Monday, April 1, 2013

Arduino 16*2 LCD, Ultrasonic Sensor, and Temperatur Sensor

OBJECTIVE

It has been a while since I've done some work hobby work with the Arduino prototyping microcontroller. I decided its time to dig out my kit and build something and reacquaint myself. Something simple to start, yet new.

Main Components

  • Arduino Uno 
  • HD44780 16*2 LCD display
  • SR04 Ultrasonic Range Sensor
  • LM335 Temperature Sensor

Design


Working with an LCD display can make things simpler. Generally, I used the LCD display to display sensor information but it can also be used to display the stages of the code written running. This comes in handy for debugging and gives me the option of not having to rely on the serial monitor.

Unfortunately, the LCD display takes up a lot of pins on the Arduino board, just look at tutorial here.
The solution; I bought an IIC serial mondule to act as the interface between the Arduino and LCD display. The LCD display now only requires two pins, the serial port on the the Arduino, A3 and A4.

Well now that I have the LCD display working after some trouble finding the correct libraries, I need to find some information to output on it. This is where  the ultrasonic range sensor comes in. They're pretty easy to work and generally pretty accurate. A line of code to to make the calculation for distance given time it takes for the ultrasonic wave to bounce from the emitter to receiver and speed is all that's needed.

distance = (duration/2) / 29.1;

As you can see, that's pretty close. My tests indicate the accuracy starts to decrease when distance sense reaches above 1m despite the manufacturer says its good for up to 4.5m. Maybe I need to fine-tune my code a bit or there's some interference.

Now that I have the distance sensor working and the LCD, there a number applications I can think of just by adding more lines of code and maybe a button or two for user input.
  • Door Alarm/Greeter
  • Motion Detector
  • Height Finder (through the use of triangulation)
Now I have one more component to add, the temperature sensor. The voltage output of the sensor scales linearly with ambient temperature, so calibration would be pretty simple. For this quick project, I didn't bother. Since I wanted a portable device, I added a power supply module for my breadboard as well.

A few more lines of code and some time wasted troubleshooting the code only to discover the problem was a lose wire, here's the result:

I'm have not come up with any ideas for applications for a device needs both the temperature and distance, but it's great to see everything working as intended. If I push my creativity further and spent a few hours writing some code, I'm sure I can find a few interesting applications for these two sensors. I should probably calibrate the temperature sensor though, 70 degrees is way off.




No comments:

Post a Comment