Arduino Smart Watering Kit with Azure IoT Central

I came across this Smart Watering Kit by Elecrow. It was really great, but one thing missing is internet conectivity. We all know that we can’t grow plants without the “I” in IoT! So let’s see what we can do about that!

Electrow Ardunio Smart Plant Watering Kit
Inside the box

The kit comes with everything you need to water four different plants automatically.

The box contains

  • Arduino Leonardo
  • Power Supply
  • Pump
  • 4 Capacitive Moisture Sensors
  • 4 Way valves
  • Pipes

The kit is very comprensive and includes and LCD display which can show at a glance the conditions of your plants.

The board
Serial Port

The board unfortunately does not have built in wifi connectivity. But what it does have is a serial port. That’s perfect, so what we could do is use that to send telemetry out to another device that is internet / wifi enabled.

A good device for that is a good old (and cheap) 8266 board. I had a NodeMCU in my box of tricks, so I decided to use that.

Parts List

  • Arduino Smart Watering Board (Arduino Leonardo)
  • NodeMCU board
  • 2.2 K ohm resistor
  • 1 K ohm Resistor
  • 470 ohm Resistor
  • Breadboard
  • Wires
  • Power Supply

Connecting an Arduino Leonardo to a Node MCU via Serial Port

First step is to make it work on a breadboard.

Parts List

  • Arduino Smart Watering Board (Arduino Leonardo)
  • NodeMCU board
  • 2.2 K ohm resistor
  • 1 K ohm Resistor
  • 470 ohm Resistor
  • Veroboard
  • Wires
  • Power Supply
Connecting an Arduino Leonardo to a Node MCU via Serial Port

Once working, the next step is to build that onto a more permanent solution. I decided to use just veroboard as it was quick and easy.

Two boards up and running

IoT Central

Device Templates

Device Capabilities

Create device capabilities for the moisture sensors as telemetry (Moisture1, Moisture2, Moisture3, Moisture4). [Device Definition json file is in the github repository along with the source code]

Create properties for the 4 relay states for each of the 4 valves. [Device Definition json file is in the github repository along with the source code]

Create a property for the pump state. [Device Definition json file is in the github repository along with the source code]

Publish the template and create an instance of the template as a device.

Instance of a device template

Note the “connection” information for the new device instance.

Device “Connection” information

Take note of the following:

  • Scope ID
  • Device ID
  • Primary Key
iotcserialrelay.ino

Update the iotcserialrelay.ino file with the:

  • WIFI_SSID – The wifi hotspot ssid
  • WIFI_PASSWORD – The wifi hotspot password
  • SCOPE_ID – The Device Instance’s Scope Id
  • DEVICE_ID – The Device Instance’s Device Id
  • DEVICE_KEY 0 The Device Instance’s Key

Deploy iotcserialrelay.ino to NodeMCU.

Deploy watering_kit.ino to the Arduio Smart Watering Board.

Telemetry in IoT Central

Once deployed and connection is made, telemetry starts appearing within IoT Central’s dashboard.

Finished Product with happy plants powered by Microsoft Azure 😎😎

Source code: https://github.com/apead/SmartWateringKit

Product Information: https://www.elecrow.com/arduino-automatic-smart-plant-watering-kit.html

Where to buy? https://www.robotics.org.za/AAK90039K

Cross Platform Iot at CTXUG

Last night was the Cross Platform Iot Session at CTXUG in Cape Town.    The turnout was absolutely amazing!    Thank you to all for coming it was a really fun evening!

 

Roger Weiss from Aliens kicked off with an overview of Windows 10 Iot Core and a few demos.  These demos featured some awesome use of Microsoft Cognitive services and also some nifty voice controlled home automation.

 

It was then my turn.   Unfortunately Chris van Wyk couldn’t make it this evening.  🙁

 

The session featured

 

Visual Micro for Visual Studio

Visual Studio Code with Arduino Extension which is now Open Source.

Xamarin Forms and Xamarin.Android with Android Things 0.41 Preview

The new Xamarin Iot preview for Linux based devices

Azure Iot Hubs

 

Devices wise 

 

Raspberry Pi 3

Intel Edison

Raspberry Pi Zero W

Latte Panda and Arduino Leonardo

MXChip Azure Kit

Devices everywhere! Latte Panda, Pi With Android Things. NexDock

 

The awesome new MXCHIP Azure Iot kit (Arduino)

 

The presentation can be found here:  https://github.com/apead/XUGSA/tree/master/19072017

Android Things Weather Station Sample with Azure Iot Hubs:    https://github.com/apead/Xamarin-AndroidThings-Contrib

Cross Platform Generic Xamarin Forms sample that ran on Phone, Android Things and Windows 10 Iot (I didn’t demo this, but it works too):   https://github.com/apead/XUGSABuildAutomation

 

Xamarin Android Things Nuget:  https://www.nuget.org/packages/Xamarin.Android.Things/0.4.0-devpreview

 

Xamarin Android Things Contrib Drivers:  https://www.nuget.org/packages/Xamarin.AndroidThings.Contrib.RainbowHat/0.40.0-beta

 

Getting Started with Xamarin Iot:   http://explorationspace.co.za/2017/06/21/xamarin-iot-comes-to-visual-studio-2017-on-windows/

 

MXChip Azure Kit:   https://microsoft.github.io/azure-iot-developer-kit/

 

