More sensor interfacing with the Bus Pirate

After interfacing the TMP102 temperature sensor recently with the Bus Pirate, the next step on my agenda was to integrate this with the Web Platform along with a HH10D humidity sensor.  Unfortunately I realised a bit late (entirely my fault rushing an order) that although the HH10D was an I2C sensor, the humidity was actually read through a frequency output pin; the I2C EEPROM was only for calibration data.  Bus Pirate to the rescue once again!

This, like the TMP102 is an 3.3V sensor and needs pullup resistors on the I2C bus to read the EEPROM.  I wasted spent a number of hours with this getting nothing but garbage data with the first sensor I tried (the calibration values were completely wrong), on the second try with a backup sensor I had much better luck, getting good results almost immediately.

We’ll be doing a similar setup to the TMP102: using I2C and turning on the power supplies but in this case the AUX pin should be set to HIGH-Z for input/reading.

HiZ> m
1. HiZ
2. 1-WIRE
4. I2C
5. SPI
6. 2WIRE
7. 3WIRE
9. LCD
x. exit(without change)

(1)> 4
Set speed:
 1. ~5KHz
 2. ~50KHz
 3. ~100KHz
 4. ~400KHz

(1)> 3
I2C> c
a/A/@ controls AUX pin
I2C> @
I2C> W
Power supplies ON
I2C> (1)
Searching I2C address space. Found devices at:
0xA2(0x51 W) 0xA3(0x51 R)

Good.  Now if you take a look at the datasheet for the M24C02 EEPROM to do a random address read you’ll need to send a start bit, device select (read only; R/W set to 0), address, then another start bit, device select again (but with R/W set to 1), then read commands.  The HH10D datasheet mentions there are 2 calibration factors we need to read: sensitivity and offset and each are 2 byte integers, making a total of 4 bytes.  These start at address EEPROM address 10.  Using the BP, we do the following:

I2C> [0xa2 0x0a [0xa3 r:4
READ: 0x01  ACK 0x8B  ACK 0x1E  ACK 0x32

This is in big-endian format so the sensitivity value (at address 0x10) reads 0x018B and the offset is 0x1E32.  We’ll also do a frequency read, the first as baseline with my AC running nearby and the second breathing on the sensor:

I2C> f
AUX Frequency:  autorange 7,169 Hz
I2C> f
AUX Frequency:  autorange 6,790 Hz

The formula in the datasheet states the RH = (offset-freq) * sensitivity/4096.  Plugging these in we get 54% and 90.6% RH which seems to match the other humidity sensor in my room.  Success!

Next step was getting this working on my Web Platform.  I have some very bare-bones code working with the TMP102 already, just need to work on the HH10D a bit more and I’ll post my example up here.

Hard drive rotary input device part 2

Been working on a few projects lately and have a number of things I’m hoping to post soon, one of them I got around to briefly documenting is the re-implementation of a hard drive rotary input device – I’m working on hooking up a laptop hard drive to an Arduino/AVR to be used as an input device similar to a rotary encoder only super-sized.  I originally put together a circuit last year which never really worked but now I’ve gotten around to doing it right.  The circuit I implemented was similar to the original Instructable with a few modifications, I tried using the LM324 op-amp called for but didn’t quite work the way I wanted (running from +5V Vcc gave an output ~3.5V instead of being saturated to the full 5V) and tried using a LM339 comparator instead with better success.  The signals can be seen for comparison on my scope in the video.  Right now this just proof-of-concept generating the correct inputs signals to the microcontroller.  Implementation of firmware, a simple circuit to the AVR and brief demo of a more sophisticated output display will follow shortly. Details of the circuit are on the YouTube page and listed below.

The schematic I followed was similar to the one in the Instructable however I removed the 1k series resistors to the non-inverting inputs of the ‘324 and replaced the 10k feedback with 1M’s. The outputs of the LM324 were fed to the LEDs with a series current-limiting resistor. The 339 was similar except it had a 10k pull-up resistor on the output. Both were running off of a single-sided +5V supply and the inverting inputs were tied to ground. The hard drive I used had 4 pins as shown, 3 pins each to separate coils and one common pin which was also tied to ground.


So this is certainly nothing new, but I’ve been unimpressed with the changes made to their interface back in this summer.  They used to have the original bookmark post date stored in a hidden FORM variable when editing in “full-screen” mode.  It was handy to edit so I could sort the bookmarks in my live bookmark RSS feeds.  Now it’s impossible to do so, not fun.  A Google search revealed next to nothing, asides from this one blog entry.  Suggestions would be appreciated. 🙂