Hi All,
I’m trying to read the ESP32 data in the form of JSON with pyserial and revert the same JSON back to the notecard with the same python script. But I can see some error logs. It seems some \ symbols added in between the data. In my Req there is no \ symbols.
Python Script:
import json
import notecard
import serial
import time
productUID = "com.gmail.pradeeplogu26:blues_wio_anomaly_detector"
if __name__ == '__main__':
ser = serial.Serial('COM22', 115200, timeout=1)
ser.flush()
serial = serial.Serial('COM7', 9600)
card = notecard.OpenSerial(serial, debug=True)
req = {"req": "hub.set"}
req["product"] = productUID
req["mode"] = "continuous"
card.Transaction(req)
while True:
if ser.in_waiting > 0:
line = ser.readline().decode('utf-8').rstrip()
print("Serial Data is" + str(line))
req = {"req": "note.add"}
req["file"] = "sensors.qo"
req["start"] = True
req["body"] = str(line)
print("Req is : " + str(req))
card.Transaction(req)
time.sleep(5)
Error Log: b’{“err”:“body: unmarshal: field body expects object_raw {io}”}’
eventhough I tried to replace " with ’ in the received JSON but the issue remains same.