I2c to BlinkM

Trying to control a blinkM over i2c.

I’ve been trying to use the 0x00 i2c address to broadcast but i’m not sure how to emulate the arduino code below.
they have separate command for each byte. also i’m unclear on what ‘format("%c%c", addr>>8, addr&0xff)’ this is meant to do.

Can anyone help. thanks nick

local addr = 0x00;

i2cPort = hardware.i2c89;
i2cPort.write(0x00, format("%c%c", addr>>8, addr&0xff) + 0x6f);
i2cPort.write(0x00, format("%c%c", addr>>8, addr&0xff) + "c “+0xff +” “+0x00+” "+0x00);

ardunio code
addr = 0x00;

Seems like this is now working

i2cPort.write(0x00, format("%c%c", addr>>8, addr&0xff) + format(“c%c%c%c”, 0x00, 0xff,0x00));

Looking at the manual .

3.1.1 I2C Addresses
The default BlinkM address is 0x09. It can be changed at any time with the “Set Address”(“A”)
command described below. BlinkM responds to both its defined I2C address and the “general
call” broadcast address (0x00).
The general call address can also be used to address all BlinkMs simultaneously, as most all
BlinkM commands do not return a value (which is not allowed when using general call). The
use of general call may not work on I2C networks with other devices that also use general call.
See “4.1 I2C Addressing” under “BlinkM Concepts” for more information about how BlinkM
handles I2C addressing

So I think your 0x00 is wrong unless you are trying to change the BlinkM address.

Note also that this:

i2cPort.write(0x00, format("%c%c", addr>>8, addr&0xff) + format(“c%c%c%c”, 0x00, 0xff,0x00));

…is better written as this:

i2cPort.write(0x00, format("%c%c\x00\xff\x00", addr>>8, addr&0xff));

…as you’re creating one string and using “\x” to put constants in there.

So I’ve build this setup too … except that I can control the red, green and blue LEDs with a html form.
I’ve used a BlinkM MaxM and a Sparkfun breakout board, powered with a 3.7V lipo battery. The BlinkM is connected to vin and gnd.
Here’s the .nut, .html and .php https://gist.github.com/4111064
I’m pretty sure it’s not the best code out there.

(inspired by the Hannah HTTP Color example - please, release some more Hannah boards)

Thanks for sharing the code!

I have a really inexpensive diffused RGB LED (Sparkfun, 10mm) that works great on the Imp as well. Plugged in my BlinkM to see if there was much of a difference. On the whole, I think I prefer the RGB LED over the BlinkM (I’m not chaining together any LEDs, just the one). The only thing might be brightness, so I’ll have to check out the MaxM.

When you say that you powered your setup with a 3.7V battery, is that for the MaxM, or the Imp? I assume the 3.7V is going to the breakout board, and your running the MaxM off the 3.3V provided by the Imp. Do you still get good brightness off the MaxM? The datasheet says it can run up to 12V, and I wasn’t sure if it would be as bright with just the 3.3V.

I was using the Sparkfun April board. The battery was connected to the board and the MaxM was powered through GND and VIN of the board. If I’m not mistaken that should have been 3.7V.
The brightness was more than enough.