We know that 1Sheeld works great with Arduino boards like Uno, Mega, Noao, … etc. And thanks to “Jeff French”, it works with Raspberry-pi too! Check Jeff’s tutorial about that here.
And regarding that we have received many requests about how to use ESP8266 board with 1Sheeld, I am going to show you how you can make it using NodeMCU; the popular ESP8266-powered development board.
Therefore, in this ESP8266 Tutorial, I will make a simple tutorial that’s about connecting an LED and control it with the phone’s MIC via the 1Sheeld MIC Shield which will turn the LED on whenever the phone detects a loud noise.
How it will work
Let’s understand first how 1Sheeld works with the Arduino. When you plug 1Sheeld over your Arduino then you end up with these connections, internally:
Tx pin of 1Sheeld (pin 0) with >> Rx pin of Arduino (pin 0)
Rx pin of 1Sheeld (pin 1) with >> Tx pin of Arduino (pin 1)
5v pin of 1Sheeld with >> 5V pin of Arduino
GND pin of 1Sheeld with >> GND pin of Arduino
And that’s how 1Sheeld is powered on and makes the communication with the Arduino. Also, that means if you unplugged the 1Sheeld and connect its previously mentioned pins to the Arduino manually with jumper wires then it should work, right? Yes .. it will definitely work and here’s the key to get it to work with the ESP8266 board 😃
So, let’s make it and see what hardware components you will need ….
Now .. you are ready to piece together with the ESP8266 Tutorial …
Connect the 1Sheeld to the NodeMCU as follows:
Tx pin of 1Sheeld (pin 0) with >> Rx pin of NodeMCU
Rx pin of 1Sheeld (pin 1) with >> Tx pin of NodeMCU
5v pin of 1Sheeld with >> 5V pin of NodeMCU (VU pin which is Voltage Usb)
GND pin of 1Sheeld with >> GND pin of NodeMCU
LED anode with >> D7 pin of NodeMCU
LED GND with >> GND pin of NodeMCU
You should end up with the hardware connected like that:
And I selected pin D7 because, in NodeMCU, it maps to the Arduino pin 13 or as it’s called in the NodeMCU; GPIO 13.
Check this image for the full NodeMCU- Arduino pins mapping:
NodeMCU board takes USB 5v and convert it to 3.3v to power its ESP8266 chip so that you should adjust 1Sheeld’s 5v/3.3v to the 3.3v notation so the voltage level between the NodeMCU & 1Sheeld is the same and no damage would occur to your NodeMCU board.
In addition, here is what your simple circuit should really look like:
The code you are going to upload to your ESP8266 board is the same Arduino code for the 1Sheeld with Arduino getting started tutorial. It’s for controlling an LED on pin 13 (pin D7 for the ESP8266) by making a noise loudly near the smartphone’s mic.
BUT with only 1 extra line of code that you have to add to optimize it to work on ESP8266. It’s this function:
This’s necessary to get your code working and its functionality is to continuously listen to any data coming from the Bluetooth of 1Sheeld.
I know that you are wondering why you didn’t face it in the case of programming Arduino with 1Sheeld over it, but the fact is, you did, anonymously in the background!
So, simply, Arduino has a hidden code that runs after your void loop() code which is a function called “serialEventRun();” and its functionality is to keep listening to the data coming serially to the Arduino. Check this link to know that code which runs behind your Arduino code.
But ESP8266 doesn’t run this function in the background as Arduino do and that’s why you MUST call a similar function that does the same job, listen to what your ESP8266 receives serially from the phone. That function is “OneSheeld.processInput();“.
Moreover, here is the full code (you can change the value of 60 with a proper threshold that your phone’s MIC can handle):
ESP8266 NodeMCU with 1Shield Example
This example shows an application on 1Sheeld's mic shield with the ESP8266 NodeMCU
By using this example, you can turn on the LED on pin GPIO13 of the ESP8266 NodeMCU if the
smartphone's mic reports a certain noise level.
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.
/* Include 1Sheeld library. */
/* A name for the LED on pin 13. */
/* Start communication. */
/* Set the LED pin as output. */
/* Always check the noise level. */
/* Turn on the LED. */
/* Turn off the LED. */
Connect the NodeMCU via your PC using Micro USB cable.
Switch the 1Sheeld power to operate on 3.3v (Not the 5v):
1Sheeld has 2 modes: Uploading mode and Operating mode. You can switch between them using the switch close to the Digital pins and is called “SERIAL SWITCH”.
Firstly, you slide the switch towards the “SW” notation which turns the 1Sheeld board into the Uploading mode to let you upload the code to your NodeMCU.
Secondly, after you finish uploading the code, slide the switch towards the “HW” notation which turns the 1Sheeld board into the Operating mode to communicate with your smart phone’s app.
Run it …
After that, open the 1Sheeld App, select the MIC Shield and watch your LED turns on whenever your phone capture any noise; like your hands clapping, talking or even loud music!
In conclusion, this ESP8266 Tutorial was only a quick starting guide to let you use 1Sheeld with the ESP8266 board. Surely, there are more out there that you can make with ESP8266 and 1Sheeld.
Finally, if have any questions please let me know in the comments below .. stay tuned for the upcoming tutorials 😉
Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …
Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …
Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …
“Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …
Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …
Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …