Lora Sensors

Sensor Network

Have been looking at deploying a sensor network for a while now.

Live on land here. My desire is to deploy basic sensors around the block reporting conditions (temp, humidity..) and also to activate relays (water system) or actuators (chicken house door). They will need to be watertight and low power. This is not a surveillance network. Its a sensor network spread across 4ha. The sensors will be distributed across the area with 200m being the longest path.

I have looked at deploying sensors using wireless or Bluetooth but neither were suitable. Either would work but range limited and high power requirements.

Whilst reading Glenn VK3YY’s blog describing LoRa tracker I recognised the opportunity LoRa presented.

LoRa stands for Long Range. This is a wireless Radio frequency technology introduced by a company called Semtech. This technology can be used to transmit bi-directional information to long distance without consuming much power. This is designed for remote sensors which have to transmit its data by just operating on a small battery. The LoRaWAN® specification is for a Low Power, Wide Area (LPWA) networking protocol designed to wireless connect battery operated ‘things’ to the internet in regional, national or global networks, and targets key Internet of Things (IoT) requirements such as bi-directional communication, end-to-end security, mobility and localization services.

Intend to use the (433MHz) LoRa transceiver modules based on SX1268 chips from Semtech Corporation and LoRa protocol for the network layer of my sensor network.

Use of 433MHz is legal to use in Australia without any form of licensing up to 25mW. Also included on Amateur 70cm band 420 – 450 MHz. Primary Service is  ‘RADIOLOCATION’ with Amateur as Secondary.

Difference between LoRa and LoRaWAN

  • LoRa is the modulation technique used in the physical layer of LoRaWAN network. It is basically CSS (Chirp Spread Spectrum) modulation used to provide different data rates using different spreading factors.
    • The basic principle is that information is encoded using chirp (a gradual increase or decrease in the frequency of the carrier wave over time).
    • Before sending a message, the LoRa transmitter will send out a chirp signal to check that the band is free to send the message.
    • Once the LoRa receiver has picked up the preamble chirp from the transmitter, the end of the preamble is signalled by the reverse chirp, which tells the LoRa transmitter that is it clear to begin transmission.
  • LoRa contains only the link layer protocol.
  • LoRaWAN includes the network layer RF, PHY, MAC and Application layer.
Lora the protocol will send what you tell it to. I will be using it to send information between the sensors and gateway (P2P communications) then the gateway will use HTTP over IP (WiFi) to send to application server.

High level view

Here is my proposed private IOT network.

Iot 12022020

Sensors, actuators, gateways and servers.

The network will consists of sensors, actuators, gateways and servers.

1. Sensors:

  • Sensors capture and transmit data to gateways over distances near and far, indoor and outdoor, with minimal power requirement.
  • Sensors will be based on Arduino devices
  • Sensors can be based on ESP32 devices.
  • End-nodes, or sensor devices will use LoRa Modulation (LoRa Technology) as the physical (PHY) silicon layer to create the long-range communication links
  • There is a wide range of input options
    • BME280 – temperature, humidity and atmospheric pressure sensor.
    • CC811 – CO2 and TVOC (total volatile organic compounds) sensor.
    • SDS011 – Dust sensor (particulate matter – PM 2.5 and PM 10).
    • MQ135 – Gas sensor. Has high sensitivity to Ammonia, Sulfide and Benze steam, also sensitive to smoke and other harmful gases.
    • AS3935 – Franklin lightning sensor (voltage divider)
    • https://create.arduino.cc/projecthub/projects/tags/sensor …..
  • Output will be relays or actuators depending on use. A relay can switch a water Solenoid whilst an actuator could close a chicken house door.

2. LoRa Gateway:

  • Gateways send information via Wi-Fi to devices on the TCP/IP Ethernet network.
  • Gateways will receive and send LoRa Technology
  • Arduino compatible device.

3. Application Servers & Cloud IoT Services:

Applications interpret the data collected by LoRa devices. Not sending into Cloud Services initially. Will send APRS WX from external sensors once sorted.

