And it looks like that there is no problem with this module, I receive proper output:
port opened SerialTransport(<_UnixSelectorEventLoop running=True closed=False debug=False>, <__main__.Output object at 0x764d09b0>, Serial<id=0x764d06b0, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False))
data received b'{"channel_1":1,"temperature_1":1'
data received b'7.5,"humidity_1":45,"battery_1":'
data received b'90}'
port closed
So… it points into “serial sensor” module in hass…
Try making a custom component with that serial.py. Add your own debug lines to it to verify. That whole section would be silent. It could be stuck on the while loop after or the serial constructor before.
The problem was in… lack of “\n” and the end of each line received over serial (readline expects that!).
In my case my arduino sketch sent just json’s lines…without proper line ending.
So I added: Serial.println();
after sending my json string in my sketch and… it resolved the problem.
@petro: thank you! you helped me a lot. Sometimes just pointing at some direction results in different perspective of the problem.
Necro’d this aging thread to mention the wonderful arduinojson.h library… in case others are looking in to setting up a similar thing.
I used this library for the code on my nano that sends 4 raw adc values to hass for doorbell, mains power, ups power, and backup battery voltage. It saved me from having think about formatting print statements… instead I could focus on the app specific stuff, like timing and anti-spam. The library made this the easiest/quickest/shortest arduino project I have ever done (yes I skipped right past the ‘blink’ examples etc lol).
allowing a custom string to be set as the ‘end of line’ for each integration, as i have a few usb devices that act differently, some using \r some using \n some using \r and \n.
having a custom ‘polling’ option, as some of my usb devices dont consistenly give a update at a timed interval, where as other devices do send an update every 60 seconds.
and with that option also, being able to set the command sent to poll the device.
I imagine the new ‘template sensor’ can semi-handle the task, but ive yet to try to implement it in a way that suits my needs.
same for a an initial connected command.
I have
numerous USB-EZO devices by atlas scientific.
A few Numato-USB devices by Numato
a few USB-Relays that have their own language by themself, but similar to Dekovis USB relays.
They all work in their own special way.
Then my arduino uno i use to test my usb integration as i cant always tell if what im doing is going to work without debugging from my windows computer.
Working on something similar.
I’ve got the JSON string coming in to a sensor named sensor.nano (verified in the Template editor), but I’m now struggling to pull out the individual values (ie temperature and humidity).
How did you do it?