Sunday, August 18, 2019

Remote gardener - project overview

The purpose of this project is to remotely control a water pump anywhere in the world. My personal motivation to build this solution is to be able to water my tomato plants during a long vacation to the other side of the globe, Australia!

Requirements:

  • turn the pump on and off during an arbitrary interval
  • get interactive feedback from the pumping, both visual and "state"
  • get alert then the soil is too dry (i.e. when I need to pump)
  • secure the solution
  • recover power shortage and network connectivity loss
  • operate solution from any connected device
Solution:

Turn on/off

In order to control the water pump remotely, one just need to control a relay in order to switch the current on and off. To do this remotely we need a connected device that is wired up with the relay and the perfect candidate to do this was for me the Arduino chip "mxchip az3166". This chip is promoted by Microsoft and very well integrated into the azure architecture thanks to a visual code plug-in.


Once the chip got connection to azure IoT hub a blue led will turn on!
The chip also got a small display that is very useful for debugging.
And it is compatible with BBC micro bit accessories!
All in all the perfect choice for an IoT solution hosted on the Azure platform.

To send commands to the pump I simply used a web application hosted as an Azure app service.

Visual feedback

To get visual feedback from pumping I just choose to install a web cam pointing at the water outlet and the tomato plants:


The pump state is also displayed in a web application hosted as an Azure app service. More about that later.

Moisture alert

There're a lot of fun accessories that one can connect to the "mxchip". One of these is a moisture sensor:


I'll use this sensor to regularly check the moisture level in the soil and if the moisture level is too low I'll send an alert to a "Remote gardener" twitter account.

Security

To secure the solution I'm relying on azure active directory. Both the web portal and the azure functions need to be secured. 
Communication between azure IoT hub and the physical device is done using standard Microsoft libraries with an access key.

Recovery

If we lose power the IoT device will just reboot then the power comes back.
But if we lose network connectivity (for instance our router temporarily goes down or lose internet connection) we need to implement a recovery mechanism that on a regular interval tries to reconnect to the router. This has to be implemented in the IoT code.

Operate

We will just build a simple website to send commands to the IoT device and to monitor it's state.

Construction

The video below show the overall construction of the system:

  • Tubes
  • Pump
  • MXChip and electronics


Result

The solution was fun to build and has worked flawlessly during summer 2019.
The video below shows some pumping from Singapore Airport :)