I'm pretty new to this whole thing, and have run into an issue with setting up serial communication between an Arduino Uno board and an ESP8266 module. Everything's hooked up and running, but what I would expect to happen doesn't seem to be working -- and I'm not sure if it's something that I'm doing wrong or something that just doesn't work like I'd think.
So...I've set up the ESP8266 so that it can fire up a server and respond to HTTP requests through a simple tutorial. That works great. What I thought I could do was simply add a serial reader to the ESP8266 and a serial writer to the Arduino (and vice-versa) so that a switch hooked up to the Arduino can trigger a response to the ESP8266.
So, on the Arduino I have a simple loop:
void loop() {
if (Serial) {
Serial.println("Testing");
delay(1000);
}
}
And on the ESP8266, I've got a reader in the loop:
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
} else {
Serial.println("No data sent.");
delay(5000);
}
...
The Serial.begin is in the setup of the ESP8266, but not in the Arduino code (when I try to use Serial.begin from the Arduino, the ESP8266 does't start up properly).
So, having said all of that, here's what I'm shooting for:
I want to have a switch that, when its state is changed, triggers the ESP8266 to post to a website. Seems easy in theory, but in practice this is much more complicated that I thought it would be.
Any suggestions would be greatly appreciated.