Maybe some power issue?
What power adaptor are you using?
Maybe some power issue?
What power adaptor are you using?
If I want just to start rpi only do I need to add the dtoverlay=gpio-shutdown to config.txt. and 1 maybe stupid question - where is this config.txt file on pri4
To power up, all that’s required is to connect physical pin 5 (BCM 3) to the ground next to it. This functionality is enabled by default.
To shut down with the same button, just add the line dtoverlay=gpio-shutdown
to /flash/config.txt
config.txt
is read only
to edit ssh
then to make it read only again
True for the reboot and shutdown. In fact I am using the Kodi app on the phone as a remote control but for the activation I can not use it
So you said just shorting pin 5 and 6 will start rpi( you mean GPIO3 and GND)??? Directly shorting them with nothing else?
Yeah thats what I mean gpio3 and the gnd across it...you add dtoverlay=gpio-shutdown to config.txt..
Your explanations are very useful. I was thinking to implement such a button on my Pi4 BUT I was thinking... What if the power button is with IR for the regular TV or Bluetooth from the phone. Is this possible to be done? I think this will be just a bit better for usage
Thanks again for your explanations!
That will be usefull just for startup if it works...basically reboot and shut down are the same as the ones you r using now from Kodi power menu..so you can set the remote buttons even without switch..
Just a quick idea is a transistor between pin 5 and 6 and an ir receiver connected to it...basically if you short pin 5 and 6 rpi will start.
You just edit script and restart to try with 50% to 100% but you dont really have to..if fan is working all should be fine
If you want to try change values just ssh systemctl reload fan.service or stop and then start service
Thank you!
speed steps in script are low so you dont see much difference by looking at the fan
tempSteps = [30, 35, 40, 45, 50, 55, 60, 65, 70, 75] # [°C]
speedSteps = [0, 35, 45, 50, 55, 60, 70, 80, 90, 100] # [%]
try to change the steps and you ll see a big jump from 50% to 100%
something like:
This way it jumps from 50% straight to full throttle
How can I verify that the speed fan is temperature controlled? I am looking at it and speed seems the same all the time
Post #74 I posted a small script calibrate.py
That is similar script to the one on #60 but works manually from terminal instead of reading temperatures...it's just for testing and to find your fan minimum speed...mine started at 30%...less then that and it wont turn...
You can test fan with that script from terminal....you type 50 will be 50% speed..100 will be 100% speed and so on...
Display More2 pin 5v fan
I made a circuit with 2n2222 transistor and 1k resistor I use the following circuit
Temperature Controlled Fan for Raspberry Pi 4 - Fizzy
but I would like to use your script from #60 because of the speed control
I just change the fan file from the link above with your script from #60 and now intend to turn it on
Seems I made something wrong(either circuit, either places for the script, .. or something else) as I turn it on but the fans are not starting
Did you connect transistor base to the proper gpio?
I have a great request:
Can you sum up 1 working solutions with all the steps needed in your first post as the topic is interesting but it is going longer and longer.
The topic is growing and in 1 part we have scripts, update in another, after there is script with variable speed and for me it is a bit confusing
Thanks in advance!
What are you planning to do?
2 pin 5v fan ?
Script in post #60 works fine for PWM temp/speed control..
You just need to make circuit..
Well although power button works as intended..unfortunately it doesn't work if system is for some reason frozen..so it might still need a dirty power shutdown once in a while..
Led On - Start - Quick Press Restart - Long Press Shutdown
#!/usr/bin/python
# shutdown/reboot(/power on) Raspberry Pi with pushbutton
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO
from subprocess import call
from datetime import datetime
import time
# pushbutton connected to this GPIO pin, using gpio 3 (pin 5) also has the benefit of
# waking / powering up Raspberry Pi when button is pressed
shutdownPin = 3
led = 13
# if button pressed for at least this long then shut down. if less then reboot.
shutdownMinSeconds = 3
# button debounce time in seconds
debounceSeconds = 0.01
GPIO.setmode(GPIO.BCM)
GPIO.setup(shutdownPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led, GPIO.OUT)
# Switch LED on.
# LED will switch off automatically at shutdown by using normal GPIO state.
GPIO.output(led, True)
buttonPressedTime = None
def buttonStateChanged(pin):
global buttonPressedTime
if not (GPIO.input(pin)):
# button is down
if buttonPressedTime is None:
buttonPressedTime = datetime.now()
else:
# button is up
if buttonPressedTime is not None:
elapsed = (datetime.now() - buttonPressedTime).total_seconds()
buttonPressedTime = None
if elapsed >= shutdownMinSeconds:
# button pressed for more than specified time, shutdown
call(['shutdown', '-h', 'now'], shell=False)
elif elapsed >= debounceSeconds:
# button pressed for a shorter time, reboot
call(['shutdown', '-r', 'now'], shell=False)
# subscribe to button presses
GPIO.add_event_detect(shutdownPin, GPIO.BOTH, callback=buttonStateChanged)
while True:
# sleep to reduce unnecessary CPU usage
time.sleep(5)
Display More
Just been to the local shop to get the switch.
So after some research managed to get it sorted..
Led,Start,Restart and Shutdown all in one..
short press is restart..long press is shutdown..press from off will switch on..
Now gonna test it for a few days...happy to share script if anyone wanna test..
Thanks for your reply..
That's a shame.
So if I understand correctly..
connections are gpio 3 and ground for switch and gpio 13 and ground for led..no transistors involved to run led?Perhaps it might need a resistance?Is there enough power in gpio 13 to run LED?
Does this work incase LE is frozen?
I mean is it only sending a clean shutdown command?
Does a long press do a reset?
Might need the reset button through the RUN pins for reset..
If you connect the card to a PC, the "storage" folder (see instructions) will become the "STORAGE" partition.
With the infos you gave so far, I can't provide a solution. I don't know whether you copied the script folder into the storage folder, nor do I know which pins are used by your hardware. A circuit diagram and / or an example script by the manufacturer would help.
PS: If you can't access the "STORAGE" partition on PC (Windows), use the PC program PuTTY to copy from PC to RPi.
I know it's not the point of this thread but all you can access from a windows PC is /flash directory..
Nope. Doesn't work. Sorry but I'm a completely noob and don't know what to do. The instrauction manual is good, but I think there are some points which need to be more clearify, because I don't have a folder with name "storage".
I think Da Flex means to access the storage from your PC and not from the micro sd card attached to the PC unless you have a linux pc...
It works ...! I `m so stupid... I shouldn't be counting pins at 2am at night ... Since I connected a fan to pin 4 and pin 6, I didn't see that I didn't connect pin1 and pin2. So I tried to make the connection between pins 7-8 instead of 5-6
Thx for your help !
By the way ... is it possible to reconnect the fan to a other Pin which is shut down if I´m in the shutdown mode ? Maybe I have to add something in that script.
Glad you r sorted...fan doesn't have to be full trottle...it should work fine on 3.3 just a little slower...or do what Da Flex recommended...you can also use same circuit for PWM Fan setup..works fine on RPI..
satfan The code looks OK, I'm using the same import. Maybe you are using wrong apostrophe signs at the sys.path.append line.
script seems to hang on line 4
That shouldn t be on line 4 if you copied the script I showed you...looks like you r still loading your first script listen-for-shutdown.py without the rest