Archive | IoT RSS for this section

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

Opportunistic Hardware Acquisition

or dumpster diving for computers.

I’ve noticed a trend. At the end of university terms the skip bins around student accommodation fill up with fridges, lounges and computers.

I’m putting this down to the the high cost for freight and low cost of technology.

Its not like I don’t have enough computers. In the shed there is an Apple IIe Clone, varies 8080 -> Pentium based devices (IBM XT & AT339)  and collection of RISC (ultra 2, SS2,10 & 20, HP and a dual CPU DEC Alpha) devices.

They all worked before being put away. Doubt they would boot up without addressing NVRAM issues and the odd wasp nest but they are going nowhere. Well that’s debatable as whilst the cases and boards may stay in my shed their souls will be reward in Silicon Heaven.

I use a Apple Mac for my desktop (the 27’ 5K iMac screen soothes old eyes) and for my personal notebook. There is a Dell notebook with Windows XP and a serial port for programming radios and everything else runs Linux. 

I rarely purchase new. The Macs come from Apple refurbished site and if I need components, eBay is the first port of call. Anyway I have recently acquired two computers by not being too ashamed to jump into a skip bin.

NewImage

i5 Workstation

MSI 7688v1.0(G52-76881X1)(P55A Fuzion). i5 CPU 760  @ 2.80GHz with 8GB memory.

Walking home down Collins St noticed a skip bin with the results of an office refurb. Hidden between the discarded partitions and lighting there were several computers cases, LCD screens and a printer. Seriously ? computers are considered office waste now ? Ok going in….

I was not alone and had to act fast. These computers had attracted the attention of another ‘recycler’ and we worked together. He took two boxes and a screen whilst I only grabbed a single box, did retrieved memory from one of the other boxes and just made it to the train heading home.

Knew it was a intel based device due to the sticker on the fan and assuming later then a Pentium based device as no ‘Intel inside stickers’. It was a long ride home wondering if I was bringing someone else’s rubbish home or had hit silicon jackpot. Michele is very tolerant but we don’t need another ancient device in the shed. Got home and ran it up to setup as no HDD. The case was low end and missing feet but did have a power supply. Also has a NVIDIA GT216 PCI-E video. The mother board supports Multi-GPU Computing. Ok that sounds cool so lets get another card tomorrow. Went back to the skip bin on the way to work on the next day armed with screwdrivers and pliers to retrieve more memory and a second video card but there was only had plaster and cables left. Too late.

Sourced a tower case and HDD. Installed Linux Fedora 29 and configured as a LAMP box so now it is hosting test instance of the ParksnPeaks website. This use to be hosted on the HP8100 but ran out of space and unable to add another drive.

NewImage

The HP 8100 was sourced second hand from eBay. It has a 2TB drive and runs Ubuntu 16.04.5 LTS hosting AppleTalk as it is the backup target for our Macs. The idea here is to pick it up one computer when leaving for fires so whilst you may loose hardware, will have data.

Dual Xeon Server

Intel® S5500BC Server. Dual Xeon(R) CPU E5506  @ 2.13GHz with 16GB memory.

Walking back from lunch recently I noticed a tower sitting next to a skip bin. It had empty slots where HDD carriers had been removed. You could see two heatsinks. This device caught my interest but I had to leave it as the case was too big to take back to work. I was receiving enough ribbing from by lunch buddies all-ready so stashed the case behind the bin to and took the ribbing whilst walking back to office. 

So once back at the office and out of sight of my ‘friends’  I grabbed a Phillips head and went back to see what was under the heat sinks.  Took off the heatsink and rubbed back the compound to find an Intel Xeon processor. Half the memory banks were filled. There where no hard disks nor a power supply so decided to take the board leaving the case in the bin.

NewImage

Got a case out of the shed and ran her up. She booted to setup no issues. I took a photo and sent to those who doubted it just to prove I’m not just a nutter, but a nutter with a dual Xeon server. Added a HDD and installed CentOS Linux. Setup up a search for ECC memory and picked up additional 16G from the US for $77 delivered. Now all the memory slots are filled, just need a decent case. The device is a SSI CEB form factor – 305 X 276mm slightly larger than a ATX 305 X 244 mm so a slight challenge as don’t want to buy (or pay for) a server case. Here she is running. Notice doing nothing.

JupiterLoad

NewImage

So what am I going to do with them ?

None of the devices are doing any real work. Need a box for testing and backup.

The inner accountant says should do nothing and keep using the HP8100 as backup and dev box. It requires no new hardware and uses the least energy.

The inner geek says not to listen to that idiot. If he had his way you would have been eating lunch at your desk not enjoying luksa and there would be a dual xeon server in land fill now.  

So have got my eye on a case for the Xeon. Will add a couple of drives for backup target and use it as the dev / test box going forward.

Want to add some devices outside for sensors and to automate garden activities. Glenn VK3YY raised the opportunities LoRaWAN present so intend to work out how to build a mesh of small devices reporting to the server using 70cm band. Will need a device to host a database and process all the data that will be generated and this would be a honourable task for such a device.

IoT

Internet of things
noun
 
  1. the interconnection via the Internet of computing devices embedded in everyday objects, enabling them to send and receive data.

Intend to build a home sensor network based on Arduino and Raspberry devices hosting environmental sensors and home voice activated automation system. Guess this is the Intranet of Things – IoT

Late to the story but can see where this is going. Can remember early days where we were being trained in digital electronics and the wait to access microcontrollers. You can now purchase for next to nothing multi core devices and the tools to develop and interface are amazing. 

Picked up a couple of Arduino’s and a Raspberry PI to play with. A kit of sensors off eBay was sourced so as to get a spread of what we can monitor. Its just a case of integrating the pieces.

AllNet OverviewCurrent overview as at 102017.

Like all IT deployment security and scaleability have to be the predominate design factors;

“if one thing can prevent the Internet of things from transforming the way we live and work, it will be a breakdown in security”

Current design is simple and will not be connected to the Internet. Voice control will be will Jasper on Raspberry Pi. Pocketsphinx as the STT (Speech To Text) engine so recognition will be performed offline. Not just to keep my data off the Internet but to conserve the rural connection. 

Features;

  • Multiple Andriod based sensors
  • RF based sensor network
  • Raspberry Pi hosting Jasper automation
  • Linux based presentation layer
  • Remote control of external (chicken door) instances
  • …..