Building Cool Stuff With M5stack Fire IOT Devices

Corona is still forcing everyone to remain working from home and to entertain and school the children at home too. Obviously, this leads to situations where not everyone is happy and voices are raised.

After one more discussion on the dinner table with kids yelling at each other, we figured, that we need a way to help everyone to lower their voices. If we, as parents, suggest doing that this will quickly become repetitive. So what can we do to help them learn when everyone is too loud?

As an engineer, my solution is not reading books about how to better engage with your children, but I quickly start browsing the internet and searching in my electronics cupboard for ways how to build something interactive. While I did not have anything handy at the time, I first came across the magic ESP32 chip that seems like an Arduino on steroids and offers lots of different development boards. Unfortunately, while I’m good at coding, wiring and soldering is not necessarily my strong suit. Searching further, I came across M5Stack that offered fully built devices on top of the ESP32 platform. Compared to traditional Arduino, they do allow programming not only with C/C++, but as well using Micropython and a very nice web interface using a block-based programming language, similar to Scratch. I was sold.

Making Noise

The device arrived, and I started tinkering using Micropython and quickly built the first application, the kid’s noise monitor, the app is a little bit of Python and you can find the source code here.

A noise monitor for the M5Stack fire.

This barely took me two hours to write with figuring out a bunch of things like, how to process the audio signals and a quick read up on how to sample them reasonably. It uses the microphone, the LC display, and the RGB bars on the side.

Solving the Maze

Next up, I wanted to play with the Lego brick compatibility of the device and figure out how to leverage the Gyro sensor of the device. While the MPU is exported to Python as well, the data seemed to be a bit scrambled and further reading brought me to this issue and it turned out that I will have to use C++ for this.

The M5Stack devices are Arduino compatible, but I don’t like the Arduino IDE, and was looking for alternatives. The Espressif IDF, started to look ok, but I ended up with lots of issues setting up the components and getting things to work together. In the end, I used Platformio and it turned out great - VSCode as the editor and easy integration of Arduino and the M5Stack libraries.

The idea of the project was to build a small game that allows the user to navigate a marble through a maze. Nothing fancy, but together with the Lego integration it looked like a cool thing for my kids and me to play with.

Without further ado, here is the final result:

A maze game for the M5Stack fire.

After figuring out how to randomly generate solvable mazes, deal with the Gyro it was not complicated. For inspiration, I put up the source code of this project on Github - https://github.com/grundprinzip/mazepuzzle

Summary

The M5Stack devices are awesome and a great start for embedded and IOT projects. They come with Wifi, Bluetooth, etc all included leaving almost no desires open. Next up for me is to work with the M5Stack Paper to see what cool projects I can build using a touch e-paper display and the ESP32.

The project I have in mind is to control the REST API of my Gira Home Server from this device and have a nice energy efficient e-paper remote control for my smart home!