-
Sometimes when I re-boot a datalogger using an ESP32-SPIRAM variant The SBMS0 is a battery management system which is sending out data I read one "fix" could be to deinit the UART and init it again, but this Maybe a I have a watchdog timer that will kick-in after 90 seconds, which gives me Any suggestions on a better way to do this are appreciated. # open serial connection, SBMS0 must be set to same BAUD rate
# and a 1sec logging interval on the SBMS0
#ser = UART(1) # ok for a ESP32
#ser.init(baudrate=19200, tx=19, rx=18, bits=8, parity=None, stop=1, timeout=300)
# for an ESP32_SPIRAM or you get a Guru Meditation Error on boot-up
# see https://github.com/micropython/micropython/issues/6166
ser = UART(1, baudrate=19200, bits=8, parity=None, stop=1, rx=18, tx=19, timeout=300)
ser.deinit() # to hopefully stop a unicode error on boot-up
time.sleep(1) # nope ... try a sleep
ser = UART(1, baudrate=19200, bits=8, parity=None, stop=1, rx=18, tx=19, timeout=300) This still seems problematic: try:
ser = UART(1, baudrate=19200, bits=8, parity=None, stop=1, rx=18, tx=19, timeout=300)
except:
ser.deinit() # to hopefully stop a unicode error on boot-up
time.sleep_ms(500)
ser = UART(1, baudrate=19200, bits=8, parity=None, stop=1, rx=18, tx=19, timeout=300) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
The unicode error is likely due to getting garbage characters at start-up. You don't show what you're doing with the bytes you read from the UART, but in my experience it helps to process the bytes as they come in and reject inappropriate ones. Don't assume that
|
Beta Was this translation helpful? Give feedback.
-
@ned-pcs This is an example format from the manual: This is what I use for testing: delimiter? Don't think so. Test length before decode sounds like a better approach. I will do some testing, which is not easy as the error only happens rather infrequently. @Josverl I am only doing this in upython Thanks for the suggestions. |
Beta Was this translation helpful? Give feedback.
Right ... I made a mistake thinking I had to do length
var_sbms
!Give me a few days and I will report back hopefully with a
Mark as answer
.