• lets get talking

    moosepr10/19/2017 at 13:41 0 comments

    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!!

  • ITS ALIVE!!!

    moosepr09/15/2017 at 09:56 2 comments

    so I eventually got round to building the board, and started testing the software side of things. After a very disappointing start (ws2812b + heat = no light!) I eventually got it running some basic code.

    A few hours later and some searching, I have some basic switching going on. Its a mash up of random example code and a neopixel library all in arduino code (I can hear the screams from here). We have some basic functions:

    • On first power up, the board just goes straight to sleep.
    • On pressing the button, the neopixel flashes for 5 seconds, the colour indicative of the voltage 4.2v = green - 3.3v = red, with a combination of the 2 in between.
    • If the button is not still pressed at the end of the flashing, the board goes back to sleep
    • If the button is still pressed, the FET is activated, and the neopixel shows a steady indicator of voltage (same green to red system as before)
    • While the FET is on, if the button is held down for 2 seconds, the FET will be switched off, and the board will go to sleep

    Im sure the code is shockingly bad, but its a start

    https://github.com/moosepr/TinyFET/blob/master/tinyFET.ino