Introduction: Arduino and Ultrasonic Sensor Based Radar on SLabs-32 IOT Board

Well, you might have seen this awesone Ultrasonic based RADAR system being done many times by the community of hobbyists in the past. Here I am not trying to claim the first rights for the RADAR system based on ultrasonic sensor and Arduino, but want to show you how good and useful this new IOT board SLabs-32 is for prototyping!!

I started using this board for a while now and in love with it already. (More information available here)

Lets get into the business now.

Step 1: Material Needed.

For this project you just need the following components.

  • SLabs-32 IOT board
  • HC-SR04 (version 1 used here)
  • Servo (any servo will work fine, s9257 is used here)
  • 3x1K resistors
  • Breadboard
  • Jumper wires.

Step 2: Getting the Ultrasonic Sensor and Servo Up and Working.

First task at hand is making sure the ultrasonic sensor is integrated with SLabs-32. If you are using a first generation HC-SR04 like I did then you need to be careful about the logic levels of the sensor and Slabs-32 board. Here the sensor's Vcc is expected to be in the range of 4.8 - 5V and the trigger and echo pins work accordingly.

Where as entire SLabs-32 board works on 3.3V i.e, every pin is 3.3V tolerant. With ultrasonic sensor running on 5V, echo pin will output a 5V logic and may damage the micro-controller when connected directly to SLabs-32. Luckily Ultrasonic sensor works on TTL logic, which means anything above 2V is high and anything below 0.5V is considered to be low. Please refer this for more details about the logic levels.

For the ultrasonic sensor to work, Input can be 3.3V, and if the output of echo pin is 3.3V or less we can read it on our SLabs-32 board too. A potential divider network can be used to bring down the voltage of echo pin output to 3.3V making it readable by SLabs-32. to bring down 5V to 3.3V we can use a combination of 1K and 2K (two ones in series) resistors as shown in the hardware connections below.

Step 3: Hardware Connections

Please refer to the schematic attached here and make your hardware connections as is.

Ultrasonic sensor to SLabs-32:

  • VCC --------> 5V
  • Trig ---------> PD7
  • Echo ---------> PD3 (From the voltage divider network as shown in the figure)
  • Gnd ---------> Atmega_Gnd

Servo to SLabs-32:

  • VCC ---------> 3.3V
  • Gnd ---------> Atmega_Gnd
  • Signal ---------> PD2

Please consider using a small piece of perfboard, solder 4 pin female berg onto the perfboard and bring out the 4 wires out for your convenience to plug into the SLabs-32. By soldering a female berg, you can plugin and out ultrasonic sensor at will. This perfboard will then need to be hot glued onto the horn of the servo and place the horn onto the servo knob appropriately.

Step 4:

Step 5: Just Dump the Code Already...

Code here is mostly self explanatory. There are two important libraries that we are using that needs a mention. Servo library available at Arduino's official website, lets us control the servo as needed. A graphic library developed by bodmer that is very fast and is being used for developing the visual content for this application.

Step 6: And!!! We Are Done.

The final visuals are as shown above.

Good job if you have followed it and got it working. You are free to use code, schematics and pictures as is or with some modifications in your projects under MIT opens source licensing. Let us know what you are up to in return, we'll be happy to listen and help in any way possible.

See you in the next tutorial.