Proximity Sensor

Lab 3 Car Proximity Sensor

Online Link

  • This lab is available online at

  • The writup is also hosted at


The purpose of this guide is to use the stoplight made in the previous lab with a proximity sensor to create a indicator for when your car has reached a specific distance away from the garage wall.

Needed Materials

The needed materials for this lab are: – 2 x Wemos d1 mini (arduino board) – jumper wires – 1 breadboard – 1 x red LED – 1 x yellow LED – 1 x green LED – 3 x 220 ohm resistors (RRBLBLBR) – Computer – Arduino IDE and necissary drivers – HC-SR04 Ultrasonic Sensor ## Sources

I used the following references in the creation of this guide:




  1. First complete the previous tutorial with this completed the adding of the proximity sensor is fairly easy

  2. Add the WIFI library and connect to wifi on the second d1 mini the same way we did with the stoplight.

  3. Using this tutorial create a httpclient that can make requests from an http server. In this project the proximity sensor will request the /green /red /yellow web pages we made for the stoplight using the httpclient library. This is the basic communication method that will be used between the 2 micro controllers. Note: To get the IP address of the stoplight web server I plugged it into my computer and used the serial monitor and then hard coded that into my proximity sensor.

  4. Wire up the proximity sensor so that ground goes to ground, vcc goes to 5v and the trig and echo go to 2 gpio pins.

  5. Use the New Ping library to get the proximity sensor working.

  6. One of the issues with the proximity sensor is it can throw some outliers in data, I created a simple error detection function that takes 5 samples, throws out the largest and smallest and then averages the other 3. This reduced the number of errors I was getting.

  7. Finally code the Arduino so that it sends the appropriate get request depending on the distance being given by the proximity sensor. I set mine up so that when it was far away it was green then as I got closer it went to yellow then red and then flashed.

Thought Questions

1. Think of the interaction between your devices. How well would this scale to multiple devices? Is it easy to add another sensor? Another actuator?

This wouldn’t scale well to another sensor in my opinion. I feel like 1 to 1 communication is OK but when you get more devices it works better to have a central hub that handles the logic and then several sensor and actuators that report back to it.

2. What are strengths and weaknesses of the tennis-ball-on-a-string system that Don had originally? What are strengths and weaknesses of the IoT system that he developed? What enhancements would you suggest?

– The strengths of the tennis ball are that it never really quits working, if the power goes out you still have a tennis Ball on a string. You also are not prone to the errors you get with the IOT sensor. The weaknesses are that a dog or children can tend to play with it and rip it off making it totally useless.

– The strengths of the IOT device is that it isn’t distracting like the tennis ball. It can be played with without being destroyed. It can also be configured to tell you other information like if the car is in the garage or not. Its weaknesses are that it is power dependent and the proximity sensor is sitting in the crash zone on the garage wall.

3. What was the biggest challenge you overcame in this lab?

The biggest challenge I overcame in this lab was debugging a faulty proximity sensor. Once that was working the only real time consuming things was getting the error handling working as I am not very comfortable with coding in C.

4. Please estimate the total time you spent on this lab and report.

Lab: 4 hours Report: 1 Hour

Posted in IOT

Leave a Reply

Your email address will not be published. Required fields are marked *