DefProc

Hackday: Connecting Sensors with LoRaWAN

Now there’s a larger coverage area of LoRaWAN in Liverpool that provides free access to the public The Things Network service, it’s the ideal time to start connecting more devices, more sensors, and taking advantage of this long range, low power, low cost way of connecting devices to the internet.

The great Arduino library from The Things Network means that getting started with using LoRaWAN is just a matter of finding coverage and a LoRaWAN modem. At the current time though, the TTN hardware has not started shipping, so we made some LoRaWAN shields, and ran a hackday at DoES Liverpool to get more people connected.

As is traditional in hackdays, progress on the day was captured in a shared document. While the main focus for many was on setting up their first LoRaWAN connection, and finding out how LoRaWAN might fit in with their project ideas, there were some great projects taking shape.

Links to the shared document:

Temperature Sensor

One of my focuses of the day was to complete an initial hello world for those new to Arduino, or those looking for a base to start using LoRaWAN that goes from sensor to online recording.

Using a DS18B20 temperature sensor, take a reading, report it over LoRaWAN to The Things Network (TTN) using the Cayenne payload structure, set the payload interpreter to Cayenne, connect to myDevices Cayenne, and create a dashboard to show current temperature.

Getting started:

Device Info sketch for the Uno & shield:

Copy to Clipboard
  • Make an account on The Things Network,
  • go to the TTN console
  • select applications and + add application
  • Set
    • Application ID (you’ll need to use when you use the application),
    • Description (up to you)
    • Handler registration to ttn-handler-eu
  • From your application page, + register device
    • Device ID (something you can uniquely identify that radio with),
    • Device EUI (reported from the sketch above),
  • Then load a basic sketch onto your device to test the data transfer:
Copy to Clipboard
  • Load the sketch and watch on the serial monitor
  • Also watch on the data tab to see the incoming data

Send temperature:

  • Add the OneWire and DallasTemperature libraries to the Arduino IDE,
  • Connect the DS18B20 sensor to power, ground, and the signal wire to pin D6 on the arduino (or another of your choice),
  • connect a 4.7k resistor between power and the signal line (this is requred for proper opperation of the sensor, but in a pinch you’ll probably get away with two 10k resistors in parallel),
  • load the following sketch (after changing the appEui and appKey) to match your application:

This example uses the Cayenne LPP format so it can be recreated back into a JSON objects without having to do any custom float to byte array translation or javascript re-building

Copy to Clipboard
  • New messages should appear in the application, data on the console with the a "temperature_1: xx.x" visible in the processed payload,
  • In the Things Network Console for your application set the Payload Formats to be Cayenne LPP,
  • Create an account at myDevices Cayenne
  • Add newDevices & WigetsLoRa (beta)The Things NetworkCayenne LPP
  • Enter the Device EUI from the TTN console,
  • Back on the TTN console for the application → Applications+ add integration → choose Cayenne,
    • Enter a Process ID of your choice (anything),
    • Select an Access Key (one of the allowed MQTT passwords on the application to pass to Cayenne)
  • New data from this device will automatically propogate to myDevices Cayenne, so entries for temperature, RSSI and SNR for this device will appear when it next sends.
  • Many attendees found that receiving mesages using node-red provided more flexibility in pricessing and using messages.
Exit mobile version