Code and wiring for I2C-It IR rangefinder?

Has anyone got the I2C-It IR Rangefinder from HVW Technologies working with an Arduino? I tried the …\Ardunio\hardware\libraries\Wire\master_reader\master_reader.pde example but can’t get any meaningful data out of it.

Thanks,

yea I need some help with this too!

I haven't had any luck with the wiring library either. I'll post my findings here though.

-Rob

  • Get 2 x 1.8k resistors
  • Wire one to A4
  • Wire the other to A5
  • Wire a vcc to the base of both resistors, at the intersection where each resistor meets the analog pin(s)
  • SCL wires to the resistor on A4
  • SDA wires to the resistor on A5
  • GND wires to GND
  • vcc wires to vcc

Each device has “an address”, and that’s decided by the user when they’ve soldered the address table.

I don’t have a HVW Tech i2c ranger finder, so the rest you’ll need to figure out from trial and error.

HVW sell BoArduino’s, so they might already have code and a circuit.

awesome thanks!

I found the Arduino sketch on HVM's site, good call. It wasn't there about a month ago. But is now! http://www.hvwtech.com/products_resources.asp?CatID=0&SubCatID=0&SubSubCatID=0&ProductID=665

I haven't tried it out yet but I'll be posting the results for sure!

-Rob

  • Get 2 x 1.8k resistors
  • Wire one to A4
  • Wire the other to A5
  • Wire a vcc to the base of both resistors, at the intersection where each resistor meets the analog pin(s)
  • SCL wires to the resistor on A4
  • SDA wires to the resistor on A5

I read somewhere that the Arduino board has built-in pull-up resistors... or is that only true for the mini?

It's not the board, the ATmega8/168 have internal pullup resistors. Write a 1 to the pin while in input mode to enable them.

-j

Upon further research, it seems that

pinMode(pin, INPUT);

Is actually what activates the internal resistors, not writing a 1 or 0 to the pin itself.

I don’t see that in the code, but I only took a quick look.

The data sheet says this:

If PORTxn is written logic one when the pin is configured as an input pin, the pull-up resistor is
activated. To switch the pull-up resistor off, PORTxn has to be written logic zero or the pin has to
be configured as an output pin.

I’m not sure at the arduino level who’s doing what to who, but at the hardware level, you’ve got to set it as an input and then write a one to it in order to activate the pullup, so sayeth the ATmega48/88/168 datasheet section 12.2.1.

I did dig around in the TWI code, and found this:

    // activate internal pull-ups for twi
    // as per note from atmega8 manual pg167
    sbi(PORTC, 4);
    sbi(PORTC, 5);

So, for TWI/I2C, the pullups are enabled.
-j

I know that if you have a large I2C network (or a long enough run) you need to use a couple of pull-up resistors paired to your power supply in order to give your sensors (or BlinkM's in the case I'm talking about) enough current to power the sensors and the network.

Yeah, the internals probably don't provide enough current for a big network. I can't find that spec at the moment, but as outputs they can provide a max of 40mA.

-j