Do you have a Lego Mindstorms NXT kit lying unused at home? You can combine a Raspberry Pi device, with a Brickpi to build your IOT solution using the awesome Lego Mindstorms sensors/motors. Here we will look at a Noise monitor (which has been packaged as a docker container) and built using the sound and LED color sensor.
Before going into the details of the solution I will try and answer a few questions :
Why a noise pollution monitor? Though there are several solutions which can be built using the Lego Mindstorms sensors and motors, I first decided to build this solution because, I am sure that if people realized how much unwanted noise they are adding to the environment by shouting, or pressing the car horn unnecessarily, they would change things for the better. As shown in the overview diagram whenever the sound intensity percentage crosses the configured threshold the green LED turns of and the red LED turns on.
Why Brickpi? Normally the Lego Minstorms sensors/motors are used with the Minstorms controller, however the Mindstorms controller has limited capability in terms of hardware (Memory, processor speed, no wifi to name a few). This is where Brickpi comes in, it provides a similar interface to the Mindstorms controller for the sensors and motors, and it also interfaces with the raspberry pi, enabling us to utilize the awesome hardware and connectivity of the raspberry pi.
Why Docker? I wanted to make it seamless for anyone wanting to replicate this solution, and then tweak it as per their needs, and let’s face it once you start using docker, it is difficult to turn back, you want to use it for every solution. The hypriot image comes loaded with the docker engine, and is one of the easiest ways to get started with docker on the pi.
Noise Pollution Monitor (packaged as a docker container) using Lego mindstorms sensors, Brickpi and Raspberry Pi
Raspberry pi is loaded with the Hypriot version 0.8.0 – Barbossa image. Once the pi has booted up with this image, docker is available on the pi. All dependencies needed for the pi to control the Mindstorms sensors, and the Brick pi (including the Brickpi_Python library) are built into the docker container image, using the Dockerfile shown in the project’s github repository.
To start the monitor we can run the container as follows :
docker run -e INTENSITY_THRESHOLD=40 -d --device /dev/ttyAMA0:/dev/ttyAMA0 --device /dev/mem:/dev/mem --privileged -ti maninderjit/pi-brickpi
(Sound intensity threshold configured to 40% using -e switch of the docker run command above)
For details of the python code and configuration details you can have a look at https://github.com/maniSbindra/docker-brickpi-raspberrypi-hypriot.
Thanks for reading my blog. I hope you liked it. Please feel free to write your comments and views about the same over here or at @manisbindra.