My adventures with a Raspberry Pi and Arduino programming

I’ve now got all communication channels working on the Arduino Pro Mini just as I had on the Raspberry Pi (aka Ralph) and the Gertboard…

I successfully got the onboard I2C working – interestingly WITHOUT pull up resistors included in the circuit… I’ll have to check that out in future to see if that increases power draw.

Also proved now that the Wire I2C library works fine with software serial and hardware serial. Here’s why I need all of them:-

Hardware serial: Printing data to host – in future a 3DR 433MHz radio using MavLink protocol framing.
Software serial: Read GPS position every second
Wire I2C library: Read 3D magnetometer (compass) data

Had to do a couple of interesting hacks for this, as shown in this Gist.

Don’t delay!

Adding a hard delay causes the software serial library to NEVER be able to read data! Don’t do it! I’ve left it commented out, but in the code, to remind me.

Don’t continuously read compass information

Although I’ve put the compass (The HDL5883L chip) in continuous mode, reading it continuously seems to block software serial from functioning.

So I’m now just taking a reading when the GPS has a new reading – better in the long run for power consumption anyway.

The HDL5883L chip and I2C

This chip is the compass on the Airbot UBlox GPS Module 2.0. It requires you to tell it the register you want to read from or write to before every request. Hence the sending of a message to the I2C bus BEFORE performing a read.

Think of this like visiting the right mail box before opening it to deposit or pick up mail.

A good intro for how this, and I2C in general, works can be found on the Sparkfun website (where else!?!)

For a full list of modes of this chip (there’s some great stuff you can do in there!) go search for the PDF datasheet and hardware integration guides. They contains ALL the information you need for the Wire library calls.

In summary

Really quite easy to do! Even easier than using ioctl in linux on the Raspberry Pi, which is nice!

Next steps: Get that LCD display working… honest…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: