Lora Sensors – Hardware

 What have I been doing during the coronavirus lockdown, well playing with microcontrollers,

WeatherProto

This is a continuation of the experiments with Lora devices and have concentrated on developing nodes for measuring basic conditions inside and extended conditions outside. I have ended up with;

  • ASR6501 based internal devices X 2
  • ESP32 based external Weather station
  • ESP32 based Lora gateway
  • Raspberry Pi 3 Model B Database server
I’m using JSON to encode the data and keeping all results internal. No data is going out into the web. 
I’ll deal with the software in next post so let’s go over the hardware that I have ended up with. 
 

Devices

Started with AVR based devices but moved to the ESP32 due to the extra inputs and integrated LiPo management. Don’t worry, the Adurino board is awaiting an RF Shield from QRPLabs and that will a story for another day.

Internal Nodes

The internal nodes are HTCC-AB01CubeCell Dev-Boards

InternalSensor

 

Features,

  • BME280 Sensor
  • LiPo support
  • LoRa sx1268 

Straight forward operation. Take a BME280 sensor, wrap some sleep code around the reading of the sensor and send on wake. Here is a naked device in the wild;

InternalSensor

The weather station is a low end unit. Im happy to report the devices report temps within stated tolerances to this unit. Yes could be both wrong but at least they are consistent. The battery is a 1100mAh single cell lipo recovered from the recycling bin when we use to go to the office to work. Carefully soldered some leads and away it went. Awaiting new ones with protection circuitry. The node charged it up whilst connected to USB and it has been running for over a week on the end of my desk. Need a case, yes. Who has a 3D printer ?

ESP32 based external Weather station

The external weather station is based on ESP32. Initial testing and code was developed with a DFRobot ESP32 FireBeetle. Final design is using a SparkFun ESP32 Thing

The first picture shows functioning breadboard instance. Below is the schematic;

WeatherStation 001Currently the design supports;

  • BME280 via I2C
  • LoRa SX1278 via SPI
  • DS-15901 Weather Station,
    • wind vane (analogue Input)
    • anemometer (Digital Interrupt)
    • rain gauge (Digital Interrupt)
  • 780X Regulator for external power 
  • Testing supported a SSD1306 OLED via I2C
I have operational software with interrupt driven weather sensors and a BME280 providing humidity, barometric pressure and ambient temperature.
 
Yes, could have purchased a weather shield cheaper that designing my own but then would have missed out on playing with KiCAD and rekindling an interest in basic electronics. There was a bare board available but now it appears only an Arduino version or populated ESP32 version is available. So after reading the schematics for the discounted ESP weatherboard I added additional pins to give flexibility and completed the second input So it has pull up resistors, capacitors for filtering and diodes to protect the inputs. There is a second I2C interface (used by OLED during testing) as well as 8 inputs in 2 banks of 4 inputs with power. Also added support for a 780X voltage regulator to allow 12v connection. I have an old solar cell (BP1259) that is seperate to all other power currently trickle charging a backup battery for my radio. The weather station may end up close enough to tap into 12V so need to drop the voltage to a level the ESP onboard LiPo charger can handle.  
 
Don’t want to use veraboard so used KiCAD and PCBNew to design a PCB. Ordered from OSHPark and still waiting its arrival. The OSHPark PCB process will result in three boards so expect to use the RJ11 interface for varies input devices in other deployments.
 
Currently rewriting the code to use a BME680 thus giving me humidity, barometric pressure, ambient temperature and gas (VOC) levels . Also adding a AS3935 Lightning sensor (via SPI) and will exploited the low power abilities of the ESP32 with deep sleep. Initial code on a ESP-WROOM-32 based device (FireBeetle) board is promising. There are issues with using pins 32-39 to trigger wake up from deep sleep. It will wake but you can’t determine which int its was (returns inf) whilst you can determine who called for the lower pins. Will be using GPIO 15 for the lightening detector and adding a DS3231 RTC module to get around the loss of time between sleeps.
 
It’s still sitting inside until I receive the PCB.

ESP32 based Lora Gateway

Gateway

The gateway between LoRa and IP is a running on a Heltec WiFi LoRa 32 (ESP32 with OLED and SX1278) It is a single channel Lora Gateway. 
The current code is solid. Initially saw issues with reboots and hangs. Followed advice from Jack Purdum book ‘Beginning C for Arduino’ and converted all strings to chars so now seeing no issues. 
 
As it stands, it picks up the LoRa packet, decodes the JSON and sends via HTTP (POST) to the database server. The device is connected to a USB hud and sits on under the table. Works a treat. 

Raspberry Pi 3 Model B Database server

Initially setup the Centos box to host Apache, PHP (7.2) and MariaDB to act as the data store. The device was hosting a REST API that the gateway calls. It takes the JSON, converts into SQL adding to database.
Apache also hosts simple web form the displays the data.
The device was doing nothing except heating up the room so ran up a Raspberry with Ubuntu to act as the database server, moved the api code across and again its doing nothing;
 
DolosLoad
 
This is a single file REST API written in PHP so may not be perfect but functional and currently supporting;

  • HTTP verbs GET, POST, PUT
  • Escapes all data properly to avoid invalid entries 
  • Handles null values to again avoid invalid entries
  • Supports debug and return error states.
The Pi lives in the cupboard connected to the wireless router via ethernet. 
Had to include code to catch invalid data as despite being out in the country see occasional unknown packets. The RSSI indicate a distance away so suspect car remote or garage door.
I will share all code, postman testing calls and device sketches. That will be described in the next post – Lora Software. The code will be released under the ‘Don’t laugh your guts out’ licence.

Deep Sleep

The ESP32 device support deep sleep. This is straight forward in the case of the internal nodes. You setup a wakeup timer then sleep. On wake collect sensor data then send for processing and back to sleep. Bit like work….

Measured;

  • ASR6501 – 90mA awake and 20uA sleep.
  • ESP Thing – 110mA awake and 34uA sleep.

However sleep has been providing challenges for the interrupt driven external node. Currently testing new code with the FireBeetle that supports times sleep and wake on interrupt;

  • observed 10 to 30μA with meter running deep sleep 
  • calculated (100K resistor in series) 34μA during sleep.
  • observed 120mA whilst running the BLE iBeacon example
  • observed 110mA whilst running WIFI scanner example
I dont believe these are absolute numbers as using a cheap meter but it does demonstrate the ease that micro usage can be achieved.
I would also like to add a voltage divider to measure and report the voltage levels.

Learnings

What have I learnt,

  • Don’t use the YURobot power supply. If you do check the 5v line as the 5V regulator failed and presented the input voltage (9v in this case) unfiltered. Dare say 5V would have killed the device but 9v did a corker of a job, all the smoke escaped. This accounted for one TTG. This was not a pointless venture as brought joy to my son who was present.
BME280Sensors
  • Don’t buy the cheap BME280 clone sensors. The Bosh BME280 sensors are square whilst the clones are rectangles. The clones provided temperature pressure but not humidity. They should be described as ‘BMP280’.  I tried varies libraries trying to work out why I could not read humidity. Google revealed they were clones. 
  • A analogueread() call invalidates digitalread()s unless you reinitialise the GPIO. Minor but kept me busy with the CRO trying to work put why I could not read the input.
  • Confused the devices several times with crap code (technical term describing too many serial prints!) requiring manual intervention to re-program.

Conclusion

So the hardware is straight forward. The devices are cheap enough to kill a few whilst playing. Order a couple. Google will help address issues you may see. 

This was a great way to spend weekends when you can’t get out to play radio and avoiding the list of things you should be doing. Now the challenge is to process the data.

Next Lora Software …..

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: