A web-controlled smiling snowball based on the Arduino MKR1000 controlled via WiFi using MQTT, Shitr.io and Node-red.
This project started with the intention to be a proof of concept for some techniques that I wanted to learn. Since it is winter now and it started to snow, I came up with the idea to build it as a smiling snowball.
The main goal is to make the Smiling Snowball controllable via WiFi using a simple web-based user application. This application should be easy to create and to control.
The following hardware and software is used:
- As hardware for this project, it uses the Arduino MKR1000 because this is a fast development board including a stable WiFi support embedded on the board.
- For the communication via WiFi, the MQTT protocol is used. This protocol needs a broker in the network. Therefore, Shiftr.io is used. But this can also be an other MQTT broker.
- For the web application, Node-RED is used. This runs on top of Node.js. Node-red is a simple drag and drop tool for creating applications on top of Node.js. Node-RED also supports communication via MQTT. Node-RED also has the potential to create a dashboard and connect UI elements to functions.
- For the display elements in the snowball, we connected six 8×8 LED matrix units and split them into groups of 3 for testing multiple control of devices.
Global project setup
The goal was to control the smiling snowball via WiFi using a simple web-based app that can be used from PC/tablet or mobile phone. The following diagram shows the different components of the project and the communication between them.
The blue arrows are the communication via MQTT. The green arrows are the web communication to the tablet and mobile phone. The physical communication is via Ethernet and WiFi.
Arduino MKR1000 Application
The Arduino MKR1000 is used for two functions. It handles the communication with the MQTT broker (Shiftr.io) using its WiFi connection and it controls the LED matrices.
This application uses the default 101WIFI library for creating the WiFi connection. To create a connection to your WiFi access point, you need to fill the correct information for your access point.
char ssid = "##############"; // your network SSID (name) char pass = "##############"; // your network password
For the MQTT PUB/SUB communication, the MQTTClient library is used. For this library, a connection to some MQTT broker is needed; also, the IP address and port should be filled in. Also a username and password is needed for the MQTT broker. See more details at the paragraph of the MQTT broker.
To receive commands in the Arduino MKR1000, the application should listen to the broker for messages on topics it has been subscribed to. If data is published for a topic, the application will call the message received function and process the message.
To see if the applications are up and running, a heartbeat message sent between the Node-RED and the Arduino MKR1000 is included. On the Shiftr.io dashboard, it is easy to see the flow of the data. The moving black dots on the dashboard are the data.
Read more: Smiling Snowball
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw