I am having small project where I want to read couple of analog inputs from Arduino UNO, send it via software serial to ESP8266-01 and from that to python server using TCP.
Data is sent to ESP using this code on Arduino UNO
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int pin = 5;
void setup() {
mySerial.begin(9600);
delay(20000);
}
void loop() {
delay(1000);
int data = analogRead(pin);
mySerial.println(data);
}
Code on ESP is bellow
void loop() {
while(Serial.available()>0){
char data = Serial.read();
client.print(data);
}
}
When data is sent to Python server, it prints it out but data is sent in two seperate parts, so it always looks like this
9
59
, but number sent from arduino is just 959!
Python server code snipet:
while True:
#Receiving from client
data = conn.recv(1024)
print data
#send data to database
post.create(
current = str(data)
)
if not data:
break
So the question is, why data sent to server is separated in two parts? Maybe it have to do something with how data is reading from serial on esp?