Disclaimer: The posts in this "Ultrasonic Sensors" category are primarily a reference for myself during this project. However, I suspect some of the things I discover will be of use to others doing similar projects, so I will make them public.
Today I started putting things together for the ultrasonic distance sensor project. Here is a brief overview of the end result.
Three battery-powered sensors will measure distance, and transmit their data wirelessly to a receiver box. The receiver will interface with a computer via a serial-usb interface. The device appears as a regular serial port, but is connected via a USB cable. I am using the Arduino platform to create the devices.
The actual sensor is this module. I am reading its PWM output rather than interfacing serially. I am using this wireless module to link the devices together.
What makes this project a little more interesting is that I accidentally ordered the surface-mount versions of the ATmega168 chips! So now I am going to learn to solder surface-mount devices, and build a custom PCB for the devices!
Below is my progress made today.
Task: Read the PWM values from the sensor module into the computer.
Overall, went pretty smoothly. Using the Arduino board and the sensor, wired everything up, and it went all according to plan.
Task: Build a standalone arduino, so that I can start testing the wireless connectivity.
Since I have only one arduino board, I need to wire up the ATmega168 chip on a breadboard so that I can eventually get two of them connected wirelessly.
I followed this guide to wiring an arduino on a breadboard. I got everything wired up, and then decided to test the serial port.
I wrote a small program which just counts up by 1 every half second and writes that number to the serial port. Here is where I encountered my first minor setback. I was seeing random characters coming out the serial port instead of sequential numbers. My first (and correct) guess was that it was a timing issue. Although the ATmega168 is rated to run at 20mhz, apparently the crystal on the Arduino board is actually 16mhz. By using the crystal from the real Arduino board instead of my own 20mhz crystal, everything works perfectly. The USB interface and Arduino need to be in sync. So I can't use my standalone Arduino with the USB port until I get my hands on some 16mhz crystals.
Todo: Link the serial connections of two Arduinos with a wire, and test sending data between them. Then replace the wire with the wireless module.