-->
Page 1 of 1

Arduino serial to ESP8266

PostPosted: Wed Jun 21, 2017 3:27 pm
by ludkokanta
I managed to set up a webserver (websockets) on the ESP8266.

I'd like to read a string from a hardware serial link from an Arduino UNO reading sensors and switches.

It is an "all in one" board with dip switches, ESP, UNO and a CH340. Pins 0 and 1 are designated for rtxt and are free...

My UNO sends a String at 9600 baud. How do I pick it up?
....setup
Serial1.begin(9600);
......loop
if ( Serial1.available() ) { string1 = Serial1.readString() ; }
...

It didn't work. Is it the other Serial? Do I change the Baud on both of them to 115200 on which the ESP comes out of the box?

Re: Arduino serial to ESP8266

PostPosted: Fri Jun 23, 2017 9:23 am
by urbanze
i can't teste this code now, but i think this work.. test and tell me!

String req;

void setup()
{
Serial.begin(115200);
}

void loop()
{
if (Serial.available() > 0)
{
req = "";
while (Serial.available() > 0)
{
char z = Serial.read();
req += z;
}

if (req == "ON")
{
digitalWrite(13, 1);
}
}
}

Re: Arduino serial to ESP8266

PostPosted: Fri Jun 23, 2017 10:53 am
by martinayotte
Nope ! it won't work with
Code: Select allreq = "";

Replace it with :
Code: Select allreq = String("");