Hello All,
I am working on a project where i would like to send the float value from my esp32 to my python program over wifi using python socket, but I am only able to receive number till the decimal point.
Can you please help me understand where am i going wrong
ARDUINO CODE:
#include <WiFi.h>
const char* ssid = "********";
const char* password = "*******";
int value = 0;
const uint16_t port = 8092;
const char *host = "********";
WiFiClient client;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("...");
}
Serial.print("WiFi connected with IP: ");
Serial.println(WiFi.localIP());
if (!client.connect(host, port)) {
Serial.println("Connection to host failed");
delay(1000);
return; }
Serial.println("Connected to server successful!");
}
void loop()
{ float a=108.67;
//client.flush();
//client.print("Hello World. Hello");
client.print(a);
//delay(100);
String line = client.readStringUntil('\r');
Serial.println(line);
}
Python code:
import time
import socket
s = socket.socket()
s.bind(("********", 8092 ))
s.listen(0)
while True:
client, addr = s.accept()
if i == 1:
content = client.recv(1024)
print(len(content))
print(content)
content = 0
client.close()
The output on my python server is
3
108
3
108
...