navigationGo.pngQuick Navigation
allprojects32.pngAll projects
hardware32.pngHardware
links32.pngLinks

favoriteStar32.pngTop projects
Alan numitron clock
Clapclap 2313/1386
SNES Pi Webserver
USB Volume/USB toys
Smokey amp
Laser cutter
WordClock
ardReveil v3
SNES Arcade cabinet
Game boy projects
cameleon
Home Presence Detector

github32.pngGitHub
AlanFromJapan

navigationMail.pngContact me

alanfjmail.png
3flags.pngWho's Alan?


Akizukidenshi
Elec-lab
Rand Nerd Tut
EEVblog
SpritesMods
Switch-science
Sparkfun
Suzusho
Datasheet Lib
Reddit Elec
Ermicro
Carnet du maker (fr)
Marutsu
ATmel blog (defunct)

raspipower

Target (following the Raspi GPIO fun) is to be able to turn off a Raspi with a tact switch AND cut the power (for real). This means I use a little uC (ATTiny10) which sends the shutdown signal to the Raspi (like done on the SNES Web server) and then closes the relay to cut the power completely. You will just feed continuously the uC which can be tuned to have a microscopic power consumption.
Target is to use that in my Bedside mood companion project but more on that later...

Presentation

Principle

An in place programmable ATTiny10 watches for a button press: on press close the realy (turning on the Raspi) and on another press sends a signal to Raspi (see the Raspberry Pi shutdown python script) then waits for ~30sec to turn off the power for real by opening the relay. Simple as they come.

Issues

Version 1.0

I am a f#$&ing idiot, I wired the version 1.0 as the relay closed by default and I used the wrong part for the HK4100F relay so you can't use it with that HK4100F relay. Need to cut some tracks and airwire it to work with the big F4052 relay ... I feel stupid.
At least it's fixable and it works fine with the big ass relay now.

Need to do the following:
  • A trace cuts on the PCB front: there's space, should be ok.
  • Some airwire to connect the incoming USB VCC to the right relay pin as well as the top part of the circuit
  • Version 1.2

    I skipped the v1.1, this one should work with both relays, and I implemented the HK4100F component in my homemade library.

    Implementation

    Bill of materials

    MandatoryPartValueDevicePackageDescription
    MC110uFCPOL-EUE2.5-5E2,5-5POLARIZED CAPACITOR, European symbol
    MD1DIODE-D-5D-5DIODE
    J2CONN_05X2PTH2X5
    J3CONN_031X03
    J4CONN_031X03
    J7CONN_05X2PTH2X5
    J8CONN_05X2PTH2X5
    JINCONN_02LOCK_LONGPADS1X02_LOCK_LONGPADS
    JIN1USB_MINI-B_SMTUSB_MINI-B_SMTUSB-MINIBUSB type Mini-B Connector
    JIN2USB_MICRO-B_FEMALE-SMTUSB-B-MICRO-SMDUSB Type Micro-B Connector
    JOUTCONN_02LOCK_LONGPADS1X02_LOCK_LONGPADS
    JP1JUMPER-SMT_3_NO_SILKSMT-JUMPER_3_NO_SILKNormally open jumper
    JP3JUMPER-SMT_3_NO_SILKSMT-JUMPER_3_NO_SILKNormally open jumper
    JSPIPROGAVR_SPI_PROG_3X2PTHAVR_SPI_PROG_3X2PTH2X3AVR ISP 6 Pin
    IK140524052F4052RELAY
    LED_POWER2LED-FKIT-1206FKIT-LED-1206LED (Generic)
    NPNOR12SC2120-NPN-TO92-ECBTO92-ECBNPN Transistror
    NPNOR22SC2120-NPN-TO92-ECBTO92-ECBNPN Transistror
    MNRELAY2SC2120-NPN-TO92-ECBTO92-ECBNPN Transistror
    R11kR-EU_0207/2V0207/2VRESISTOR, European symbol
    R21kR-EU_0207/2V0207/2VRESISTOR, European symbol
    MR31kR-EU_0204/70204/7RESISTOR, European symbol
    R410kR-EU_0207/2V0207/2VRESISTOR, European symbol
    R510kR-EU_0207/2V0207/2VRESISTOR, European symbol
    R61kR-EU_R1206WR1206WRESISTOR, European symbol
    S1MOMENTARY-SWITCH-SPST-PTH-6.0MMMOMENTARY-SWITCH-SPST-PTH-6.0MMTACTILE_SWITCH_PTH_6.0MMMomentary Switch (Pushbutton) - SPST
    MU$1ATTINY10ATTINY10SOT23
    IU$2HK4100F-DC5VHK4100F-DC5VSMR1HUIKE (Fujitsu) subminaiture relay
    Mandatory status:
  • M: mandatory
  • I: pick one or the other, no difference (Beware: board v1.0 works only with F4052 relay, only from v1.2 both relays type are properly accepted)
  • Schematics



    Variants

    JP1
    By default it can be left opened. Leave all opened if use the OR resistor pair below.
  • JP1-A: close this to pull up the reset pin
  • JP1-B: close to connect pin PB3 (/RESET) to the Raspi GPIO13, used as PI_IS_ON: should be set as HIGH 5V when the Pi is running. Can be used only if the /RESET pin is overriden disabled, meaning you won't be able to reprogram the chip after

  • JP3
    By default you should close JP3-B to enable simple control of the relay transistor NRELAY.
  • JP3-A: close this to enable the OR circuit
  • JP3-B: connects ATtiny10 pin PB2 to the relay's NPN transistor for the simplest scenario

  • OR Circuit
    A transistor based OR that drives the relay's transistor by implementing "uC pin PB2 OR GPIO13". GPIO13 is PI_IS_ON and should be HIGH when the Raspi is running.
    One idea is that if the script makes PI_IS_ON HIGH as long as the Raspi runs, and the uC pin PB2 is high the relay will be closed. And when turning off, the tiny sends DATA-DO_SHUTDN to turn off the Raspi, and keeps the relay on for 30 sec. So as long as the uC consider it should keep the Raspi powered (=until shutdown button pressed and notified +30sec) OR the Raspi says "I'm running" (the PI_IS_ON GPIO) the relay will stay closed.

    Source code

    Board

    Source code on my GitHub.

    ATTiny10 micro-controller

    On my GitHub based on ATTiny10 microcontroller.

    Pictures


    The assembled version with its big ass relay

    Top side of the board

    Initial circuit for my own version of a PowerBlock

    The v1.0 of the board ... with its bug :(

    Links

    Helpful sources

    Inspiration

    All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated)
    electrogeek.cc ~ Formerly known as Kalshagar.wikispaces.com (AlanFromJapan [2009 - 2017])