Android Things Starter Kit with Rainbow Hat:   https://shop.pimoroni.com/products/rainbow-hat-for-android-things

 

Rainbow HAT

 

There’s a Xamagon!

 

Interesting VR Stuff happening in Aliens office

Cross Platform Iot at GXUGSA

Last night was the Cross Iot Session at GXUGSA in Johannesburg.    It’s always fun presenting all the Iot toys, but also what can actually be done with Xamarin and the rest of the Microsoft tooling.

 

It’s also not always clear that you can basically do anything you want with Xamarin, so always nice and exciting to showcase it outside the usual phone type scenarios.

 

 

Gert Talking Windows 10 Iot Core

 

 

The session featured

 

Visual Micro for Visual Studio

Visual Studio Code with Arduino Extension which is now Open Source.

Xamarin Forms and Xamarin.Android with Android Things 0.4 Preview

The new Xamarin Iot preview for Linux based devices

Windows 10 Iot Core

Azure Iot Hubs

 

Devices wise 

 

Raspberry Pi 2 + 3

Intel Edison

Raspberry Pi Zero W

Latte Panda and Arduino Leonardo

MXChip Azure Kit

Devices Devices Everywhere

The presentation can be found here:   https://github.com/apead/XUGSA/tree/master/11072017

 

Android Things Weather Station Sample with Azure Iot Hubs:    https://github.com/apead/Xamarin-AndroidThings-Contrib

Cross Platform Generic Xamarin Forms sample that ran on Phone, Android Things and Windows 10 Iot:   https://github.com/apead/XUGSABuildAutomation

 

Xamarin Android Things Nuget:  https://www.nuget.org/packages/Xamarin.Android.Things/0.4.0-devpreview

 

Xamarin Android Things Contrib Drivers:  https://www.nuget.org/packages/Xamarin.AndroidThings.Contrib.RainbowHat/0.40.0-beta

 

Getting Started with Xamarin Iot:   http://explorationspace.co.za/2017/06/21/xamarin-iot-comes-to-visual-studio-2017-on-windows/

 

MXChip Azure Kit:   https://microsoft.github.io/azure-iot-developer-kit/

 

Android Things Starter Kit with Rainbow Hat:   https://shop.pimoroni.com/products/rainbow-hat-for-android-things

 

Rainbow HAT

 

Behind the Scenes Fun 🙂

Arduino Development with Visual Studio via Visual Micro (Overview)

Visual Studio has become a one stop shop for any type of development.  But did you know you can do Arduino development as well?    There is a Visual Studio extension called Visual Micro (http://www.visualmicro.com) which will allow Arduino development and debugging within Visual Studio IDE, with the full development experience you have become used to.   This is a high level overview of what is provided.

 

Arduino and Visual Studio

 

What’s really great about having Arduino support within Visual Studio is, you can group together all the various different projects that makes up your solution all together within a Visual Studio Solution.

 

Multi-platform Solution

 

In a world of Iot and cross platform (or multi platform) development this is perfect.   You could have one or more Arduino projects, .NET Micro framework projects,  a Xamarin Mobile client and the back-end (be it an on-premise ASP .NET WEB API solution, or in the cloud with something like Azure Mobile Services) all managed together in a single Visual Studio solution.

 

Installing Visual Micro

 

Visual Micro can be downloaded here:   http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx   It is a Visual Studio extension which will be installed within Visual Studio.   There is a version for both Visual Studio 2015 and 2017 RC.     Be sure to have the standard Arduino IDE installed as well, as it uses this tooling under the hood.   Arduino version 1.06 – 1.8 is supported.

 

The IDE Experience

 

Visual Micro Toolbar

 

 

Visual Micro Menu

 

Both a toolbar and a new menu is added to Visual Studio.    The toolbar allows access to quickly configure the connected board and COM port used (via USB).    It also allows quick access for building and debugging, however if the Arduino project is the startup project the debugging and build options work as usual direct from the Visual Studio hotkeys, toolbars and menu items.    The menu allows for deeper configuration of the compiler, debugging options and other integration options.

 

File New Dialog

Templates are provided to easily create a new Arduino Sketch or Library.    Standard Arduino INO files are supported.   These standard file types are also used when opening and saving to existing Arduino Sketch files, which ofcourse can be ported back to the Arduino IDE if need be.

 

Solution Explorer

 

The solution explorer is quite neat for the Arduino.   All the source files, header files and external dependencies are presented in much the way you have grown accustomed to in Visual Studio.

 

 

The Visual Micro Explorer provides a visualization of all libraries installed.    There is also reference material and documentation provided along with a collection of Example code.   This is great for both learning and quickly looking up something.

 

The debug experience

 

Debugging Experience

 

Debugging and conditional breakpoints are supported.   This does though require a purchase of the Pro version.   The pro version has quite a number of additional features aswell which you can read about here:  http://www.visualmicro.com/page/What-features-are-included-in-Visual-Micro-Pro.aspx

 

The live tracing works great.  There is also the standard port monitor which does live logging of the Com ports.    In the screenshot provided the codes displayed are being reported from an infrared remote control in real-time.   The ability to see everything happen, and be visible, at once in an IDE saves a whole load of time.

 

Conclusion

I’ve been using Visual Micro for a few Arduino related Iot projects and can definitely recommend using it.

 

Happy Arduino coding!  🙂