Range Finder IoT Range Finder IoT

Instructables Instructables

    Check some projects published on Instructables website

Basic Security with ESP8266

Temperature Monitor with ESP8266

Illuminance Monitor with ESP8266


More details here...

   Range Finder IoT


        This project allows you to measure distance with with an ultrasonic range finder.



Project  Range Finder
Time to build  1 hour
Cost $30
Arduino Code download
Cloud Device Code N/A
Mobile App Code download



        Here you have the list of the components required to build the hardware. We assume you have a computer, a router and a network cable. If you purchase the Arduino board from the specified source it comes with the USB cable. Otherwise you might need to provide a USB cable too. You can find better options for hardware. Be careful what components you buy. For Ethernet boards there are many versions with different chip sets but only the standard Arduino Shield or equivalent works with the software provided here. The prices are just a guide. These are the values we found when we created this project.

Picture Name Price Source

Arduino Uno

 $13 Link
Arduino Ethernet Shield $10 Link
Ultrasonic Sensor (DS18B20) $3 Link
Single Port Female to Female Jumper Wires $3 Link
Single Port Male to Male Jumper Wires $2 Link


        We recommend to buy an Arduino board with a smaller USB connector (mini or micro USB) because the Ethernet Shield will not insert properly most of the time if you do not use original Arduino boards.

        Here you have a picture with the components we used:




       This section shows the pinout of the components or provide a link to the specifications of the component.


Component Name Pins
Arduino Uno See: http://arduino.cc/en/Main/arduinoBoardUno
Arduino Ethernet See: http://arduino.cc/en/Main/ArduinoEthernetShield
Temperature Sensor
Pin Description
GND Ground
Echo Receive the Echo pulse
Trig Trigger the ultrasonic pulse
Vcc 5V



        This section shows you how to connect the components together. First you have a pin-out connection and below there are pictures showing how it's done on the real boards.


Temperature Sensor Pin ArduinoUno
Vcc +5V
Echo D8
Trig D9


Arduino Ethernet ArduinoUno
Just insert the Ethernet Shield into Arduino Uno

       Here you have pictures with the wiring





        The schematic is




        To run the system you need two software components. One is the software to run the hardware (Arduino Software) and the other one is the mobile App (Mobile App).


     Arduino Software

        To run the software you need the Arduino development environment.You have to load the software provided here and configure it. There is only one value you need to change in the code.


Field Description

This is a unique id you have to create for your hardware device to identify it from others in the cloud. Use this www.guidgenerator.com to generate GUID (Global Unique ID)

String devId      = "b5ebf7a7-e63a-4660-8f83-cf1e5d39cf5b";

This is the authentication string required for basic authentication of the http requests. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"

String auth    = "dXNlcjpwYXNzd29yZA==";


       And here you have the sketch (download)


#include <SPI.h>
#include <Ethernet.h>

#define echoPin 8      // Echo Pin
#define triggerPin 9   // Trigger Pin

// Network settings
byte mac[]     = { 0xDE, 0xED, 0xDD, 0xDD, 0xFE, 0xED };
EthernetClient eth;

char server[]  = "www.ic2pro.com";                          // Wiring Cloud host name
int port       = 80;
String devId   = "111-222-333";                             // Device ID. CREATE YOUR OWN GUID; Use this http://www.guidgenerator.com/
String auth    = "dXNlcjpwYXNzd29yZA==";                    // Authentication credentials Create a string from <email_address>:<API_Password> and encode it base64
                                                            // The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"

void setup() {
  // start serial monitoring
  // set-up pins
  pinMode(triggerPin, OUTPUT);
  pinMode(echoPin, INPUT);

  // start network communication

void loop() {
  long duration, distance;
  digitalWrite(triggerPin, LOW);

  digitalWrite(triggerPin, HIGH);

  digitalWrite(triggerPin, LOW);
  duration = pulseIn(echoPin, HIGH);

  // Calculate the distance (in cm) based on the speed of sound.
  // distance = duration * speed of sound / 2
  // We divided by two because the sound travels to destination and 
  // comes back which is twice the distance we measure
  distance = duration * 0.034 / 2;
  if(distance > 0 && distance < 1000)

void sendRange(String range) {
  if (eth.connect(server, port)) {  // connect to server
    eth.println("GET http://" + String(server) + ":" + String(port) + "/Wire/connector/set?id=" + devId + "&RANGE=" + range + " HTTP/1.1");  // send range to server
    eth.println("Authorization: Basic " + auth);
    eth.println("Connection: close");
  else {
    Serial.println("Connection Error");


Mobile App


        The mobile application to receive the data for the range finder is built with "App Inventor" (ai2.appinventor.mit.edu). If you just want to import the .aia file you can download it here. Otherwise you have to create next components.


Component Name Description
Label RangeMsg A text that shows the "Range" word.
Clock Timer A timer that will send regular requests to get the temperature from the Wiring Cloud.
Web APIGetRange

The HTTP request that will be sent to retrieve the range value. Set Url to:


don't forget to put the device_id you set in the Arduino Code

        In the code you have to set a proper authentication string. Replace the string "Basic dXNlcjpwYXNzd29yZA==" with your authentication string. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password". Make sure you append "Basic " at the beginning of it.

        And this is the logic you have to create in App Inventor. Once that is done you just build the APK and install it on your Android phone.


    Final Product

       Here you have a picture of the "final" product, hardware and screenshots from App.