-->
Page 1 of 2

RX pin

PostPosted: Tue Mar 29, 2016 6:04 am
by nogard
Hey,
No doubt a noob question... but I'm trying to get my head around it - I need to read serial data sent from a device, so have plugged its TX into the RX of the ESP8266. In code, Serial obviously relates to the debug console via USB. How do I read code coming into the RX pin? Does Serial1 exist and relate too it? Do I have to use SoftwareSerial? If I use SoftwareSerial, what pin number does RX relate too?
Sorry, I'm just too used to Arduino hardware!
Thanks

Re: RX pin

PostPosted: Tue Mar 29, 2016 2:39 pm
by willfly
Code: Select all// in setup()
Serial.begin(...);

// in loop()
if(Serial.available())  {
  int a = Serial.read();
}

Re: RX pin

PostPosted: Tue Mar 29, 2016 3:58 pm
by nogard
willfly wrote:
Code: Select all// in setup()
Serial.begin(...);

// in loop()
if(Serial.available())  {
  int a = Serial.read();
}

I'm using Serial. for the Arduino IDE Serial Monitor window to display debugging info. I want to read data from the RX pin, and display it on the Arduino IDE serial monitor window. At present, I first connect to Wifi and display my IP address using Serial.println(WiFi.localIP()); (to know its connecting correctly) then want to display serial data coming in to the RX pin in the same IDE console window (for debugging purposes) then parse through and extract the data I need and send that data to an MQTT broker. Wifi and MQTT are working, I just can't work out how to read the RX serial info.

Re: RX pin

PostPosted: Thu Mar 31, 2016 2:01 pm
by willfly
What is sending that serial data. Is it coming from Arduino IDE serial console (stuff that you type in)?

just print it back to console using this line:

Code: Select allSerial.print(Serial.read());