# how do I automatically power off the raspberry pi and cut power every night and then power it back on each day?

Background

I'm a student working on research project to develop a remote wireless sensor network of data loggers. Each data logger (aka node) is going to be retrofitted to a bird feeder that reads the RFID tag of any bird that visits that feeder. Every read is going to be sent via our LoRa network to a gateway and eventually stored in a database.

Question Context

Our pi's are going to run off of battery, meaning, we need to conserve as much power as possible. Since the birds we are researching (chickadees) mainly feed during the day we do not need to run the pi at night. Our goal is to only run the pi during the day. We considered using a photoresistor but would prefer to use something more reliable. We need the pi to turn on at least an hour before daylight to catch early feeders and we don't want the photoresistor to get covered by the snow (we get a lot of snow!). right now our best option seems to be setting up some type of separate circuit between the pi and the battery using a combination of the following: RTC, Microcontroller (looking at the Adafruit Trinkit), Solid State Relay, or some kind of Timer IC. I have absolutely zero experience with managing power or using RTC's, SSR's, or Timer IC's and am having trouble finding a viable solution to our problem.

Lastly, it is important that we are able to shut down the pi safely! We cannot just cut the power because that will damage the SD card.

I understand this is a pretty specific question but if anyone has encountered a similar problem before or has some potential ideas I would really appreciate any help I can get! Thanks!

Tech Specs

Our nodes are currently equipped with:

• Raspberry pi zero W
• Dragino LoRa Module
• RFID sensor
• Weight sensor
• DC-DC converter

• Your question is perhaps specific, but solutions on battery stuff is very general. You might like to read the following posts to get a rough idea of what other guys are doing: (1) RpiZW Weight Sensor Project raspberrypi.org/forums/… (2) Switching On/Off LM2596 PSU raspberrypi.stackexchange.com/questions/96247/… / to continue, ... – tlfong01 Sep 21 at 1:04
• (3) Watchdog Timer and LM2596 PSU raspberrypi.stackexchange.com/questions/99584/… (4) Lead Acid Batteries raspberrypi.org/forums/… (5) Lipo Power Bank and Lead Acid Batteries UPS raspberrypi.org/forums/… – tlfong01 Sep 21 at 1:11
• I do not have hands-on experience with RFID readers, so take this with a grain of salt. Unless there is some part of your project that absolutely requires a (comparatively) power-hungry Raspberry Pi, you might want to consider a MCU board with LoRa and RFID capabilities. They often can be powered with a LiPo battery and you can easily program the board so it will automatically power down to sleep (or deep-sleep) mode during night time (or any other time you like). For example, Pycom makes a LoPy4 MCU board which has a LoRa module and which can be combined with a PyScan shield equipped with a R – yesno Sep 21 at 6:13

You have asked many questions - this site works best if you ask a single question (otherwise you will get lots of speculative answers, but often none from experienced users).

it is important that we are able to shut down the pi safely!

To safely shut down the Pi run the following command:-

sudo poweroff


To detect WHEN the Pi has shut down include the following in config.txt:-

dtoverlay=gpio-poweroff


This will assert a voltage on GPIO (default 26) when safely shutdown

Unfortunately the Pi continues to consume significant power, even when shutdown, so you will need to provide external circuitry to cut power.

GPIO pin 26 can be used to control power circuitry. You will need to provide your own circuitry to startup.