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 Robotics

Arduino Robotics Series, from a car to a robot arm

Arduino keeps standing out from the crowd of all-around development boards due too its ease of use and budget price. As a result, this has enabled almost anyone to get his own idea into life no matter how crazy or even useless to the whole world it was, except for its maker! Also, it has …

Arduino Robot Arm

How to build an Arduino Robot Arm placed on RC Car

Arduino robots are always funny and definitely more enjoyable when combined with robotic arm! And today, I will walk you through the making of a simple Arduino Robot Arm that’s made of cardboard and how you can attach it over your Arduino Bluetooth RC Car / Robot that you have made so far through this series. …

Arduino Line Following Robot

How to build an Arduino Line Following Robot using Cardboard

Arduino Line Following Robot is one of the easiest and most well-known projects that anyone can make to learn the basics of programming, electronics, and mechanics all in one project. It’s known that this project is common for most of the makers and tech students and today I am going to give it a revisit …

Arduino Obstacle Avoiding Robot

How to build an Arduino Obstacle Avoiding Robot using Cardboard

Back again with another Arduino Bluetooth RC Car tutorial but with an advanced feature that makes your car autonomous by adding ultrasonic sensors to the RC Car you have made before!. Yeah, I know that you may have seen other tutorials using ultrasonic to make the car/robot avoid obstacles ahead, but I am going to …

Arduino Bluetooth RC car

How to make an Arduino Bluetooth RC Car using Cardboard

  Cardboard crafts are one of the most popular and easy to make DIY stuff. Mixing this with the unmatchable enjoyment of RC Cars and the ease of using Arduino, I am going to show you how to make a Cardboard Arduino Bluetooth RC car that you can control via Bluetooth from your smartphone.  …

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 …