<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

Digital Piano with Ubidots and NodeMcu

Maria Hernandez
By Maria Hernandez
on December 30, 2016

What if you could make your very own digital, Internet-connected piano? It can be a bit complicated, but it's your lucky day! We'll teach you how to make one in just a few steps.

DigitalPiano_NodeMcu.jpg

It's actually very simple. We will use a NodeMcu connected to the cloud (Ubidots) and we'll establish the musical notes. We'll also create buttons in Ubidots replacing the standard piano keys. So, let's make the music sound! 

Overview

In this post you will learn how to use the NodeMcu with a Buzzer + Ubidots. NodeMcu is IoT device with GPIO, PWM, IIC, 1-Wire and ADC all in one board, and it has connection via Wi-Fi. Is easy to use and you just need the Arduino IDE to learn to program it. 

 

Requirements

First, you need the following:

Setup

1. First, couple the NodeMcu to its base shield and then make the connection of the buzzer to pin D1. It should look like this:

IMG_20161220_111256.jpg

2. Go to the Arduino IDE, click on Files -> Preferences and enter 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.

3. Open "Boards Manager" from Tools -> Board menu and install esp8266 platform. Don’t forget to select your NodeMCU 1.0 board from Tools > Board menu after installation.

4. Download the UbidotsESPMQTT library if you haven't already. Now, 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; unzip the downloaded rar / zip and copy the folder from the library to the path C:\Users\ubidots\Documents\Arduino\libraries

7. Close the Arduino IDE and open it again.

 

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. Finally,  its should 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 de 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 (IoT), which by the way proves how apparently complex things can be done with the right tools and time. 

 

Leave a comment

Maria Hernandez
Written by Maria Hernandez
Written by Author