Exploring soil moisture sensors

From Sensors in Schools
Revision as of 05:25, 1 January 2022 by EdmondLascaris (talk | contribs)
Jump to navigation Jump to search

Connecting to a soil moisture sensor via The Things Network (TTN)

Overview

  • In this lesson we are going to connect to a soil moisture sensor.
  • The soil moisture sensor is connected to an Arduino MKR 1300 microcontroller (a small computer).
  • The data will be transmitted to the LoRa network.
  • LoRa is short for Long Range radio communication.
  • The data is then sent to The Things Network, which is a community run server that collects data from sensors and makes the data available for download.
  • We will download the data to our Raspberry Pi, and in future lessons display that data in a Dashboard using Node-RED.
  • All these skills are very important in helping to address Climate Change and general Environmental Sustainability issues the world faces.

Learning Objectives

  • Learn how to connect to The Things Network using MQTT using Node-Red
  • Learn how to extract specific data from JSON formatted data packets

Connecting to the Things network using Node-RED

  • In this lesson we are going to use Node-RED as our main programming tool.
  • Node-RED is a block or node based programming language.
  • Each block has a discrete function and some blocks can contain Javascript code or be configured in different ways.
  • Blocks are connected together using wires.
  • Node-RED and the programs on the Raspberry Pi are always being updated, so it’s normally good practise to update our Raspberry Pi on a regular basis.


Updating and Upgrading the Raspberry Pi

  • Open the Raspberry Pi Terminal.
  • Enter the command sudo apt-get update

  • This command will update all the software libraries on the Raspberry Pi, so that if we need to install software the Pi will install the latest software packages.
  • Enter the command sudo apt-get full-upgrade -y
  • This command will upgrade the entire operating system on the Raspberry Pi.
  • The -y option tells the computer to answer Yes to any questions.
  • The upgrade will take between 5 and 30 minutes to complete.
  • It is always to do this once every month.

Running Node-RED on the Raspberry Pi

  • Open the Terminal.
  • To start Node-RED enter the command node-red

  • The display on your Raspberry Pi will be different, but similar enough.
  • When using Node-RED it is important to stop Node-RED when you are shutting down your computer.
  • To close Node-RED open a new Terminal window and enter the command node-red-stop
  • To re-start Node-RED enter either node-red or node-red-start