Skip to main content
Arduino

Return to Revisions

2 of 2
typo corrected. thank you @jwpat

Serial read in ESP8266-01 not working

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);
 }
 
}
Sri

AltStyle によって変換されたページ (->オリジナル) /