TTN version: | TTNv3 |
Activation: | ABP |
Device Class: | Class A |
Last updated: | October 7, 2023 |
This article provides instructions for making a temperature sensor using Adafruit Feather 32u4 RFM95 LoRa Radio and DS18B20. If you haven’t set up Adafruit Feather 32u4 yet, check out our Adafruit Feather 32u4 tutorial.
Prepare
- Adafruit Feather 32u4 RFM95 LoRa Radio
- DS18B20
- 4x wire
- 4.7k resistor
- breadboard (optional)
- PC + micro USB cable
DS18B20
To measure temperature, we will use the DS18B20 temperature sensor. The sensor measures temperatures in the range of -55 ºC to 125 ºC. In the range of -10 ºC to 85 ºC, the measurement accuracy is ± 0.5 ºC.
Sensor assembly
Connect everything according to the schematics bellow.
Wire up the Adafruit Feather 32u4’s IO1 pin with pin 6. The sensor is connected using three wires. The red wire (Vcc) is connected to the supply voltage (3V pin on Adafruit Feather 32u4) and the black wire (GND) is connected to ground (GND pin on Feather). The yellow wire (DQ) is used for data transmission via the 1-Wire bus and is connected to Feather’s digital pin 12. Between red and yellow DS18B20 wires is connected 4,7k resistor. The sensor requires a stabilized supply voltage in the range of 3 V to 5.5 V for its function.
Arduino IDE setup
- Run Arduino IDE.
- In the Arduino IDE Library Manager search DallasTemperature by Miles Burton and install it with all dependencies (library OneWire).
- In the Arduino IDE Library Manager search CayenneLPP by Electronic Cats and install it.
- Download as ZIP this Low-Power library by Rocketscream.
- In the Arduino IDE Sketch -> Include Library -> Add .ZIP Library… choose downloaded ZIP.
Printing measured values to Serial Monitor
- Copy and paste this program to your Arduino IDE.
- Connect Adafruit Feather 32u4 using micro USB cable to your computer.
- In Arduino IDE click on Upload button to upload program to your Adafruit Feather 32u4.
- In Arduino IDE click on Serial Monitor button and you should every 10 seconds see this:
Sending measured values to TTS
We have prepared four programs for measuring temperature. The first program sends the current measured values. The second program sends averages of measured values over a certain period of time. The other two programs extend the first two with a low power mode, which is great when you run this sensor on battery power.
Programs
- Current measured values
- Averages of measured values
- Current measured values with low power mode
- Averages of measured values with low power mode
Instructions
- Copy and paste one of this programs to your Arduino IDE.
- In program replace NWKSKEY, APPSKEY and DEVADDR with keys of your end device registred in TTS. Keys are in TTS -> Applications -> YourAppName -> YourEndDeviceName -> Overview -> Session information.
- In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Payload formatters -> Uplink change Formatter type to CayenneLPP. For more information, check out our Cayenne LPP tutorial.
- Click on Save changes.
- Connect Adafruit Feather 32u4 using micro USB cable to your computer.
- In Arduino IDE click on Upload button to upload program to your Adafruit Feather 32u4.
- In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Live data you should every 5 minutes (Low Power Mode – 10 minutes) see this:
Data visualization
If you want to visualize your measured data, continue with the following tutorial: