It is Christmas guys! So how about a Christmas-themed rug? But not any Christmas-themed rug, an IoT Christmas-themed rug!
Let’s make an IoT carpet that when stepped on it will play Jingle Bells, light LEDs in the eyes, and Santa’s noses and finally notify that there is someone at the door, like a high-tech IoT bell door!
Material
To make this project we will need:
- 3 piezoelectric sensors;
- Buzzer;
- ESP8266 NodeMCU;
- Li-Ion battery;
- 6 LEDs for the eyes;
- 3 LEDs for the noses;
- Jumpers female-female;
- Jumpers male-female;
- Perfboard (opcional);
- Christmas-themed carpet;
Follows the scheme of the circuit:
Assembly
Distribute the Piezo in the rug so that they get the entire area, thus increasing the probability of the sensor detecting someone stepping in it:
I punched holes in the eyes and noses from Santa’s and Reindeer’s and I put LEDs:
As you can see all the connections were made with jumpers and glued to the rug with insulation tape. Pretty ugly, everything “under the rug”. If you have the patience, and the sewing skill, you can also use a conductive line to sew the connections with the LEDs and piezoelectric sensors, it is much more organized also.
In the case of NodeMCU, our ESP8266 microcontroller from our IoT rug, I scraped two rows to “fit” the pins and mount the jumpers:
And finally I glued the battery, I used a battery of 1000mAh the smallest it had around here:
Software
I used in my NodeMCU Espruino firmware, giving me the possibility to program this project in JavaScript. You can check the code that was embedded in my Github: https://github.com/microhobby/EspruinoProjects
Logic From the Rug
Let is follow the diagram:
When we initialize our ESP8266 the first thing it expects after the setup of the pins is a Wi-Fi connection. To indicate the status of the connection the program turn on all LEDs and then waits for the Wi-Fi to connect to our network. If this happens successfully the LEDs are turned off and we can begin to check the signal of the piezo sensors. The piezos will serve as pressure sensors, and will detect when someone steps on our rug. When a pressure is detected by the piezos a message will be sent through the internet, alerting us that someone is at the door, and we will start playing Jingle Bells music in our Buzzer, in the rhythm of the music the LEDs will flash changing from the eyes and noses of the Santa Claus and Reindeers.
For the message I used the Facebook messenger API to send me a message and to be notify both on my smartphone and on my computer. But you can use the service you want, is just an HTTP request or MQTT.
Once the piezo detect the pressure and initialize the song the next detection cycle will only start when the song ends and stops. Check it out an example below:
Conclusion
It’s really cool to see what we can do with a NodeMCU ESP8266, Espruino and a small battery. The use of piezoelectric pads as pressure sensors worked well, although only have 3 sensors. In order to work better, it would be better to use more sensors by taking the largest possible area of the rug.