The application server in this case will be a device salvaged from a dumpster running Linux hosting a MySQL database displaying the information via Apache (LAMP Stack).

Devices

The sensor nodes will be based on Arduino,ESP32 and ASR605x (ASR6501, ASR6502) controllers.

Use LoRa Ra-02 module SX1278 (433Mhz) modules where not incorporated.
Use Audrino IDE for sketch development and uploading
FirstSketch bb

NewImage

The LoRa gateway will be based on Heltec micro controller.

This device is supported by Arduino GUI and has onboard OLED, WFIF and LoRa. There is also battery management abilities.

  • WiFi LoRa 32 (V2) from Heltec Automation
    • Microcontroller  ESP32 @ 240MHz
    • WiFi                  WIFI802.11 b/g/n/e/i
    • LoRa chip         SX1278
    • Bluetooth          BLE
    • Flash                8MB
    • RAM                 320KB
    • Display             0.96 inch 128*64 OLED

Highlights;

  • Fully supported by Arduino IDE
  • Lithium: Battery socket for Heltec boards is SH1.25-2 (JST 2P-1.25 (JST connector with 2 pins, separated each other by 1.25mm)
  • Vext 3.3V(500mA) output, for external devices (e.g. sensors) power supply, in deep sleep mode, Vext can be shut down via software
  • $30AUD delivered

Anyway so off I went.

Ordered some BME280 sensors and a couple of the CubeCell dev boards. The intent is to deploy outside. This setup will be able to run off a 18650 3.7V 1200mAH lithium polymer Battery.

Started to program with the devices and sensors I have here. Had all-ready ordered a WiFi LoRa 32. The built in Display, WiFI and Lora interfaces  for $20 was too hard to pass.

This data is not going to any cloud IoT services. Ultimately will expand to exploit select IOT cloud services but intent is to keep it internal.

I’ve used JSON ‘encoding’ for data being sent. There are a lot of reasons not to use JSON. Im using JSON to support device IDs.

LoRaWAN provides headers that support device identification. Had a go at Cayenne Low Power Payload (Cayenne LPP) encoding. Worked as described in the tutorials. It is used as payload for the TTN so a lot of material around. For now I did not want the overhead of LoRaWAN just for device ID so using JSON for the payload and adding own device control. Yes JSON is fat. Same data is 21 bytes using Cayenne whilst JSON comes in at 65 bytes.

When it comes time to send to IoT services it will be straight forward to pass the JSON to Cayenne then to via LoRaWAN to said service.

The use of JSON is also consistent with conditions of the Amateur licence. Not encrypted, clear text. No privacy concerns with clear text out here. Remote private network broadcasting current conditions in clear text. Dare say of little interest to Mr Potato Head.

Typical Data Packet;

 data={“id”:2,”t”:21.6,”h”:71,”b”:1007.5,”d”:0,”gps”:[-37.691,144.009]}

Also the size of the JSON data in bytes for the JSON string and RSSI from the gateways point of view are sent.

Decided not to use the Heltac library, not because it was not enticing but wanted to ensure compatibility across wider devices so open libraries used. Used the LoRa library from Sandeep Mistry. The Heltec library is identical

HTTP GET to PHP script on Centos server. Not happy with using GET. Again based on the Heltec examples as it worked.

PHP used for the script on the LAMP server to store the data in a MYSQL database.  Based on existing routines and works well. No presentation layer. Just working routines for now.

So currently (8 Mar 2020) Two sensors are sending data.

Here are the contents of two tables;

NewImage

So the basic functionality is present however, the gateway hangs after a couple of hours use. Suspect I have a buffer over run. Currently checking code as suspect its my error. I have Mega 2650 Mini available so will order another couple of SX1278 boards and create a gateway to see if its a hardware issue

I’ll go into detail of each step and link pages here;

So, more to come but initial efforts demonstrate a sensor network using Arduino and LoRa is more that achievable.
 
Allen
 

Libraries

Of Interest;

Notes:

Arduino Sensors – Sender

Arduino Sensors – Test Sender

NewImage

IMG 3224

This is the code for the test devices based on Arduino UNO.

The Duemilanove has hard coded values while the UNO a sensor.

This is the code for 1 (Duemilanove with no sensors).  As the sensors come in will be adding to the sketch and simply un commenting the required calls for the target device.

The posted data log like this,

http://Jupiter/processIoT.php?data={“id”:2,”t”:24.3,”h”:59,”b”:1007.5,”d”:0,”gps”:[-37.691,144.009]}&rssi=-86&size=65

Again, I want the same code for the Arduino and the ESP based boards.  

 

#include "DHT.h"
#include <SPI.h>
#include <LoRa.h> 
#include <ArduinoJson.h>
 
#define DHTTYPE DHT11
const int DHTPin = 8;
DHT dht(DHTPin, DHTTYPE);
 
int counter = 0;
 
void setup() {
 
  Serial.begin(9600);
  Serial.println("LoRa JSON Sender");
  
  // DT11 Sensor
  pinMode(DHTPin, INPUT);
  dht.begin();
  
  //RA02 Module
  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }else{
    Serial.println("Starting LoRa Success!");
  }
}
 
