An Easter (and (sadly) covid-19 project...
This started as a project for work - I need to record various info (time, temp etc) on a user input.
I wanted battery power - which meant an auto shut off.
So - to demonstrate - I created a thermometer (currently o.o.s. everywhere) - press the button, top left. This connects to a Zero Power switch (NanoTech) - though several YouTube videos display a way how to do similar using a thyristor and a (smaller) handful of discrete components.
This passes the power to a LM7805 voltage regulator which powers the Arduino - in this case a Nano (although my ultimate aim is an ATTiny85 with i2c eeprom and RTC)
The Arduino here powers a DS18B20 sensor using pin D2 as power (gnd is next door for convenience) and D8 as data (there is a 4k7 resistor between them) D6 is connected to the power swicth with a pull up resistor (570kOhm) to give a weak pull-up. Pulling this pin low turns the power (and thus the board) off. Because of the time the Arduino takes to 'boot' up - pulling the pin high takes too long to hold the power on - hence the pull-up to latch the power on after the momentary button press.
Here the temperature (and a 60s countdown) is displayed on an i2c OLED display (thanks to medelec for the conversion code - but why does the one wire component only give raw data ?)
The Arduino is powered for 60s (to give the temperature time to stablise) before shutting off - to be powered by a pp3 or 6 x aa batteries (in the photo it is wired to a bench power supply)
I am tempted to create the smallest component - a PwrPin property and a PowerOff macro!
Martin
Auto Power Off for MCU
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Auto Power Off for MCU
Hi Martin,
Looks like a very nice project there.
ALso nothing wrong with it being small and simple, means there is less to go wrong
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Looks like a very nice project there.
Sounds like an excellent idea, exporting known working code as components is a great way to allow you to easily reuse the code in another future project. If you share here then others can use it tooI am tempted to create the smallest component - a PwrPin property and a PowerOff macro!
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
Ideally we need to do more with this and build some more layers on top to work with the specific sensors etc. I've added this to my listwhy does the one wire component only give raw data ?
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Valued Contributor
- Posts: 1189
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Auto Power Off for MCU
Next step...
ATTiny85 (cheapo board from Banggood - not quite Digistump compatible). I set the fuses for the board to run at 16MHz (set manually in FC - the config options are a 'bit' confusing so I ignored them!) and checked with a 1s 'flasher'
As mentioned - not quite compatible with the Digistump boards - I couldn't get the USB to recognise under windows 10. So used the trusty USBTiny (v1.0) programmer - to program and this works well - found and used automatically by FC.
First a 'feasibility check' = can I get temp and i2c working (and the MCU programmed) - so connected a i2c 128 x 32 OLED display and a DHT11 sensor. Note that a kludge is needed here - the ATTiny doesn't have enough RAM to drive the display. So I changed the 'resolution' to 128 x 16 which worked nicely (with the line of text displayed centrally on the display)
Display connected to PB0 and PB2 and DHT11 data connected to PB3 - and all up and running in record time. So - not as easy to pop under the tongue - but suitable for workplace measurements.....
So: A simple Temp and humidity display using ATTiny85.
Next step - add eeprom and clock (both i2c) - unfortunately I don't have boards with the same pin-outs which would make wiring very easy.
Martin
ATTiny85 (cheapo board from Banggood - not quite Digistump compatible). I set the fuses for the board to run at 16MHz (set manually in FC - the config options are a 'bit' confusing so I ignored them!) and checked with a 1s 'flasher'
As mentioned - not quite compatible with the Digistump boards - I couldn't get the USB to recognise under windows 10. So used the trusty USBTiny (v1.0) programmer - to program and this works well - found and used automatically by FC.
First a 'feasibility check' = can I get temp and i2c working (and the MCU programmed) - so connected a i2c 128 x 32 OLED display and a DHT11 sensor. Note that a kludge is needed here - the ATTiny doesn't have enough RAM to drive the display. So I changed the 'resolution' to 128 x 16 which worked nicely (with the line of text displayed centrally on the display)
Display connected to PB0 and PB2 and DHT11 data connected to PB3 - and all up and running in record time. So - not as easy to pop under the tongue - but suitable for workplace measurements.....
So: A simple Temp and humidity display using ATTiny85.
Next step - add eeprom and clock (both i2c) - unfortunately I don't have boards with the same pin-outs which would make wiring very easy.
Martin
-
- Valued Contributor
- Posts: 1189
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 439 times
- Contact:
Re: Auto Power Off for MCU
Okay - I'd downloaded KiCad a while ago (on Martin's recommendation) so I'll have a go....
In the meantime:
I used a board from Banggood https://www.banggood.com/ATTINY85-Mini- ... rehouse=CN - with hindsight it would have been better to get the programmer board and some loose chips...
I made a 'custom' programmer cable from some header pins to connect to the USBTiny MOSI to PB0, Miso to PB1 SCK to PB2 and RST to PB5 (plus power/gnd to breadboard rails)
The i2c (and rtc (DS3231)) connect to PB0 (SDA) and PB2 (SCL) The RTC board has a 24c32 memory chip onboard.. I haven't tested this yet but the RTC and display both work at 400khz.
No pullups - I think the display I used has one built in https://www.banggood.com/0_91-Inch-128x ... rehouse=UK
I connected the DHT11 data pin to PB3...
Gnd and VCC as required - I'll try and create my own latching power supply (rather than using the zero power board mentioned above) - handful of parts arrived from Banggood ready for testing...
Martin
In the meantime:
I used a board from Banggood https://www.banggood.com/ATTINY85-Mini- ... rehouse=CN - with hindsight it would have been better to get the programmer board and some loose chips...
I made a 'custom' programmer cable from some header pins to connect to the USBTiny MOSI to PB0, Miso to PB1 SCK to PB2 and RST to PB5 (plus power/gnd to breadboard rails)
The i2c (and rtc (DS3231)) connect to PB0 (SDA) and PB2 (SCL) The RTC board has a 24c32 memory chip onboard.. I haven't tested this yet but the RTC and display both work at 400khz.
No pullups - I think the display I used has one built in https://www.banggood.com/0_91-Inch-128x ... rehouse=UK
I connected the DHT11 data pin to PB3...
Gnd and VCC as required - I'll try and create my own latching power supply (rather than using the zero power board mentioned above) - handful of parts arrived from Banggood ready for testing...
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Auto Power Off for MCU
Hi Martin
I have posted information on adding Digikey library here.mnf wrote:I'd downloaded KiCad a while ago (on Martin's recommendation)
Martin