microchip-pic-avr-solutions / mcp9808_arduino_driver

Other
3 stars 1 forks source link

wake from power down not working properly #2

Open andrewwootton opened 10 months ago

andrewwootton commented 10 months ago

I set up the AVR IOT Cellular to send via MQTT every 5 minutes and use PowerSaveMode between readings of the MCP9808 and volts. After it had been running for a while I noticed the temperature reading was constant. The code uses Mcp9808.begin(); in the setup loop and wake() and shutdown() in the loop. So I think the wake command is not working as designed. I used a workaround of putting begin() into the loop followed by delay(1000); and this is working. Hope this helps and you can look into it, Happy to supply my code if this would help. Andrew

voelkerb commented 5 months ago

@andrewwootton I know I am bit late to the party but I experienced the same issue. The cause is a copy and paste error in the wakeup function. SDHN bit 8 is not cleared correctly. Replace this line by

regWrite16(POINTER_CONFIG, reg & ~(1 << 8)); // Clear bit 8 (SHDN)

and everything works as expected. Also see the PR I created.