Sensor graphing with 3 lines of code!

I’ve been looking for simple ways to graph the data from a sensor attached to a microcontroller lately, because it’s such a necessary activity if you want to look at sensor data over time. Using Apples Grapher program, which comes with OSX, I found a simple way that involves only four lines of code on an Arduino or Wiring microcontroller, and produces graphs like this:

graph.png

Continue reading “Sensor graphing with 3 lines of code!”

iPod control from Arduino or Wiring

Rosie Daniel wrote a nice piece of Arduino code to control an iPod. Rosie used a hacked iPod remote to connect her Arduino to the iPod. The remote’s AUD connection is its data in connection, which is connected to the Arduino/Wiring board’s data out. The iPod’s power (VCC) and Ground are connected to the power and ground of the microcontroller. Then this code works.

Thanks to Rosie for writing this:

Technorati Tags: , ,


Continue reading “iPod control from Arduino or Wiring”

XOR calculation for NMEA checksums (GPS protocol)

If you’ve ever seen the serial output of a GPS reader, you’ve seen a mystery string at the end like this:

That’s the checksum of the whole string. NMEA data structure for Global Positioning (GPS) readers has a checksum on the end of each sentence. The checksum is the XOR of all the bytes between the $ and the * in the sentence. For example, if the sentence is this:

$GPRMC,155123.000,A,4043.8432,N,07359.7653,W,0.15,83.25,200407,,*28

then you run a checksum on this:

GPRMC,155123.000,A,4043.8432,N,07359.7653,W,0.15,83.25,200407,,

Here’s a Processing method to calculate the checksum, given the string between the $ and the *:

Technorati Tags: ,


Continue reading “XOR calculation for NMEA checksums (GPS protocol)”

XBee to USB modules

Droids.it has a breakout board for XBee radios, and a USB-to-Xbee board available.

The USB board is nice, because in addition to having a built-in 5V-to-3.3V regulator and indicator LEDs, it’s got all the pins of the XBee broken out on the side of the board. Makes development of XBee projects easier.

The breakout board also has its own regulator on board, making it easy to interface with a 5V project. It’s also got the serial pins broken out to a single row, making it easy to mount on the side of a breadboard.

The prices on both are reasonable for the European market. As the US dollar continues to sink, they’re a bit pricier for US customers, but still reasonable, for now.

Thanks to Rob Faludi and Jeff LeBlanc for testing help, and to Luigi Carnevale for supplying sample boards.

Technorati Tags: , ,

Startup Checks

When you’re making a microcontroller circuit that drives a high current load like a motor or an incandescent light, it’s not uncommon to make a mistake and create a circuit that draws too much electrical energy on startup and causes the microcontroller to reset itself constantly. To debug this, it helps to put a routine in your startup() function so you can see when the microcontroller has started up. For example, I often blink an LED three times in the startup. If the LED blinks three times then stops, I know the microcontroller has successfully run the startup and gone into its main loop. If it blinks constantly, I know the microcontroller is continually resetting, so there’s a problem.

Hans Steiner recently showed me his trick for checking for the startup routine on the Arduino: he writes to the microcontroller’s EEPROM, or permanent memory, and reads back the result. Every time the Arduino resets, it’ll increment the EEPROM value. Since this value is stored even when the Arduino is not powered, you’re going to get a new number each time it’s run.

Thanks to Hans for the code.

Technorati Tags: ,


Continue reading “Startup Checks”

Peak finding in Processing

In a previous example, I showed how to detect a peak in a changing analog value on a microcontroller. This example shows how to do it in Processing, assuming the microcontroller is just sending you binary values from 0 to 255. It graphs the incoming bytes, and when a peak is detected, it draws an ellipse and prints a message in the message pane.

Thanks to Matt Young for helping me debug this.

Technorati Tags: , ,


Continue reading “Peak finding in Processing”