So the circuit for TinyFET is actually acting as the power circuit for my Clicker project, and so im developing on both projects at once!
After some trawling of the internet I have managed to piece together some i2c functionality. Even though the voltage of the tiny will fluctuate from 4.2v to 3v, the communication to an i2c host is actually pulling the lines to gnd, and the pi is providing the pullups, so it should be safe.
Im planning on having 3 registers available to allow comunication
0x00 - voltage will be here in a 2 digit byte, so 3.7v will be represented as 37
0x01 - status is here, im thinking of a 4 status system that will be detailed below
0x02 - sleep timer, the pi will be able to trigger a countdown to power off, so on shutdown it can set this register
The status only really need a few simple options
0 - the power is on, but we have not had an i2c read yet, so assume the pi is booting
1 - the pi has made a read, so everything is normal
2 - the power button has been pressed, so lets get ready to tell the pi
3 - the pi has triggered the sleep timer, countdown to poweroff
The sleep timer will just be a simple countdown that will kill the power and put the tiny to sleep once it hits zero
The pi will have some code running, which will ping the tiny at regular intervals to check the status and the voltage. I have considered modifying the code created by @hoolyhoo which actually puts a battery status on the screen, and can trigger safe shutdown.
The only shortcomings i see in this setup is that there will be a delay between pressing the power button and the actual triggering of the shutdown. This can be adjusted by altering the delay between i2s reads. The pi could maybe read the status once a second, and the voltage once every 10 seconds (the voltage wont change quickly!!)
Onwards and upwards!!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.