@pb66 and @TrystanLea, this is probably a question for you, I’m guessing.
I recently did a write-up about using a Moteino as an RFM69Pi with the JeeLib Classic format. I also contributed to a topic, explaining how I used a Moteino LoRa repeating JeeLib Classic packets into the serial interfacer to bridge a long distance to an emonBase.
In these examples I was telling people to use Type = EmonHubSerialInterfacer in the emonHub configuration:
[[SerialDirect]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyUSB0
com_baud = 38400
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
subchannels = ToRFM12,
Then I set about writing up how I have, in the past, used a Moteino running the LowPowerLab RF69 library to collect packets from other such Moteinos and format it correctly for the emonHub serial interfacer.
When I went to test my old LowPowerLab-based sketch, it would not work with my emonBase unless I used the EmonHubJeeInterfacer. If I kept the Type=EmonHubSerialInterfacer the non-numeric ‘OK’ would cause errors:
ValueError: invalid literal for int() with base 10: ‘OK’
It seemed odd to me that I wasn’t getting those errors with the sketches I had recently been posting about, with the JeeLibClassic-to-USB and the RadioHead-LoRa-to-USB technique. These also produced the characters “OK” at the front of the serial output.
So I went back to re-test my JeeLibClassic Moteino USB-based RFM69Pi that I had so recently posted about. Sure enough, the “OK” problem tripped me up.
The TLDR for those out there that run into this problem is: use the EmonHubJeeInterfacer type instead. It works for all the USB-based interfacers I mention above.
But for me, I’d like to know why I was getting the emonHubSerialInterfacer to work yesterday (and in fact it is still working in the case of the LoRa setup I implemented last Fall and haven’t touched since) but it is not working for my tests today.
One other clue. I have two Moteinos I am testing with and I see two different errors using them with emonHubSerialInterfacer. I can’t say for certain at this time if which error I get is related to which Moteino I use, or what might be making that difference.
2023-01-22 04:40:43,279 WARNING SerialDirect Exception caught in SerialDirect thread. Traceback (most recent call last):
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 31, in wrapper
return func(*args)
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 98, in run
rxc = self.read()
File "/opt/openenergymonitor/emonhub/src/interfacers/EmonHubSerialInterfacer.py", line 90, in read
c.nodeid = int(f[0])
ValueError: invalid literal for int() with base 10: 'OK'
and
2023-01-22 04:38:54,959 WARNING SerialDirect Exception caught in SerialDirect thread. Traceback (most recent call last):
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 31, in wrapper
return func(*args)
File "/opt/openenergymonitor/emonhub/src/emonhub_interfacer.py", line 98, in run
rxc = self.read()
File "/opt/openenergymonitor/emonhub/src/interfacers/EmonHubSerialInterfacer.py", line 69, in read
self._rx_buf = self._rx_buf + self._ser.readline().decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 0: invalid start byte
And here is the sketch I am using in my Moteino USB: RFM2Pi/firmware/RFM69CW_RF_Demo_ATmega328/RFM69CW_RF12_Demo_ATmega328 at master · openenergymonitor/RFM2Pi · GitHub