I just started using an imp with a custom impee, but I’m having issues getting i2c communication up and running. I haven’t ruled out issues with my hardware, but the circuit is pretty simple, so I think it’s unlikely. Also, when I hook an o-scope up to the SCL and SDA pins, I’m not seeing any signals, which suggests that I have something configured incorrectly.
Here’s the code I’m using:
`imp.configure(“Test resistor”,[],[]);
hardware.i2c12.configure(CLOCK_SPEED_400_KHZ);
local AD5245_ADDR = 0x2D;
local result = hardware.i2c12.write(AD5245_ADDR, “\x00”);
server.log(result);`
The “write” function always returns -2, even though the docs say the only options are 0 and -1.
Any suggestions for troubleshooting would be greatly appreciated!
The sparkfun breakout board socket exacerbates issues with pin1 on some imps - specifically, the pin9 contact spring bends the imp pcb up and causes pin1 to sometimes not make contact.
This doesn’t happen on the imp breakouts, or on all imps. If you contact info@electricimp.com we can swap your imp out for you.
Hmm…that would definitely explain my problem. Is there an easy way to hack the imp to improve the contact? Or do you recommend just sending the imp back?
Hi jsiegle,
I also made my boards based on Sparkfun’s board. I have a issue with nvram being cleared on wake up from deep sleep. Have you already checked nvram with your boards? I hope you don’t have problem with this.
I’m also having some difficulty with i2c. pretty new to this - coming from arduino world.
I’ve looked through the new and old documentation on i2c library and read up a bit on the net. I think I understand the gist of i2c - master activates slave, slave acknowledges and then streams some bytes, waits for next instruction.
Presumably this is because the imp i2c library assumes 7bit addressing and does a >> 1 on the address you provide. Other i2c hardware I have seen expects the MSB of the i2c address from a chip’s spec to be aligned in bit.
The << 1 worked for me. Maybe it should be fixed in the library? Opinions?
also call i2c.read and i2c.write with address << 1
Last week I helped someone debug an MSP430 I2C circuit and one of the problems was the address from the spec needing to be >> 1 before writing to the address register.
Is this just common knowledge when using I2C libraries?
Thanks, the <<1 worked for me on my Sparkfun breakout board. I am talking to a BlinkM. Before adding this shift to the address I was getting a -2 on i2c89 and i2c12.
After adding the shift i2c12 still returned -2, however i2c89 worked.
I’m trying to connect couple of i2c sensors to Imp and everything works out well when only one sensor is connected. When I add another sensor to the bus hardware.i2c89.write starts to return -1.
Philmy mentioned that he adds the error codes to the documentation but at least documentation of i2c.write does not contain any error code specification. Are those codes specified somewhere else?