I’ve been trying to get the Swan to sleep using CircuitPython (NoteCarrier-F), but I’m seeing two different behaviors: 1) With the ATTN DIP switch set to ON, the code just drops through the Transaction, and 2) With the ATTN DIP switch set to ATTN, it hangs a while, then throws an exception (Failed to aquire I2C lock). This is with a simple
If you are communicating with the Swan using CircuitPython, I assume you have a USB cable plugged into the Swan? If so, then the Notecarrier F will NOT be able to power down the Swan as it is receiving power from your computer. Additionally, the I2C transactions are failing because the I2C bus is also impacted by the ATTN pin being set to LOW by the card.attn command.
To use card.attn with sleep mode, you SHOULD have the ATTN DIP switch set to ATTN. If you want to observe the powering down behaviour, you should use an external Serial to USB cable connected to the UART pins of the Swan (F_RX & F_TX on the header). Only power the Notecarrier F via the USB connector on the Notecarrier itself, NOT the Swan.
If you do not have a Serial to USB cable, you could also observe the behaviour by turning on the LED on the Swan from CircuitPython when you press the USER button and then after X seconds have passed, issue the card.attn command with the mode: sleep param as you shared. The LED should turn off due to the power being cut (the EN pin of the Swan is pulled low by the ATTN pin of the Notecard).
Wow, Thanks for clarifying why I was seeing the behavior I was seeing. Everything is working way I planned it now. If the notecarrier is getting usb power, I do not try to sleep, Otherwise I try to sleep after a period of no motion determined by my environment variables, and wake up periodically as a heartbeat or from motion.
Blues has to have the best customer service I’ve ever seen! Thanks.