Hey all Programming Gurus!
Right, before you all swear at me: I already asked this question on the MikroC forum, and they can’t help. The reason I am posting here, is because I have seen far more examples of interfacing a MAX44009 lux sensor using Arduino than I have seen any other uC and IDE, and so I’m hoping that someone here may have seen or worked with this sensor in the past.
I need to interface a MAX44009 to a PIC24FJ64GB002 microcontroller and display the lux reading, continuously (at a refresh rate of 100ms), in real-time, on an LCD. I am coding the system using the dsPIC MikroC IDE.
Now before you all swear at me again - I am not expecting anyone to learn a new library, I suspect that there is an issue with the C code and this question is aimed specifically at people who have worked with this sensor before.
I do not want to enable the interrupt setting of the sensor IC, I just want to read the lux value on the LCD every 100ms.
The code compiles without error or warning, I am just concerned that I have configured it incorrectly. The sensor package is the GY-49, and I suspect that the address pin is high (A0) thus you will note different slave address to the typical MAX44009 code already available on Github. I have tried the slave address with A0 low, and still no response. If you are familiar with the GY-49package, you will know that only the VCC, GND, SDA, SCL pins are labelled, and the INT and A0 pins are not. So I have no idea which pin is A0. So it’s a bit of a guess, but both slave addresses don’t work.
I’m worried that I have coded register 0x02 and register 0x03 incorrectly. I think this is a code issue, not a library issue, and so anyone who’s worked with this sensor might be able to spot the error quickly.
Please could you take a look at the code attached. I have included the datasheet for quick reference.
I measured the SCL and SDA lines on the oscilloscope, and both pins are just high all the time (3.3V) and yes, there are pull-up resistor attached. But it seems like there is no communication.
I would really appreciate any and all assistance.
Much love peeps, and thanks for reading.
MAX44009 code.zip (517 KB)