Imp001 Electric Imp - April Development Board with VOC sensor

We have an Imp001 Electric Imp connecting to a VOC sensor.


sensor manual:

I tried to read from the sensor using one of the following addresses. I either get -2, -6, -10 error.

Please help out.

Description of the wiring.

Ground → Ground
3v3 → 3v3
Here is the picture of the devices.

const BASE_I2C_ADDRESS = 0x5A;
local local_addr = BASE_I2C_ADDRESS << 1;
const SUB_I2C_ADDRESS = 0xB5;
local local_subaddr = SUB_I2C_ADDRESS << 1;
local i2c = hardware.i2c12;
local cmd=0x05;
server.log(,"", 2));

local error=i2c.readerror();
if (error!=0) {
server.log("Error= "+error)

You probably want

server.log(, "\xB5", 2));

Also, you should probably set a timer to take the readings after five minutes

imp.wakeup(300, function() {
   server.log(, "\xB5", 2));

I tried that and it’s returning -2 as an error.

Have you soldered the wires instead of leaving them just resting in the pin holes?

No, do you think it would make a difference?

Yes… I think it will make a huge difference in reliability.

We just tried it and it is still the same.

Check out

A -2 suggests you have the wrong device address.That said, you seem to have correctly converted the 7-bit 0x5A address to the 8-bit value (stored in local_addr), but you don’t need to convert the sub-address (ie. the register address), which is why I used the literal \xB5 in my code above). I also missed a comma, which I have corrected.

However, the data sheet says “Bus master clock stretching support is required”, and I don’t think the imp supports this mode. That right, @hugo?

I would try using pins 8/9 for I2C in case you have a socket with a flaky pin1 (we saw this a few years back with some april/imp combinations).

I checked the “air quality 2” click schematic and it has pull-up resistors on it, which was going to be my other suggestion for things to check.

@smittytone’s suggestions aren’t correct here; the device is read only, you should not specify any subaddress as it has none.

server.log(, "", 2)); // the address on the bus, as it's a read transaction, will be 0xb5

…should return 2 bytes, which the IDE would probably show as hex. If it returns null then yes there has been an error and you should print the error.

Re. read-only device and sub-addresses, good spot and thanks for putting me right.