Intergrate MQ135 sensor with ttn-abp-feather-us915-dht22

Hey guys, im fairly new in this. But i managed to upload ttn-abp-feather-us915-dht22 and my dht22 sensor is sending the needed data to TTN.

I am trying to add another sensor (MQ135) as i need to read the air quality info. Any idea how to integrate the sensor in the same code as well as the payload decode to for TTN to read the data?

I appreciate any help anyone can give, thank you.

Lora sensor node: Dragino Lora GPS Shield with Arduino mega
Gateway: Dragino LG308

Thanks for your interest.

It’s kind of a big topic. For integrating the sensor, you can check, for example, the sketches in Catena-Sketches, for example catena4612-simple. If the sensor is simple, you have to grab the data at the right time. If the sensor is complex (requires a lot of attention) you have to do a little more work in your loop() routine.

As for uplink formats, you need the following:

  • a description – this is critical, you’ll waste lots of time if you don’t do this
  • a JavaScript decoder – so you can see your data on the TTN or other console
  • a test vector generator – something to generate sample messages to test your decoder
  • scipts foryour target data handling system – I tend to use NodeRED as part of our docker-iot-dashboard.

I suggest you start by reviewing the document catena-message-port1-format-22.md in the mcci-catena-4430 repo.

You’ll find useful starting points for all of these things.

  • The .mdfile was written as my referenence (hint: I filled in the answers for the test vectors later, and I started with a previous example).
  • Then I built the JavaScript decoder catena-message-port2-format-22-decoder-ttn.js. Again, I started with a previous example.
  • Next, I adapted the test vector generator catena-message-port2-format-22-test.cpp from a previous example. I got it to compile and tested manually.
  • Then I wrote a test-vector input file catena-message-port2-format-22.vec. I fed it into the test vector generator.
  • I copied the .js file into an application on the TTN console. (I used V2, but you can also do this on V3.) I then cut/paste the output from the test vector generator into the test input box of the TTN console. I examined the output, compared to the input; and if the JSON output looked right, I copied this back to the test vectors in the .md document.
  • Finally, I updated the code in the sketch to output the new format. By this point, I was so familiar with the new format, that this was easy.
  • Run the sketch, send data to TTN and check that the decoder decodes your data correctly.

After this, you still may need to do additional work, depending on your app. I also:

  • build a Node-RED decoder – this just calls the TTN decoder. Since TTN decoder scripts are uncontrolled, I prefer to re-decode the data in my application. See catena-message-port2-format-22-decoder-node-red.js
  • create a Node-RED function to prepare my data for InfluxDB. Again, I’m always in a hurry so I end up cutting/pasting from a prevous app. See format-22-influxdb-prep-data.js.
  • Incidentally, I find it useful to put device performance data into yet another database in my app. See influxdb-prep-rf.js for an example.

Hope this helps!