I’m having some strange serial comms issues, or just simple device hanging. Can anyone offer some advice on if my Leo broken somehow, or I’m doing something badly in terms of the serial I/O?
But before I get into that, from posts on this forum and elsewhere it seems the Leos specifically are having significant serial comms / USB issues - am I right? My experience with this Leo has been poor, with comms issues right out of the box regardless of which host I connect it to (Mac, Windows, Linux) or the serial port I try to use.
What I’ve currently got is the Leo connected to a Raspberry Pi via USB and the serial1 (TX/RX) pins. Trying to do serial comms over the USB is a disaster because that connection is so flaky so I’m only using the USB port for programming the device. From there I do all my program interface comms via serial1 which I’ve wired back to the Pi’s matching TX/RX ports - with appropriate handing of the Leo’s 5V TX down to the Pi’s 3.3V RX etc.
I’m trying to use the Leo to read the IR output from a Elster electricity meter, so I have a photodiode wired to a Leo digital pin. I’ve been careful with the device in relation to handling, static, voltages etc - electrically everything is simple enough and should be ok.
I’ve attached the code I’m using. When I run that code on the Leo it hangs under the initial load of reading the meter pulses (at 2400 baud).
Here’s the output from the code at the moment:
ReadMeter started. Debug: ON Read  ON Finding next IR session000000000000000000000000000000000000000000000000000000000000000000000000000000ReadMeter started. ON Finding next IR sessionReadMeter started. Help d Toggle debug output on/off o Toggle IR monitoring on/off v Toggle verbose output on/off reset Resets the program.
Basically, when it starts doing the run of zero’s that is the interrupt function being called on each IR pulse from the meter. Sometimes I’ll get 5 pulses, sometimes 50… but the code always hangs at this point. From there the watchdog kicks in and restarts processing - indicated by “ReadMeter started”. The code hangs if I have the debug output (the zeros) on or off.
What’s interesting is when I’m having these I/O issues over serial1 the USB port is usually in trouble too. Either it’s dropped or, usually, is just unresponsive. I need to reset the device before I can do an erase cycle and upload any code.
I’ve built this code up from a simple prototype and at times I’ve had it running fairly smoothly where the interrupt function is being initiated correctly and printing a single character each time. I’ve noticed as I’ve tried to increase the amount of data being output the Leo, or try to add features like the watchdog the device performance has just got worse and worse. Trying to do serial comms from the interrupt function itself seems very problematic so I’ve moved that into the main loop where possible.
I know this is the wrong forum for discussing code issues, I’m just trying to show that I’ve tried to work around, over, under and through all the serial comms issues I’ve seen on the Leo and so far it’s gotten nowhere. It’s looking like a device issue to me.
I’ve seen posts on other forums where serial issues have been solved by updating the bootloader. Is that something to try here? Perhaps the device is just a bad one, bad batch? Or I’m happy for my code to be the issue, but I’m just not seeing it.
ReadMeter.ino (6.32 KB)