3

ArduinoをESP8266に接続しました

ESP の Tx に接続された Arduino のピン 2 分圧器を介して ESP の Rx に接続された Arduino ピン 3 ESP の GND に接続された Arduino GND ESP の CH_PD に接続された Arduino 3v3

1117電圧レギュレータを使用してESP8266に電力を供給しました

最初にESp8266を購入したときは動作していましたが、今ではガベージ値の無限の流れを示しています...

arduinoは次のコードでプログラムされています

#include <SoftwareSerial.h>

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2
                             // and the RX line from the esp to the Arduino's pin 3
void setup()
{
  Serial.begin(9600);
  esp8266.begin(9600); // your esp's baud rate might be different
}

void loop()
{
  if(esp8266.available()) // check if the esp is sending a message 
  {
    while(esp8266.available())
    {
      // The esp has data so display its output to the serial window 
      char c = esp8266.read(); // read the next character.
      Serial.write(c);
    }  
  }



  if(Serial.available())
  {
    // the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
    // In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
    // but we want to send everything at the same time.
    delay(1000); 

    String command="";

    while(Serial.available()) // read the command character by character
    {
        // read one character
      command+=(char)Serial.read();
    }
    esp8266.println(command); // send the read character to the esp8266
  }
}
4

6 に答える 6

0

esp8266 は 3.3v およびシリアル ポートのボー レートで動作するため、論理値を確認してください。まれに、ESP8266 に内部障害が発生し、ガベージ値が生成されることがあります。ESP8266に関する限り、ここでチェックアウトし てください。

于 2017-12-17T09:06:02.123 に答える