After a couple of months building LoRa field gateways and demo clients I figured a selection of sample projects (with analog, digital, I2C and serial sensors) 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 ultraviolet (UV) levels as an example of an I2C connected sensor. I have based this project on a solution built by a student at a maker class I run at a local girls school.
New Zealand has high UV levels (causing one of highest skin cancer rates in the world) and the student wanted to illuminate a sign or display a message as students went outside to tell them they had to put on a hat if UV levels were high.
Some of the senior students are looking at extending this with, a Raspberry PI, camera and machine learning (Microsoft Azure Custom Vision) to check that the junior students are actually wearing a hat.
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, and use spare cellphone chargers to power the Arduino or Seeeduino device.
The duino client uses a SeeedStudio Grove - I2C UV Sensor (VEML6070), base shield (Arduino only, as Seeeduino V4 has an onboard I2C socket) and a Dragino, MakerFabs or Elecrow LoRa shield.
The first step is to mount the Grove Base Shield on the Arduino and plug the Grove UV sensor into a I2C socket. For the Seeeduino plug the plug the Grove UV sensor into the onboard I2C socket.
The seeedstudio wiki has step by step instruction and sample code
#include "Seeed_VEML6070.h"
/*SAMD core*/
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL SerialUSB
#else
#define SERIAL Serial
#endif
VEML6070 sensor;
char *UV_str[]={"low level","moderate level","high_level","very high","extreme"};
err_t read_UV()
{
err_t ret=NO_ERROR;
u16 step;
sensor.wait_for_ready();
CHECK_RESULT(ret,sensor.read_step(step));
SERIAL.print("UV step = ");
SERIAL.println(step);
RISK_LEVEL level=sensor.convert_to_risk_level(step);
SERIAL.print("UV level is ");
SERIAL.println(UV_str[level]);
SERIAL.println(" ");
SERIAL.println(" ");
SERIAL.println(" ");
return ret;
}
void setup()
{
SERIAL.begin(115200);
delay(10);
SERIAL.println("serial start!!");
delay(1000);
if(sensor.init())
{
SERIAL.println("init failed!!!");
}
/*threshold is 145 steps*/
/*enable*/
sensor.set_interrupt(INT_145_STEP,ENABLE);
}
void loop()
{
if(read_UV())
{
SERIAL.print("read UV sensor failed!!");
}
//sensor.enable();
//sensor.disable();
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 GatewayI 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 checking the sensor data is being received and getting the BCD representations of sensor identifiers.
For extension projects students have compared the performance of different shields for the UV sensor (toughened vs. quartz vs. laminated glass etc.) and 3D printed enclosures.
Comments