This Project aims at measuring the distance using an ultrasonic sensor HC-SR04 and an ESP8266 WiFi module. The measured values are sent to AskSensors IoT platform through WiFi, so the user will be able to access to the data remotely and visualize data stream in real time.
Before proceeding with this tutorial, you will need to create an AskSensors account. it takes less than one minute to get a free account and sign in !
Then, create a new sensor to send data to, here is an example to start with.
- Hardware Needs:
- Build The hardware:
Note: Basically the HC-SR04 should be powered by 5V power supply, and it happens that some HC-SR04 sensors don't work well with 3.3V power supply. In this case, you can power the sensor with 5V (if available on the development board or external).
- Run the code
The provided code has been tested and should work as is. All you need is to set the following parameters:
const char* wifi_ssid = "...................."; // SSID const char* wifi_password = "...................."; // WIFI const char* apiKeyIn = ".................."; // API KEY IN
- Visualize data stream
The image below shows how data looks like in a Line graph. Go to your sensor dashboard at AskSensors and select your graph.