Project tutorial
Education with IoT- LoRa+Arduino - Some Assembly Required #3

Education with IoT- LoRa+Arduino - Some Assembly Required #3 © MIT

This sample project shows how to build a LoRa connected UV sensor(I2C)

  • 2,242 views
  • 3 comments
  • 1 respect

Components and supplies

Apps and online services

About this project

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 Device

To 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 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 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.

Code

Duino sample application
Download then compile and deploy to device with Arduino IDE
Duino sample client
Download the code, modify the configuration, build then download to your device.

Comments

Similar projects you might like

Education with IoT- LoRa+Arduino - Some Assembly Required #2

Project tutorial by Bryn Lewis

  • 919 views
  • 0 comments
  • 10 respects

Smart Plant IoT

Project tutorial by Shin Ae Hong and Peter Ma

  • 8,369 views
  • 3 comments
  • 31 respects

*Duino Field Gateway Clients

Project tutorial by Bryn Lewis

  • 884 views
  • 0 comments
  • 7 respects

GPS Datalogger, Spatial Analysis, and Azure IoT Hub.

Project tutorial by Shawn Cruise

  • 16,940 views
  • 4 comments
  • 61 respects

DHT Tiny Breakout for the Raspberry Pi

Project tutorial by Daniel Porrey

  • 6,079 views
  • 5 comments
  • 15 respects

TIA Weak Artificial Intelligence IoT Assistant

Project tutorial by Adam Milton-Barker

  • 3,943 views
  • 0 comments
  • 22 respects
Add projectSign up / Login