Ok, so i tried with the following code (the result is the same with your library now) but, in deed, it's seems that it doesn't work. The output is always "0" even when i put some light on the sensor. The output for manufacterID and deviceID seems ok and i tried to change the modul sensor with an other one without more success so i don't think the problem come from the hardware.
Code :
var REG = {
RESULT: 0x00,
CONFIG: 0x01,
LOWLIMIT: 0x02,
HIGHLIMIT: 0x03,
MANUFACTURERID: 0x7E,
DEVICEID: 0x7F
};
var adr = 0x44;
var i2c = new I2C();
i2c.setup({sda:B9,scl:B8});
// Config (same as the library - maybe don't work)
i2c.writeTo(adr, [REG.CONFIG, 0b1100110000010000]);
i2c.writeTo(adr, REG.MANUFACTURERID);
print(i2c.readFrom(adr, 1));
i2c.writeTo(adr, REG.DEVICEID);
print(i2c.readFrom(adr, 1));
i2c.writeTo(adr, REG.RESULT);
print(i2c.readFrom(adr, 2));
I think the output is "uninitialized-like" because the values are "0" and "0". We can verifie that by reading 3 bytes (in place of two) with the following code
There is maybe a problem with the configuration. I'm sorry, i don't have time now to more investigations but I'll let you know if I find something in the next few days.
If it helps, here is the result of reading of all the registers
In addition, if i look in the OPT data sheet, the result value is, in deed, on 16 bits but divided as follow :
12 bit (LSB) : real value data
4 bit (MSB) : exposent
Sadly, your library doesn't take care of that and just return the 16 bits value without treatment. It would be nice to have direct the value ready to be read :)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, so i tried with the following code (the result is the same with your library now) but, in deed, it's seems that it doesn't work. The output is always "0" even when i put some light on the sensor. The output for manufacterID and deviceID seems ok and i tried to change the modul sensor with an other one without more success so i don't think the problem come from the hardware.
Code :
Output :
I think the output is "uninitialized-like" because the values are "0" and "0". We can verifie that by reading 3 bytes (in place of two) with the following code
Code :
Output :
There is maybe a problem with the configuration. I'm sorry, i don't have time now to more investigations but I'll let you know if I find something in the next few days.
If it helps, here is the result of reading of all the registers
Code :
Output :
In addition, if i look in the OPT data sheet, the result value is, in deed, on 16 bits but divided as follow :
12 bit (LSB) : real value data
4 bit (MSB) : exposent
Sadly, your library doesn't take care of that and just return the 16 bits value without treatment. It would be nice to have direct the value ready to be read :)
datasheet i found : http://www.ti.com/lit/ds/symlink/opt3001.pdf