void loop() {
 
  // Setup 
  StaticJsonDocument<128> doc;  
 
//  float h = dht.readHumidity();
//  float t = dht.readTemperature();
 
  float t = 21.5;
  float h = 75;
  float b = 1000;
  
  // ID. Match to DeviceInfo table
  // 1 = Duemilanove no sensors
  // 2 = UNO with DF11
  doc["id"] = 1;
 
  // Sensors or preset 
  doc["t"] = t;
  doc["h"] = h;
  doc["b"] = b;
  doc["d"] = -1; 
  
  JsonArray data = doc.createNestedArray("gps");
  data.add( -37.691);
  data.add(144.009);
 
  String output;
  serializeJson(doc, output);
  
  LoRa.beginPacket();  
  LoRa.print(output);
  LoRa.endPacket();
 
  if (1){  // Check what was sent
    // Decode JSON and print serial 
    serializeJsonPretty(doc, Serial);
    Serial.println();
  }
 
  delay(150000);
}

2019 UTC Rollover

31122019 – VK3/VN-001 Mt Torbreck

01012020 – VK3/VC-006 Mt St Leonard in VKFF-0556 In – Yarra Ranges National Park

01012020 – VK3/VC-038 Archer Lookout in VKFF-0556 In – Yarra Ranges National Park

In VK, ZL and JA we have UTC rollover late morning (11am EAST). This means double activator points can be claimed for activation as the UTC rollover is for a new year.

Chasers can always claim double points for activations spanning UTC rollover but this annual event is a bonus for activators. This year not all chasers were in a position to participate. VK1 activation were off the table given the conditions and sites being closed.VK2 had limited access for similar reasons. VK3 was fast becoming limited with the fires to the east.  Here id a view of VK3 three days later. As you can see the east of VK3 is now off the table.

FireOverview

