Introduction
Today’s small microcontrollers offer impressive functionality and provide an opportunity to replace older, more expensive software and hardware.
Consider the case where a facility wants to have control over devices or equipment, with rules that evaluate telemetry from sensors and activate, deactivate or regulate equipment and other devices.
Many large facilities have systems in place that rely on a global standard named BACNet. This protocol has been an ISO standard since 2004 and allows for different types of devices to integrate with each other. Systems based on BACNet have been very reliable and used for many years across various industries. While BACNet may be an acceptable solution for large facilities, the cost associated with the controllers and software can be prohibitive for small to mid-size operations. The protocol itself can also be cumbersome to work with if you wish to develop your own custom application.
Welcome to modern microcontrollers
In my opinion, inexpensive, readily available, modern microcontrollers that were initially targeted towards hobbyists have become very reliable. The variety of sensors that easily integrate with these devices are becoming more accurate as well. This may make them a suitable replacement for proprietary devices and protocols, and in fact are being used in some industrial applications.
These devices come with the following advantages:
- Cost savings: These devices cost significantly less than their more expensive counterparts. This also makes replacement more cost-effective.
- Energy Efficiency: These smaller controllers are designed to be energy efficient, reducing electric demand within a facility.
- Cloud Friendly Protocols: Use of more modern protocols such as MQTT makes integration with today’s cloud based services like Amazon’s IoT Core and Azure’s IoT Hub easier. The benefit is maintenance free infrastructure.
One such device, the Arduino MKR WiFi 1010 comes in a small form factor and includes features such as the following:
- Built in WiFi support
- An ECC508 crypto chip
- Digital I/O pins
- Analog input pins
- An analog output pin
Refer to the documentation for additional features. Larger devices such as the Arduino Mega 2560Wifi R3 contain many more ports, 8K of SRAM, are readily available and are a formidable replacement for some commercial controllers.
Other devices such as the Raspberry Pi 4 come with HDMI output, can be configured with up to 8 GB of RAM and can be fitted with an on-board touch screen. The additional resources allow for larger applications to be run. On this platform, software can be developed in Python, Node.js and other languages since it runs a small Linux distribution.
Lending a helping hand
After having tried some tutorials online, I found them to be a little cumbersome to follow considering there are so many steps. I’ve tried to ease the process for developers interested in getting started with IoT by creating a bootstrap repository at github.com/chariotsolutions/mkr_1010_iot_template. This will help you get up and running quickly with an application and infrastructure to send data from the MKR 1010 via MQTT to Amazon’s IoT Core, ingest the data and persist it into Amazon’s S3. From there, additional features such as rule based evaluation and device control can be added.
The repository contains the following:
- The firmware for the MKR 1010 WiFi fitted with the MKR 1010 Environment Shield which provides it with sensors for light, humidity, temperature and barometric pressure.
- A set of directions in the form of a README file.
- A terraform script to register the device in Amazon’s IoT Core and configure the infrastructure allowed to consume the data and persist it into Amazon’s S3.
This should be enough to get you started with cloud-based integration of a basic device with sensors. For additional information on IoT Core and security and MQTT, refer to this presentation.