<img height="1" width="1" src="https://www.facebook.com/tr?id=1640437302870650&amp;ev=PageView &amp;noscript=1">

Subscribe to Email Updates

bg-img11.jpg

Create a digital Piano with Ubidots and a NodeMcu

Maria Hernandez
By Maria Hernandez
on July 11, 2017

If you could make your very own digital, Internet-connected piano, what would you play? In this post we will teach you how to make program a buzzer using a NodeMCU and Ubidots.

DigitalPiano_NodeMcu.jpg

This may sound hard at the beginning but with Ubidots, it's pretty simple. We will use a NodeMcu connected to the Ubidots and establish some tones to a few buzzers hooked up to Ubidots.  Now let's make some music! 

Overview

In this post you will learn how to use the NodeMcu with a buzzer and Ubidots. The NodeMcu is an IoT device with GPIO, PWM, IIC, 1-Wire and ADC all in one board, and connects via Wi-Fi. It is easy to learn and prototype with and with the Arduino IDE, programming is a sinch.

Requirements

First, you need the following:

Setup

1. First, couple the NodeMcu to its base shield and connect the buzzer to pin D1. See photo below for reference:

IMG_20161220_111256.jpg

2. Next, go to the Arduino IDE, click on Files -> Preferences and search "http://arduino.esp8266.com/stable/package_esp8266com_index.json" into the Additional Board Manager URLs field. You can add multiple URLs, separating them with commas if needed.

3. Then open "Boards Manager" from Tools -> Board menu and install "esp8266" platform.

3a. Don’t forget to select your NodeMCU 1.0 board from Tools > Board menu after installation.

4. If you haven't already, download the UbidotsESPMQTT library and click on Sketch -> Include Library -> Add .ZIP Library

6. Select the .ZIP file of Ubidots ESPMQTT and then “Accept” or “Choose” for all the libraries. If you can't add the library, try manually adding by unzipping the downloaded rar / zip and copy the folder from the library to the path C:\Users\ubidots\Documents\Arduino\libraries

7. Reboot Arduino IDE. 

Setting up Ubidots

1. Add a new Data Source called "piano".

ezgif.com-video-to-gif-1.gif

2. Add a new Variable for each musical note. Start with a variable called "do", and then "re", "mi", "fa", "sol", "la", "ti". 

ezgif.com-video-to-gif (1).gif

3. Verify that the label of the Data Source and the Variables are the same as the name. This allows the communication between Ubidots and the NodeMcu.

4.Create the buttons/switches that allow you to play each musical note. To do this, go to Dashboard and in the upper right of the page click Add widget. Select Control > Switch > piano (data source) > do (variable) > finish. Don't forget do the same for each musical note. When complete it will look like this:

DigitalPiano_NodeMcu_switches.jpg

Program the ESP NodeMcu

Once everything is connected correctly, we will go to the IDE and write the following code.

Results

And that's it! It's time to play the piano. 

ezgif.com-video-to-gif (2)-1.gif

We've just shown you how to create a low-cost digital piano based on the Internet of Things.

 

Leave a comment

Maria Hernandez
Written by Maria Hernandez
Written by Author