极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 16871|回复: 1

求大神指点!esp8266传输数据问题

[复制链接]
发表于 2015-1-22 00:27:42 | 显示全部楼层 |阅读模式
我现在用uno板连接一个ttl摄像头,已经调试成功了,代码如下(太多,省略了后面部分),然后又连接esp8266,也调试成功了,代码就不贴了,现在问题来了,我把两个东西同时连到uno上,需要怎么样才能让摄像头输出的数据传到8266上,并发射出去呢???大神们快来帮帮忙吧!谢谢
#include <SoftwareSerial.h>

byte incomingbyte;
SoftwareSerial mySerial(4,5);                     //Configure pin 4 and 5 as soft serial port
int a=0x0000,j=0,k=0,count=0;                    //Read Starting address      
uint8_t MH,ML;
boolean EndFlag=0;

void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();

void setup()
{
  Serial.begin(19200);
  mySerial.begin(38400);
  delay(2000);
  WIFISerial.println("AT+RST");
  delay(2000);
}

void loop()
{
     SendResetCmd();
     delay(4000);                               //After reset, wait 2-3 second to send take picture command

      SendTakePhotoCmd();
  if (mySerial.available()){
    WIFISerial.write(mySerial.read());
  }
     while(mySerial.available()>0)
      {
        incomingbyte=mySerial.read();

      }  
      byte a[32];

      while(!EndFlag)
      {
         j=0;
         k=0;
         count=0;
         SendReadDataCmd();

         delay(25);
          while(mySerial.available()>0)
          {
               incomingbyte=mySerial.read();
               k++;
               if((k>5)&&(j<32)&&(!EndFlag))
               {
               a[j]=incomingbyte;
               if((a[j-1]==0xFF)&&(a[j]==0xD9))      //Check if the picture is over
               EndFlag=1;                          
               j++;
        count++;
               }
          }

          for(j=0;j<count;j++)
          {   if(a[j]<0x10)
              Serial.print("0");
              Serial.print(a[j],HEX);
              Serial.print(" ");
          }                                       //Send jpeg picture over the serial port
          Serial.println();
      }     
     while(1);
}
回复

使用道具 举报

发表于 2015-3-1 00:29:28 来自手机 | 显示全部楼层
请教你的WiFi串口用的是Uno上面的串口通讯端口0和1吗?
还用的soft.serial软串口?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-10 12:35 , Processed in 0.039630 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表