Hi Folks,
I'm trying to get my emontx talking to my beagle bone black through serial connection.
So far I've read the other posts on the topic and have both of the devices talking to each other.
- I'm running the sketch for serial connection https://github.com/openenergymonitor/emonTxFirmware/blob/master/emonTxV3/noRF/emonTxV3_DirectSerial/emonTxV3_DirectSerial.ino
- I'm using the latest code for emonhub from github on the bbb.
It seems with the serial communication between my serial node and emonhub I can't get emonhub to agree with the datacodes values. My emonhub.conf is as follows:
[[Serial]]
Type = EmonHubSerialInterfacer
[[[init_settings]]]
com_port = /dev/ttyO2
com_baud = 9600
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
subchannels = ToSerial,
basetopic = emonhub/
[[10]]
nodename = emonTx_1
firmware =V1_6_emonTxV3_4_DiscreteSampling.ino
hardware = emonTx_(NodeID_DIP_Switch1:OFF)
#hardware = emonTx_1
[[[rx]]]
names = power1, power2, power3, power4, Vrms, temp1, temp2, temp3, temp4, temp5, temp6, pulse #Firmware V1.6
#names = power1, power2, power3, power4, Vrms, temp #Firmware =<V1.4 (un-comment)
datacodes =h, h, h, h, h, h, h, h, h, h, h, h
scales = 1,1,1,1,0.01,0.1,0.1, 0.1,0.1,0.1,0.1,1 #Firmware V1.6
units =W,W,W,W,V,C,C,C,C,C,C,p #FirmwareV1.6
#scales = 1,1,1,1,0.01,0.1 #Firmware =<V1.4 (un-comment)
#units =W,W,W,W,V,C #Firmware =<V1.4 (un-comment)
There error I'm getting is that the size of the data recieved is not matching that of the calculated datacodes.
2015-03-02 04:01:32,325 DEBUG Serial 1 NEW FRAME : 10 0 0 0 0 24620 3000 3000 3000 3000 3000 3000 19909with size 52
2015-03-02 04:01:32,329 DEBUG Serial ######ALP DEBUG: nodeid 10 size 12 data [0, 0, 0, 0, 24620, 3000, 3000, 3000, 3000, 3000, 3000, 19909]
2015-03-02 04:01:32,335 DEBUG Serial Printing Datacodes ['h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h']
2015-03-02 04:01:32,339 WARNING Serial 1 RX data length: 12 is not valid for datacodes ['h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h']calculated datasize: 24
2015-03-02 04:01:32,342 WARNING Serial 1 RX data length: 12 is not valid for datacodes ['h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h', 'h']calculated datasize: 24
Note i've added some extra debugging to emon_interfacer.py to try to figure out the problem.
What's interesting is I've compared the same data sent with the RF sketch to the emonpi and added the same debug logging there.
emon pi raw: [0, 0, 0, 0, 0, 0, 0, 0, 136, 97, 184, 11, 184, 11, 184, 11, 184, 11, 184, 11, 184, 11, 1, 0]
emon pi parsed: [0, 0, 0, 0, 249.68, 300, 300, 300, 300, 300, 300, 1]
bbb: [0, 0, 0, 0, 24945, 3000, 3000, 3000, 3000, 3000, 3000, 19907]
on the emon pi this works when the data comes through RF and the datasize appears as 24 but on the bbb through serial the same data size is 12. Not sure where the difference is here.
Thanks again for any assistance.
All the best,
Alp
Re: Emontx_V3 serial direct problems
Hi Alp
The main difference between the rf and non-rf versions of the sketch is that the rf version packages the data up as a stream of byte values which emonHub needs to reconstruct to real values, hence the datacodes are the key whereas the non-rf version prints all the characters of each value to the serial port, so the latter doesn't need decoding just reading.
ie in your "emon pi raw:" example the 136 and 97 are 2 bytes of the integer 24968, which is then scaled by 0.01 to reach the "emon pi parsed:" value of 249.68. however the same value is passed as the string of characters "249.68" via the Serial.print() of the non-rf version
Use " datacode = 0" to define "zero decoding required" or "datacodes = 0,0,0,0,0,0,0,0,0,0,0,0" to define 12 values which do not require decoding"
Paul
Re: Emontx_V3 serial direct problems
Hi Paul,
That makes complete sense , I figured it was something like that. Does it make sense to update the wiki documentation for a serial connection accordingly? I'm happy to do this if no one else is up for it!
All the best,
Alp