trash while sending and receiving between arduino & esp
Posted: Tue Mar 15, 2016 4:36 pm
I am not sure if it is a bug, but seems so to me.
I have ESP8266 connected to Arduino. ESP has uploaded arduino sketch.
Arduino reads continously button state - it sends to ESP 0 if button is released and 1 if button is pressed. If ESP gets data it sends back to arduino's Serial port for view. This lets me check if there is any data loss between Arduino and ESP. My code is far more complicated but mainly thats how it works in simple words. Now I'd expect on arduino if button is released something like:
0
0
0
0
0
0
0
0
0
0
0
0
but i get:
)0
†0
¤0
0
0
0
áHř0
0
0
0
˙*0
0
0
0
0
¤0
R0
)0
¤0
0
A lot of trash;(
Baud speed between ESP and arduino is 115200, but i also checked other speeds - no effect.
Code:
ESP:
ARDUINO:
Does anybody have idea why does it work that way?
I have ESP8266 connected to Arduino. ESP has uploaded arduino sketch.
Arduino reads continously button state - it sends to ESP 0 if button is released and 1 if button is pressed. If ESP gets data it sends back to arduino's Serial port for view. This lets me check if there is any data loss between Arduino and ESP. My code is far more complicated but mainly thats how it works in simple words. Now I'd expect on arduino if button is released something like:
0
0
0
0
0
0
0
0
0
0
0
0
but i get:
)0
†0
¤0
0
0
0
áHř0
0
0
0
˙*0
0
0
0
0
¤0
R0
)0
¤0
0
A lot of trash;(
Baud speed between ESP and arduino is 115200, but i also checked other speeds - no effect.
Code:
ESP:
Code: Select all
void loop() {
if ( client.available()) {
String WiFiResponse = client.readStringUntil('\n');
Serial.println(WiFiResponse);
}
if ( Serial.available()) {
String SerialResponse = Serial.readStringUntil('\r\n');
client.print(SerialResponse);
Serial.print(SerialResponse);
}
if (!client.connected()) {
Serial.println();
Serial.println("Disconnecting from server.");
client.stop();
while(true);
}
}
ARDUINO:
Code: Select all
int currentButtonValue = 0;
for ( int i=0; i < numberOfButtons; i++) {
currentButtonValue = currentButtonValue + int(buttonStatus[i] * (0.5 + pow(2, i)));
}
previousButtonStatus = currentButtonValue;
Serial1.println(String(currentButtonValue));
Does anybody have idea why does it work that way?