This map clearly show an inadequacy in the current system. I’m not going into the current politics as this is not the place (but it is the time to discuss the implications of climate change and the f#*% T!#*# we have ‘leading’ us) but the map is of VK3

VK2FireMap

and this is the view of VK2. You have to go to two separate sites for a view. I don’t think the fires will respect the state boundaries, just saying.

Update – 032020- Bushfire.io integrates information from:

Anyway, talking with Andrew before Xmas we decided on Mt Torbreck. Its a good summit. On the edge of reasonable day trip and neither of us had activated this year. We watched the conditions and after committing to cancelling should conditions dictate to our wives, took off nice and early for UTC fun. We were well clear of the fires and also not in a position to hinder access or require assistance.

Watching the spots on the drive up and saw ZL up and working. They are a head of us and working locals as we could not hear from the car.

31122019 – VK3/VN-001 Mt Torbreck

We went down the Hume and cut across through Alexandra to turn down Eildon-Jamieson road. Arrived at Barnwell Plains on time and with excellent conditions.

IMG 3109

View from VK3/VN-001 east

Its a clean 2km walk up to the summit from the car park. We arrived comfortably and setup the end fed across the cairn. On air by 10:30 and started working the S2S pre UTC.

The smoke haze was two ridge lines away. Did not want to be any closer. Ended up with 24 contacts from ZL, VK7, VK5, VK4, VK3 and VK2. Again nothing from VK1 as they were they were dealing with smoke and fires.

21 S2S contacts across 11 unique sites. The day was proceeding as per plan except for my lunch as still in the fridge at home. After eating half of Andrews lunch knocking over a bag of snakes we packed to collect more summits on the way home.

Typically in when in the area I would pickup VK3/VN-005,VK3/VN-002 and possibly VK3/VN-004 but that was not the plan as they are off Snobs creek road we came in down  Eildon-Jamieson road. Will come back during the year for these three but come down Snobs Creek road.

From here we were targeting Archer Lookout and Mt St Leonard as intended to head home via Healesville. The ‘plan’ was to turn into Monda Road (opposite Dom Dom Road) from the Maroondah Highway. This was not a good plan was we hit a locked gate 200M from highway. So instead decided to reverse the plan and come in St Leonards and again follow Monda Road to Archer Lookout.

01012020 – VK3/VC-006 Mt St Leonard in VKFF-0556 In – Yarra Ranges National Park

This summit has a reputation for RF noise and also attracting crowds. We decided to go for a HT VHF based activation of the summit. We could hear VK3ZPF on the drive up so made contact once in the carpark and so he would wait for a S2S. Still took HF station but the goal was a HT based quick operation. Once qualified (VHF S2S with VK3ZPF then 5 contacts from a UHF net) trekked back does the k or so to the car and headed up Monda Road to Archer Lookout. This is a AWD track. Its a great track for Subie given the tyres and suspension but I would not call it a 2WD track only due to the use of large course rocks for the road and a handful of ruts. 2WD in summer but you will need to consider the conditions as you may need to get out in a hurry.

IMG 3113

VK3ARR with 2M Jpole on VK3/VC-038

01012020 – VK3/VC-038 Archer Lookout in VKFF-0556 In – Yarra Ranges National Park

This is a new summit as added to VK3 November this year. It took an hour to get down and on site then was surprising hard work to qualify.

It was late. Well not that late but consider we all up early for UTC activations not surprised as to the quite bands. Andrew setup up 2M to secure a S2S with VKJ3ANL on VK3/VC-018 and we then turned to 20M to secure 3 more contacts with ZL, VK4 and VK5.

Once qualified we packed up and headed out as still had a couple of hours drive to be home late for tea.

A good day. Ended up with 4 summits qualified with for 24 S2S (13 unique).

IMG 3115

HF antenna on Archer Lookout.

31122019 – VK3/VC-019

VK3/VC-019 – Mt Warrenheip

VKFF-2402 In – Mount Warrenheip Flora Reserve

Quick activation to pickup Mt Warrenheip before the years end and to catch Peter VK3PF for a S2S.

Setup with my back to the compound facing east with antenna ran out along the ridge. The undergrowth was a lot cleaner this year. The site was burnt out 2 years ago so good to see the grasses coming back ahead of the weeds that plagued the site. 

It was a SOTA activation but the site qualifies for VKFF (VKFF-2402) so will submit the log.

IMG 3108

 Photos of Mt Warrenheip and Mt Buninyong from Navigators Road the day before. I was going to go out but given the temp and wind decided it could wait another day.

We have low haze from the fires at Mount Mercer. No risk just a reminder of the conditions and to keep a eye out.

Charging batteries and packing for NYE activation tomorrow at Mt Torbreck with VK3ARR.

IMG 3083

VK3/VC-019 – Mt Warrenheip

IMG 3085

VK3/VC-018 – Mt Buninyong

28122019 – VK3/VC-039

VK3/VC-039 – Mount Gisborne

Mount Gisborne is a new addition to VK3. Its close to home being an hour drive so I decided to get it this year.

Had a window to get out. Intention was to be out, qualify and get back in time to see daughter off and before the heat rolls in. 

IMG 3105

Park at the second gate n the left along Woodland drive which is gated access to Mt Gisborne Nature Reserve. There is no parking just the side of the road.

Follow the track up. It a 10 min walk to the summit which is a great clearing. Yes space for a 160m antenna and a helicopter.

IMG 3103

First contact was with ZL1SKL and VK2GP onZL1/WK-158 using 20m SSB. It was a 52 transaction but no issues with the contact as quiet band. 40m was rocking. Easy 599 CW contact with VK3PF then VK3ANL,VK7EE and VK3BYD to finish off with a 2m contact with VK3YE. Called it a day and headed back as still running to a tight schedule. 

Straight forward summit. Parking could be an issue but access is easy so carrying a heap of gear is not an issue.

Will be added to the list to activated each year as close and clear. 

26122019 – VK3/VS-054

VK3/VS-054 – Mount Noorat

IMG 0977

New summit. Well an dormant volcano (5,000 and 20,000 years ago) that was added to the VK3 list during recent review. Situated near my inlaws so decided to pick up on boxing day.

Access is from Morack St off Glenormistomn Rd Mt Noorat. Good but very busy path. There is a 4G tower on the site so took the iPad to spot and log. Open summit so take cover if heading in the full heat.

There are convent posts on the summit for setup. Setup the end fed antenna and pickup a S2S with Geoff ZL3GA on ZL3/CB-55. Continued to work 40m CW to qualified the summit when around 2 dozen walkers reached the summit and my antenna.

I had my antenna high and clear but then then they decided to to talk to me which lead to slight confusion with my final contact (Geoff VK3SQ).  

Comfortably qualified and given the traffic on the summit and as there will be eggs and bacon for breakfast if I get back on time, decided to pull up stumps and head home.

Took the long way home to circumnavigate the crater. Views back to the Grampians were affected by the smoke in the air.

IMG 3086

First summit I have seen where the contour lines have been marked.

Great site. Add to your list if out in Western Victoria easy clear access to summit.

08122019 – VK3/VN-029

VK3/VN-029 (Federation Range)

WWFF Yarra Ranges National Park (VKFF-0556) 

With VK3ARR.

IMG 3067

Rare photo of Andrew activating in VK.

We walked in the ‘WILD HORSES Festival’. Was not expected or a issue but did create a problem as access to the Lake Mountain site was restricted so we had to park 2kms down the road. The additional 2kms was on the road ,in the heat it was all up hill. Fornatually we didn’t have to walk as jumped on the hippy buss and was dropped off on the site. That was an experience in itself.

The walk to Federation Range is straight forward as long as you start on the correct track (Royston Trail) Its a clear walk with consistent climb following the ski tracks through the old site and Andrew didn’t get too far ahead of me. Got on site and setup in time to secure S2S with VK3BYD and VK3PF. Comfortably qualified on CW leaving the SSB contacts to Andrew. The end fed worked a treat. I had performed some much needed maintaince as the end connector was fraying (using Araldite to enclose it) and adding addition wire as had to cut down after a serious tangle incident on Mt William. Added a length of yellow wire to the end to also increase visibility. 

IMG 3068

With 40m of wire and the 49:1 matcher the tuner in the KX gives all band support. Setup high and clear 40m returned 1:1 swr without requiring tuning.  

We walked back to the carpark and kept going not waiting for the bus as down hill and had allready decided to drop the proposed second summit. Had to walk on the edge so as to avoid walking in the blistering road tar.

Good day in great conditions. Happy to grab this summit before the heat settles in as is not a spot you would want to be in should there be fires.