Arduino Ultrasonic Distance Monitoring using IoT Platform

Want to measure how far away objects are and check the results from anywhere? This project shows you how to track distances using the HC-SR04 ultrasonic sensor and Arduino. We’ll connect everything to the AskSensors IoT cloud platform through WiFi with an ESP-01 module, so you can check your measurements from anywhere with internet access.

It’s a great setup whether you’re a hobbyist or an organization wanting to keep tabs on sensor readings through the cloud.

Ultrasonic sensor applications

Before we get our hands dirty, here are some cool ways people are using ultrasonic sensors:

  1. Vehicle Autonomy: Self-driving cars use these sensors to spot objects and measure distances in real-time, helping avoid crashes.
  2. Smart Home Solutions: Ever used a touchless faucet or had lights turn on when you walk into a room? That’s ultrasonic sensors at work.
  3. Hazardous Liquid Monitoring: They help measure dangerous liquids from a safe distance, keeping both equipment and people safe.
  4. Inventory Management: Warehouses use them to track stock levels without constant manual counting.
  5. Manufacturing Precision: They ensure parts are placed exactly where they need to be on assembly lines, reducing waste.
  6. Non-Invasive Flow Measurement: Water treatment plants and factories use them to measure liquid flow without disrupting it.

Step-by-Step Instructions

1. Create an AskSensors Account

Sign up at Asksensors.com

2. Set Up Your Sensor Project

Just follow the account setup instructions to create your new sensor.

3. Assemble Your Hardware

Grab all your materials: 1 x Arduino, 1 x ESP-01, 1 x HC-SR04 Ultrasonic Sensor, 1 x Breadboard and some jumper wires

Remote Distance Monitoring with Arduino, an ultrasonic sensor & IoT Platform

4. Connect ESP-01 to Arduino

Hook up the ESP-01 to your Arduino as shown in this tutorial.

5. Wire the HC-SR04 Sensor

Connect your ultrasonic sensor to the Arduino like this:

TRIG → Arduino Pin 9

ECHO → Arduino Pin 8

VCC → Arduino 5V

GND → Arduino GND

6. Download & Configure the Code

Grab the source code from the AskSensors GitHub.

Extract it and update these important details:

String ssid = "YOUR_WIFI_SSID"; // Your WiFi network name
String password = "YOUR_WIFI_PASSWORD"; // Your WiFi password
String apiKeyIn = "YOUR_ASKSENSORS_API_KEY"; // Your AskSensors API key in

Code of Distance Monitoring with Arduino, an ultrasonic sensor & IoT Platform

7. Upload & Run the Code

Plug your Arduino into your computer with the USB cable.

In Arduino IDE:

Pick the right board and port.

Hit upload.

Open the serial monitor to check that:

Your Arduino connects to WiFi successfully.

Distance data is making its way to AskSensors over HTTP.

8. Visualize Your Data on AskSensors

Log into your AskSensors account.

Navigate to your sensor’s dashboard.

Add a nice graph (a bar graph works well) to see your distance measurements.

You’ll now see updates coming in from your Arduino in real-time.

result of Distance Monitoring with Arduino, an ultrasonic sensor & IoT Platform

Bonus: Set Up Email Alerts

– Log into your AskSensors IoT platform and select your sensor
– Click the ‘Add Alert’ button
– Select ‘Email Alert’ as the notification type
– Configure your threshold settings:

Set ‘Min Value’ to 100 (or whatever distance matters to you)
Enter your email address
Save the configuration

Now you’ll get instant email alerts whenever the distance drops below 100 centimeters!

That’s it! Your Arduino is now sending distance measurements to the AskSensors IoT Platform, and you can check them from anywhere!

We’re curious to know how you’re using this tutorial in your own projects. Drop a comment below and join the conversation!

1 Comment
  1. Love how this project bridges physical sensors with online dashboards. I’m thinking of adapting this for a smart parking space tracker—seems like a great fit for monitoring available spots in real time.

    Leave a reply

    AskSensors Blog
    Logo