Cakes & Desserts & Liqueurs

Various projects at Royal HaskoningDHV

Projects

Old code

Various games / projects at Deltares

Older games

Augmented Reality / Graphics

DIY Sensor networks at home using MySensors

Wireless sensors throughout the house and outside

For many years I have tried to get some sort of wireless sensors network to work in- and outside the house. However the solutions was always rather cumbersome and not reliable. Especially the typical 433 mhz modules (cheap, and easy to find on AliExpress/EBay) were common in use. The modules did not provide any means of "debugging" either: It really was a case of just sending data and hopefully it would arrive on the receiver side. In some countries 315 mhz is used instead of 433 mhz.

Although 433 mhz modules can still be quite handy (when you would like to interface with wireless weather stations or doorbells) there are quite some better approaches to wireless data transmission now, such as the Nordic nRF24L01 modules. These can also be easily found on AliExpress of EBay for rather cheap prices. They might, however, be not the official one from Nordic Semiconductor.

Combining these nRF24L01 modules with a simple Arduino (any variation) opens up a world of reliable communication. When I discovered the libraries of MySensors.org my enthousiasm grew even more. MySensors allows you to quickly set-up a (mesh) network of connected sensors that communicate with a gateway. A gateway is a device which is always on and available. This could be a Raspberry Pi, another Arduino device or, as in my case, an ESP8266. Why I like the ESP8266 is that it allows practically the same code (and therefore effort) as programming an Arduino, using the same Nordic module and having WiFi support to transmit data to an online script (such as PHP) and share information directly on a MQTT protocol. In my case, also SD card backup has been added if there would be any communication failures on the WiFi.

Hardware

Various stages of my sensor nodes

The sensor nodes consist of the following parts, which can easily be purchased on AliExpress:

As you can see the nodes are fairly basic. The instructions for building these nodes are practically the same as on the MySensors website. It is recommended to get a couple of Arduino Pro Mini's in one order. Sometimes you can suddenly end-up with a different model, which for example has some pins switched. Different Arduino Pro Mini modules and pins

The gateway is build using:

  • An ESP8266 board and development board if you prefer.
  • nRF24L01 module, I would recommend with antenna
  • SD card module (optional). See below how to connect it to the ESP8266
  • Standard USB power supply/charger with micro USB cable
Note that this device should be running permanently, so thats why some kind of simple (USB) power supply is required. The gateway receives all data and handles as you tell it to.

The network

Currently the MySensors network at my house consists of nodes which are located at various locations in- and outside the house: Living room, bed room, fridge, outside and the basement.

The currently used sensor modules can again, be bought quite cheaply at AliExpress. Connecting the sensors mostly consists of finding the right library and connecting two to three wires. For instructions for many sensors you can take a look at the MySensors page.

  • Barometric / Temperature / Humidity: BMP280E
  • Temperature only: DHT11 or DHT22
  • Plant soil moisture sensor: these kind, but only the "fork" is used.
  • Water pump: Peristaltic pump for 3v. See more instructions below how this was connected.
  • Gas and electricity consumption through the P1 port of the smart meter (Landis Gyr)
Sensor in a Philadelphia cream cheese box.

I am currently working on another plant sensor + pump combination. The air quality sensor needs quite some warm up time, and not sure about it's reliability.

Data storage

On SD card (see issue) and MQTT (live updates) and database through remote PHP script.

Website

A simple website requests the most recent data from the database (using PHP) and displays it. The website is build using BootStrap4 and ChartJS. As it is only for the occasionaly monitoring, it does not need to be much more right now. Sensor page One barometer has a different opinion out of the three. Sensor page Battery levels over time. Fluctuate a bit with temperature. Sensor page Soil moisture and indication when pump was turned on for 20 seconds (red line). Sensor page Temperature sensors.

MQTT

All data that is sent to the gateway is also forwarded to a remote MQTT server. One could connect to this to pick up the live feed. MQTT stream

SD-card

And an SD-card module is used at the gateway as extra backup. The receive() function of the MySensors gateway is overloaded to perform this action. Please note that the SD-Card module needs a modification to work properly with multiple devices. You will have to solder an extra wire between these two locations. The pin at the right of the IC needs to be lifted and then connected to the first pin at the left side of the IC. Otherwise, you cannot use two devices on one Arduino. It took a while to find a forum that mentions this issue... Unfortunately cannot find the original source for this. SD Card reader fix.

Low power modifications

In order to run the Arduino Pro Mini 3.3v for a very long time on just 2AA battery's, you will have to remove some components. This is a permanent change to your devices.

You will have to remove the power regulator and the power LED from the device. This will greatly reduce power consumption. Note that from that point on you will have to use the Arduino Pro Mini from batttery power. When connecting USB wires, do not connect the VCC anymore! The ground should still be connected however. Right now I do not have a specific photo of the modifications yet, but you can find clear instructions on Andreas Rohner's websiteHow to modify an Arduino Pro Mini (clone) for low power consumption.

Various photos of some nodes

Original testing nodes Some early prototyping on small breadboards. Finished node A completely functional node. Pump prototype Prototyping the pumping system. Preparing parts Preparing all the parts to build a couple in one go.

Some source code

Still have to clean this up a little bit, but should be online soon!

Fritzing examples

Here are a couple of my designs that I use. These are very likely correct, but please double check. It is always possible that a wire got moved by accident. The pump and MOSFET display how to power the pump using another independent battery source from the Arduino Pro Mini 3.3v. My default battery node Gateway node with P1 support Connecting Arduino and a pump to water plants How to connect an SD-Card module to the ESP8266.

Inspiring reads to get you started

Some articles that I thought were good a good read to learn more about MySensors, low power Arduino's, etc.