OPT3001 read not working #1766
Replies: 10 comments
-
Posted at 2018-05-30 by @gfwilliams It looks like a bug in the OPT3001 module, which I have now fixed. If you re-upload the code hopefully you won't get that error any more. However it looks like the module itself hasn't been tested, so I'm afraid it may not work for you even it it does run. Let us know what happens though - it looks promising from the numbers it is printing, so I may be able to make some tweaks at this end to fix it if it is broken. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-30 by Sestre I looked for the librairie for the OPT3001 module (https://www.espruino.com/modules/OPT3001.js), and i saw a strange think :
EDIT : 2 minutes too late =D |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-30 by Sestre 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 : 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 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-30 by @gfwilliams Hi, Looks like the module itself is definitely not good then! Thanks for poking around. This won't work, because it's just writing 8 bits:
Try
It might work after that? Getting the result data should be easy enough, something like:
might work? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-30 by Wilberforce You might want to try pull-up resistors or set the pins to pull up in the module? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-31 by @yerpj Pull-ups are not the problem, in this case. If this was the case, a timeout would occur on I2C (both if pull-ups are missing or if the slave did not respond) and would therefore be notified in the console |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-31 by @gfwilliams I think the issue is the fact I wasn't handling 16 bit writes correctly. I have just uploaded some new code - can you try now and see if it's better? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-31 by @yerpj It works! (tested by my colleague) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-31 by @gfwilliams \o/ great news! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-06-06 by Sestre I confirm : It's working, thank for support ! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-30 by Sestre
Hello,
I'm not sure about how to read the OPT3001 sensor's data and i didn't find a lot of documentation. Here my code and the error i have on output.
My code :
Output :
The module is right connected and seems ready (led on). Can someone help me ?
Beta Was this translation helpful? Give feedback.
All reactions