In the DS3231 control register byte 0Eh bit INTCN is correctly set, but bit A1IE clear. They should both be set to enable the alarm.
Posts by idk2069
-
-
Thanks chewitt.
Also LE9.2 would set the system time from hardware RTC on boot-up. LE10.0.1 doesn't on this setup.
-
Hi,
I got LE 9.2 to wake a Raspberry Pi 2 from halt for a TVHeadEnd recording using this circuit with a DS3231 RTC module: Circuit to wake Raspberry Pi from halt for a recording using DS3231 RTC
Updated to a Raspberry Pi 4 with LE10.0.1 and this no-longer works. It does correctly set the alrm_time and alrm_date to just before the recording, but doesn't enable the alarm, by not setting "alarm_IRQ : yes".
Output from cat /proc/driver/rtc
rtc_time : 13:14:14
rtc_date : 2022-02-06
alrm_time : 15:11:00
alrm_date : 2022-02-06
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1
max user IRQ frequency : 64
Any ideas please?
-Ian
-
Warning: following this guide risks destroying your Raspberry Pi
Hardware, the complicated bit
It is possible to wake a Raspberry Pi from halt using one of the DS3231 RTC modules that you can buy widely on the internet:
But requires some electronics knowledge and soldering directly to pin 3 on the above IC.
The DS3231 will pull and hold pin 3 low (if LibreElec/Kodi is set up as in the software section below) this is used to pull pin GPIO3 low to wake the Raspberry Pi from halt using the following circuit:
Input “RTC” in the circuit above connects to pin 3 of the RTC and output “PowerOn” connects to GPIO3. The monostable U1 limits the wake up pulse on GPIO3 to 100ms so that the Pi can still communicate to the RTC on GPIO3 & 2, to disable the current wake up alarm and set the next one.
The components ringed in red allow 5V from a TV USB port to also wake the Pi up, with C2 limiting this to a pulse of 25ms into the monostable input on TV power-up. This is so that if you are watching something else other than Kodi the RTC can still wake Kodi up for a recording if Kodi halts with the TV on. These components can be omitted if this isn’t required.
Switch A & B go to a momentary push button switch that allows the Pi to be woken without turning the TV on, to set up recordings via a web browser on TVHeadEnd. The switch simply connects them together when pressed.
Although I used a SN74LVC1G123DCUR (as I had one, see below) the SN74LVC1G123DCTR is slightly bigger and hence easier to solder (I used a protype PCB)
In the above pictures the red/black wires go to the TV 5V USB connector and the thicker green/yellow wires to the momentary wake-up switch.
Software, the simple bit thanks to the open-source community
Based on: DS3231 Real Time Clock installation guide for RPi / /LE8
and: https://raspberrypi.stackexchange.com/questions/1238…he-raspberry-pi
In the Kodi Settings/System/Power saving (in advanced or expert modes) set Kodi to halt after say 2 hours of inactivity.
To configure wake up, ssh into LibreElec:
mount –o remount,rw /flash
To end of /boot/config.txt add:
dtoverlay=i2c-rtc,ds3231,wakeup-source
mount –o remount,ro /flash
Verify local system time with the ‘date’ command. If local time is off, either adjust it manually or connect your Pi to the Internet and wait for the correct time from an NNTP server.
Transfer local time to RTC: hwclock –w
Verify RTC time: hwclock –r
See when next wake-up time: cat /proc/driver/rtc
(although it may require shutting down using Kodi then waking again for the wake-up time for the next recording to be correctly set)
Increase USB ports current output to 2.3A
To power/use two WD 5TB 2.5” hard drives and a Hauppauge WinTV USB Dual HD TV Tuner (to watch record TV via TVHeadend) directly from a Raspberry Pi 2B the USB current limit needs increasing. By following:
More Power For Raspberry Pi USB PortsSince the Raspberry Pi 2 was released, everyone building RetroPi emulators has been graced with four USB ports. For those of us doing useful stuff with the Pi,…hackaday.comI changed R50 to be 10K and removed R4 to be safe on the Raspberry Pi. This sets the USB current limit to be typically 2365mA, not the 2100mA stated in the above link.
Although not mentioned in the Hackaday article to get the extra power the 5V power supply input will either need to be connected straight to the Pi Header, pins 4 (5V) & 6 (0V) by soldering the wires directly to the connector to avoid voltage drops across connectors. Or by removing Q3 and U14 (reverse power connection protection) from the Raspberry Pi and shorting across Q3 as ringed in red below. This link is the 5V input with 0V the wire to the far left below. Using a 3A Raspberry Pi 4 power supply to power the Raspberry Pi 2B used, requires only 0.5W in during sleep/halt and about 3W running (both measured at the 240VAC mains, and hence includes the PSU power usage).
Power-On LED
Taken from: RPi4 GPIO using in LibreELEC
Install the Raspberry Pi tools add-on (from Kodi interface: Add-ons --> Install from repository --> LibreELEC add-ons --> Program add-ons --> Raspberry Pi tools)
Create /storage/.config/autostart.sh :
#!/bin/sh
(
python /storage/scripts/status_led.py
) &
Create /storage/scripts/status_led.py :
#!/usr/bin/python
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO
led_gpio_number = 27
# Use BCM pin numbering (i.e. the GPIO number, not pin number).
# WARNING: this will change between Pi versions. Check yours first and adjust accordingly.
GPIO.setmode(GPIO.BCM)
# Switch LED on. LED will switch off automatically at shutdown by using normal GPIO state.
GPIO.setup(led_gpio_number, GPIO.OUT)
GPIO.output(led_gpio_number, True)
Finally reboot the system and the chosen output should go high, allowing an LED to be connected (with a series resistor, I used 1K5 for a dim LED)
Complete system:
The case was made using 1.5mm sheet aluminum; and a cheap manual metal bending/folding machine brought from ebay.
Measured Power Usage for Raspberry P 2B
0.77mA no Pi, just extension leads neon light @233VAC
14.7mA booting = 3.25W
11.2mA running showing just EPG both drives spinning = 2.43W
10.7mA running showing just EPG with one 5TB drive spinning = 2.31W
10.2mA (guesstimate not measured) running showing just EPG with no drives spinning = 2.20W
3.0mA asleep = 0.52W
Note all power calculations exclude the neon light’s power usage.
Testing
The extra power for the USB hard drives has been successfully used for over 4 months without the shutdown/wake feature. The shutdown/wake and power LED features have been successfully used for the last week over Christmas, with no recordings missed.