Data from LHT65 temp sensor (LoRa) to weewx db via MQTT

150 views
Skip to first unread message

bgra...@umw.edu

unread,
Feb 13, 2023, 12:23:48 PM2/13/23
to weewx-user
Hello,
I have a Dragino LHT65 temp/hum sensor sending MQTT data from a RAK7244 LoRa gateway. Presently I also have a Seeed CO2 sensor sending data correctly to weewx (Standard skin) via MQTT--this is working via Node-Red on the weewx server (many thanks to vince and storm for the help setting this up).

Not being a programmer, I thought it would be simple to copy the CO2 flow, with certain modifications, and get the LHT65 running. Not so...
I have a connection at both ends of the NR flow but there seems to be a problem with the format of the data being parsed and exchanged. I would like to store the data as extraTemp3 in the db.LHT65flow.png
I am attaching a file of areas that might explain what the problem might be; however, I can send any additional information that might be needed.

My setup is weewx 4.10.1 (setup.py) running on ubuntu 22.04.1.
Thanks in advance for any help for this.
Cheers,
newelllht65a.txt

vince

unread,
Feb 13, 2023, 3:18:07 PM2/13/23
to weewx-user
Lets see a "mqtt_subscribe -t yourtopicname -h yourhostname" command and resulting output please, but the temperatures and humidity in your .txt file at the top sure looks like strings to me.  The syslog messages saying 'could not convert string to float' seem to agree.

bgra...@umw.edu

unread,
Feb 13, 2023, 4:47:30 PM2/13/23
to weewx-user
Thanks for the help, vince. I guess you mean mosquitto_sub because I couldn't get  mqtt_subscribe to work.

```
n4mrv:~$ sudo mosquitto_sub -t application/7/device/a84041c14184b062/rx -h 192.168.1.10:

{"applicationID":"7","applicationName":"LHT65","deviceName":"LHT65b","deviceProfileName":"my-device-profile","deviceProfileID":"67920d1f-034b-4739-8116-4bc7ebb1703d","devEUI":"a84041c14184b062","txInfo":{"frequency":904900000,"dr":0},"adr":true,"fCnt":16,"fPort":2,"data":"y9oI2AE5AQixf/8=","object":{"BatV":3.034,"Ext_sensor":"Temperature Sensor","Hum_SHT":"31.3","TempF_DS":"72.05","TempF_SHT":"72.75"}}

MQTT explorer:
{
  "applicationID": "7",
  "applicationName": "LHT65",
  "deviceName": "LHT65b",
  "deviceProfileName": "my-device-profile",
  "deviceProfileID": "67920d1f-034b-4739-8116-4bc7ebb1703d",
  "devEUI": "a84041c14184b062",
  "txInfo": {
    "frequency": 904900000,
    "dr": 0
  },
  "adr": true,
  "fCnt": 16,
  "fPort": 2,
  "data": "y9oI2AE5AQixf/8=",
  "object": {
    "BatV": 3.034,
    "Ext_sensor": "Temperature Sensor",
    "Hum_SHT": "31.3",
    "TempF_DS": "72.05",
    "TempF_SHT": "72.75"
  }
}
```

vince

unread,
Feb 13, 2023, 5:46:20 PM2/13/23
to weewx-user
Yes.  mosquitto_sub of course.

Look carefully at 'object'.   The voltage is a float.  The other items are strings.  You need to convert the humidity and temperatures to floats.

bell...@gmail.com

unread,
Feb 14, 2023, 8:15:29 AM2/14/23
to weewx-user

I am a bit confused. From your weew.conf snippet, it looks like the topic is ‘lht65b’. From your mosquitto_sub invocation you used ‘application/7/device/a84041c14184b062/rx’. From the log snippet, ‘ **** MessageCallbackProvider Ignoring topic=lht65b‘, it looks like ‘lht65b’ has the data.
The other info from the log, MQTTSubscribe is trying to convert the field ‘applicationName’ to a float.
'Failed converting field applicationName with value LHT65 using 'lambda x: to_float(x)' with reason could not convert string to float: 'LHT65''
The last important piece of information is that the json is ‘nested’. Meaning that the desired field, ‘TempF_SHT’ is nested under ‘object’.

It looks like ypu currently have one topic, ‘[[[mytopic]]]]’, configured under ‘[[topics]]’. Adding a second topic, ‘[[[lht65b]]]’ with the following configuration should accomplish what you want.
# second topic
[[[lht65b]]]
    ignore = true # opt out of all data for this topic

    # This field is ‘nested under’ object 

         [[[[object_TempF_SHT]]]] 

             ignore = false # opt in for this field 
             name = extraTemp3

Note, this is untested. If it doesn’t capture the log, post here, and we will figure out what is wrong.
rich


Reply all
Reply to author
Forward
0 new messages