After a couple of months building LoRa field gateways and demo clients I figured a couple of sample projects to show how to use all these building blocks would useful for students, teachers & hobbyists.
This is an end-to-end demo using a duino device and one of my Windows 10 IoT Core LoRa field gateways to remotely monitor the soil moisture level of indoor plants as an example of an analog sensor. I have based this project on a series of maker classes I run at a couple of local schools.
This project should be read in conjunction with my other Hackster projects.
The Duino DeviceTo keep things simple the sensor nodes are plug 'n' play, use spare cellphone chargers to power the Arduino or Seeeduino device and the devices are intended for indoor use only so there is no need for weatherproof enclosures.
The duino client uses one or more Seedstudio Grove moisture sensor(s), a base shield and a Dragino, MakerFabs or Elecrow LoRa shield.
The first step is to mount the Grove Base Shield on the duino and plug the grove moisture sensor into an analog input. (Make sure the voltage setting matches your device)
The seeedstudio wiki has step by step instruction and sample code
int sensorPin = A0;
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print("Moisture = " );
Serial.println(sensorValue);
delay(1000);
}
When compiled and downloaded to the device this code confirms the sensor is working. After looking at the values in the Arduino IDE Serial monitor there is usually a discussion about what they "mean".
I get students to connect the probe pins together with one, two or three damp fingers to show changing values and wiggle the probes in the dirt to show how this can impact the readings
Then, I get the students to explore the minimum (distilled or deionised water) & maximum (water with a small amount of salt) sensor values they can measure. Trials with different soil types and moisture levels work well but can be a little messy in a classroom environment.
The students usually display the moisture values as a percentage using the map function.
int sensorPin = A0;
int sensorValue = 0.0;
#define sensorMin 0
#define sensorMax 1023
#define valueMin 0
#define valueMax 100
void setup() {
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print("Sensor = " );
Serial.print(sensorValue);
// Convert it to a percentage
sensorValue = map(sensorValue, sensorMin, sensorMax, valueMin, valueMax);
Serial.print(" Moisture = " );
Serial.print(sensorValue);
Serial.println("%");
delay(1000);
}
Once the students are confident with building & deploying the code from the Arduino IDE the focus shifts to the LoRa wireless connectivity.
The students use my Hackster duino client sample as the basis of their application.
Pay attention to your local ISM band regulations and ensure that you are compliant with them, especially frequency, power levels and duty cycle requirements.
Send data as infrequently as possible and reduce the transmit power to the minimum level required for reliable data transmission. If interference is a problem change frequencies\sync word.
The Windows 10 IoT Core Field Gateway
I have prebuilt LoRa telemetry field gateway Hackster projects for AdaFruit.IO and Azure IoT Hubs\Azure IOT Central.
Once the field gateway is installed and running the Windows 10 IoT Core the ETW logging is useful for check the sensor data is being received and getting the BCD representations of sensor identifiers.
It is assumed that you have an AdaFruit.IO or Azure IoT Central account setup and can perform basic configuration tasks.
There are free\educational pricing options for AdaFruit.IO,Azure IoT Hubs and Microsoft Azure IoT Central.
They way that Adafruit IO "automagically" provisions new feeds with the SensorID is really helpful.
For extension projects students have added more moisture sensors, built with battery powered devices which have required some experimentation with power conservation libraries.
Comments