Tiny House temperature monitoring using Node-RED and LoRa
Overview
- In this lesson - temperature and humidity data from a Tiny House was collected using a Pycom LoPy4 and transmitted to a local LoRa WAN Gateway
- The data was processed in The Things Network
- The data was subscribed to using MQTT using Node-RED
- A time stamp was added simple time node
- The data was processed using a process node to extract out temperature data
- The data was then packaged so that it cold be dweeted.
- The data will be available to students as a Dweet so that they can monitor the performance of their tiny house
- Students will use Python to process the dweeted data (Dweepy module)
Node-RED Configuration
mqqt-in Node
mqqt-in edit Node - Connection
- Follow the example below to configure the connection to the MQQT broker on The Things Network
mqqt-in edit Node - Security
- Follow the example below for the security configuration.
- Note that the username is whi-tinyhouse-12-temperature-pycom@ttn
- Whereas the password is a very long chanracter set (40+ characters) obtained from the The Things Network Application page.
- For security reasons, Node-RED will not retain any passwords if the node is copied.
simpletime Node
- simpletime adds time and date stamps to the data flow within Node-RED.
- The simpletime node needs to be added to Node-RED using the Manage pallet function.
- Example of default configuration of simpletime node.
function Node
- The function node is used to process data flows in Node-RED.
- In this example the function node is used to:
- Extract temperature, humidity and battery data from the mqtt in data feed
- Then assign the data to variables
- And finally, dweet the data so that the data is available to students on the internet.
- Code reproduced below.
- Add your own unique dweet address to the code.
- The dweet address also requires the question mark symbol at the end - <My_Dweet_address>?
var battery; // battery voltage data
var int_humidity; // humidity data from within the sensor housing
var ext_temp; // external temperature data
var int_temp; // temperature data from within the sensor housing
battery = msg.payload.uplink_message.decoded_payload.bat;
int_humidity = msg.payload.uplink_message.decoded_payload.humid;
ext_temp = msg.payload.uplink_message.decoded_payload.onewire_temp;
int_temp = msg.payload.uplink_message.decoded_payload.temp;
msg.payload = "bat=" + String(battery) + "&"
+ "intHumid=" + String(int_humidity) + "&"
+ "extTemp=" + String(ext_temp) + "&"
+ "intTemp=" + String(int_temp) + "&"
+ "date=" + String(msg.myymd) + " " + String(msg.mytimes);
msg.url = "https://dweet.io/dweet/for/<My_Dweet_address>?" + msg.payload;
// check dweet with - https://dweet.io/get/latest/dweet/for/<My_Dweet_address>
return msg;
http request Node
- The http request node is able to Dweet the data package using the POST http operation.
- The configuration of the http request node is shown below.
- The node has been named dweet tiny house 12 data (name is lower down in node edit window - not shown).