Getting started with 1Sheeld and esp8266

 

ESP8266 Tutorial

ESP8266 Tutorial

 

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 ….

 

Gather Components for the ESP8266 Tutorial

  • 1Sheeld+
  • ESP8266 or NodeMCU
  • LED
  • 4 male-male jumper wires
  • Breadboard

Before you start …

If you are just getting your 1Sheeld out of the box then go ahead with this 1Sheeld getting started tutorial or simply check the 1Sheeld User’s Manual.

Also, please get your hands dirty with this 5 minutes-effort “Blink” example in this ESP8266 getting started tutorial.

 

Now .. you are ready to piece together with the ESP8266 Tutorial …

Hardware Connection:

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:

 

Note:

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:

Code

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):

 

Code uploading

  • 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!

More …

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 😉




Related Blogs

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

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 IoT

Arduino IoT Shield Functions Explainer

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 …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

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 …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “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, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

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 …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

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. …