Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | Buy from JP |
In this lesson, we’ll learn how to use HC-SR04 Ultrasonic sensor to measure distances and send data to remote browser .
First, please insert the ESP8266 wifi Shield into your UNO board,
UNO Board | HC-SR04 |
5v | VCC |
GND | GND |
D8 | Trig |
D7 | Echo |
Software Installation
Step A)Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip this step).Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en, then install the software.
Step B) Connect the Arduino UNO board to computer via USB cable,
Step C) Open the Arduino IDE and choose corresponding board type and port type for you project.
Step D) Download the sketch file fromhttps://osoyoo.com/driver/Esp8266_Arduino_IOT/lesson9/esp8266-lesson9.zip
unzip the file and double click the esp8266-lesson9.ino file, load the sketch into Arduino IDE, find following lines:
char ssid[] = "******"; // your network SSID (name) char pass[] = "******"; // your network password
please replace the ****** with your correct wifi SSID and password, otherwise your project can not connect to Internet.
Step E) After change above lines, load the sketch into Arduino IDE.
Open your Serial Monitor, you can see your router will assign an IP address to your Arduino as following:
Now put an obstacle in front of the sensor and use another computer or your cell phone’s browser to visit url : http://192.168.50.116 Your browser will show following result which tells you the distance between sensor and obstacle:
DownLoad Url osoyoo.com