Esp 8266
Esp 8266
net/publication/326580937
CITATIONS READS
0 1,521
1 author:
M. Todica
Babeş-Bolyai University
97 PUBLICATIONS 330 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
IR and Raman Investigation of Some Poly(acrylic) Acid Gels in Aqueous and Neutralized State View project
Simple WI-FI remote car with smartphone and Blynk View project
All content following this page was uploaded by M. Todica on 24 July 2018.
M. Todica
In this project we show how to measure distances with the ultrasound sensor SR HC 04
connected to NodeMcu ESP 8266 and send the results to the smartphone, using Blynk
application. There are a lot of projects referring to this subject, but few of them are
concerning with the transmission of data trough the internet. The majority of the projects
use the module SR HC 04 which contains one ultrasound sender and one receiver, (Fig.
1). The principle of distance measurement is very simple: a short ultrasonic pulse
transmitted at the time 0 is reflected by an object and received after a time interval the
echo time,(Fig. 2). Knowing the speed of the ultrasound in air, c= 340 m/s, and the time
, the distance is given by the simple relation d=c /2. (Keep in mind that represents the
Hardware
For this project we need only HC SR 04 module and NodeMcu ESP 8266 board.
Optionally we can use Oled 0.96” (124x64 pixels) display if we want do display locally
the data. The electric diagram is presented in figure 4. We must take care that HC SR 04
is 5V operating and NodeMcu ESP 8266 works at 3.3V. For this reason a level logic
converter must be used when connecting the two modules together. A much simplest
solution is the use of 2/3 resistive divider connected to the Echo pin of the HC SR 04.
This is an output pin which provides TTL signals with amplitudes going up to +5V. This
signal is applied to NodeMcu board which accepts only signals smaler than 3.3V. The
resistive divider reduces the amplitude of the Echo signal up to 3.3V. The trigger pin of
the HC SR 04 is an input pin driven by the NodeMcu board and can be activated by
signals with amplitude smaller than +5V. So we don’t need level converter because the
output signal provided by NodeMcu is enough high to drive the ultrasound board. The
ECHO and TRIG pins are connected to the pins D5 and D6 of NodeMcu board using the
syntax:
#define ECHOPIN 12 // Echo pin to D6
#define TRIGPIN 14 // Trig pin to D5
The software
For this project we used the version Arduino 1.6.8. Then Arduino must be set to
recognize and communicate with the NodeMcu ESP8266. We can follow the procedure
described in the link below:
5.6 K
2 x 5.6 K
5.6 K
2 x 5.6 K
3. Manage ESP library. In the Arduino IDE go to the menu Sketch/ Include Library/
Manage Libraries/ and add the Library of ESP8266.
4. Set the NodeMcuESP8266 board. Go to menu Tools/ Board/ Boards Manager/, Select
NodeMCU 1.0 (ESP-12E Module).
At this stage the Arduino is able to recognize and communicate with the board.
If we want to use the Oled display we must download and install the libraries Adafruit
GFX and Adafruit SSD1306. We can use the link below.
http://arduino-er.blogspot.ro/2016/04/nodemcu-esp8266-to-display-on-128x64.html
The code
Open new sketch in Arduino IDE and upload the following code:
//////////////////////////
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
Adafruit_SSD1306 display(-1);
void setup()
{
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendUptime);
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,40);
display.print("radar");
display.display();
void sendUptime()
{
else {
digitalWrite(TRIGPIN, HIGH);
}
digitalWrite(TRIGPIN, LOW);
}
Serial.println(distance);
Blynk.virtualWrite(12, " ");
Blynk.virtualWrite(12, distance);
display.clearDisplay();
display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print(distance);
display.display();
}
}
void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}
////////////////////////////
After uploading the code the board can be disconnected from the computer and powered
by an externally separately source. It will become to work and send the data to the
smartphone. For reliable connection to the internet the board NodeMcu must be placed in
the area of strength signal of the WI FI router.
View publication stats