This instructable presents how to monitor the distance from an object using ultrasonic HC-SR04 sensor and ESP8266 node MCU connected to the AskSensors IoT cloud.
Step 1: Material We Need
We will need the following Hardware:
- ESP8266 Node MCU
- Ultrasonic HC-SR04 Sensor
- Bread Board
- Jumper wires
- Micro USB cable
Step 2: Build Your Hardware
Connect the ultrasonic sensor to the ESP8266 node MCU:
- HC-SR01 TRIG pin to ESP8266 D1 pin
- HC-SR01 ECHO pin to ESP8266 D2 pin
- HC-SR01 VCC pin to 5V (you can also try with 3.3V)
- Ground to ground
Step 3: AskSensors Setup
- Get a free account at https://asksensors.com/
- Sign in and create a new Sensor.
- Copy down your Sensor API KEY IN.
Step 4: Download the Code
Download the code from the AskSensors github Page.
Decompress it and fill the following informations:
const char* wifi_ssid = "...................."; // SSID const char* wifi_password = "...................."; // WIFI const char* apiKeyIn = ".................."; // API KEY IN
Step 5: Run the Code
Connect the ESP8266 to your computer and upload the code.
Now, Go to your AskSensors dashboard.
Open your sensor page and add a new graph to visualize your data stream in real time as shown in the enclosed figure.
Miatadude made it!