-1

I am new to programming. kindly bear with me. I am trying to use ESP8266-01 device for serial read and write application. Before writing the full program for my application, i wanted to test how it functions. I programmed the ESP8266-01 device to read the data from its Rx pin and write it to Tx pin. I used a standard USB-TTL cable to send and receive data from PC using Hterm. The ESP device does not read the data available at the Rx pin. what am i missing ?. Also kindly help me in understanding the difference between serial.println and serial.write with respect to ESP8266-01 device. As per the program if i check the data from the Tx pin of the ESP8266 device, i get only "No data received". I am using arduino IDE 1.6.11. Kindly provide some guidance

regards

Sriniketh

#include <ESP8266WiFi.h>

void setup() {

Serial.begin(9600);
}

void loop()
{
  byte serin=0;
  if (Serial.available()>0)
  {
    serin=Serial.read();
    delay(100);
    Serial.println(serin);
    delay(100);
    Serial.write(serin);
  }
  else
  {
    Serial.println("No data received");
    delay(5000);
  }

}
  • You might mean bear rather than bare in “kindly bare with me” (which means, “kindly take off clothes together”) – James Waldby - jwpat7 Mar 12 '17 at 20:13
  • can you successfully flash the arduino sketch over that serial connection? – dandavis Mar 13 '17 at 2:51
-1

A circuit diagram or photo would help, but I would guess you have taken the lead from the PC that is marked Rx and connected to the pin on the ESP marked Rx. That's the wrong thing to do. Firstly the PC will use 5V and the ESP uses 3.3V, so you need a little board called a level shifter something like this 2 channel level shifter. This will let a 3.3v device talk to a 5V device. Some ESP boards are 5V tolerant, but I don't know what you have so ...

Then when you "talk" over serial you need to cross the Tx and Rx between the two devices, so the can 'hear' each other

 PC - Tx  ---> Rx - ESP
 PC - Rx <---- Tx - ESP

(Lots of other level shifters are available and a lot are cheaper than the example shown, a lot cheaper!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy