# Timer - 5 min on, 2 sec off

#### maiksebben

##### New Member
Do you mean 2s?
Correct:
5 minutes and 10 seconds for ON-TIME
0 minutes and 02 seconds for OFF-TIME

The 555 doesn't show any trouble with the duty cycle, this circuit works just fine. I tested for several hours, I recorded the length between the ON and OFF cycle. I also recorded the cycle length after pressing the switch (which resets the countdown). I spent hours doing just that, and I didn't have any issued at all. Sometimes the ON-TIME will be 5 seconds more or less, but it's just around 5 minutes and 10 seconds, which is perfect.

#### gophert

##### Well-Known Member
Correct:
5 minutes and 10 seconds for ON-TIME
0 minutes and 02 seconds for OFF-TIME

The 555 doesn't show any trouble with the duty cycle, this circuit works just fine. I tested for several hours, I recorded the length between the ON and OFF cycle. I also recorded the cycle length after pressing the switch (which resets the countdown). I spent hours doing just that, and I didn't have any issued at all. Sometimes the ON-TIME will be 5 seconds more or less, but it's just around 5 minutes and 10 seconds, which is perfect.
Thank you for reporting back. Always nice to see that a project gets completed successfully.

#### crutschow

##### Well-Known Member
Yes, it's nice to know that a proposed circuit works as designed.

#### maiksebben

##### New Member
{message deleted}

Last edited:

#### maiksebben

##### New Member
Sorry I had to delete the last message because I'm having an issue and am trying to find a solution, and I think I had the wrong idea, so I deleted it...

I use two methods to reset the timer countdown, I can send the reset signal using a switch (connected to V+), or, I can send the reset signal using a GPIO out of a Raspberry PI, with the output set to HIGH for 1/2 second.

When the switch is pressed to reset the timer, everything works beautiful, timer goes to around 5 minutes and 30 seconds before resetting. However, when I have the Raspberry PI reset the timer by making a GPIO pin output V+ for 1/2 second, it only takes 2 minutes and 45 seconds to reset. So I must be doing something wrong. Can anybody point the issue so I can try to resolve it? Thanks, Maik

#### maiksebben

##### New Member
By the way, I'm not using any pullup or pulldown resistors on the GPIO, physically or by code. So the GPIO is either high, or low. I make it LOW all the time, and HIGH for 1/2 second only when I want to send that reset signal. I don't know if this information is needed to troubleshoot my problem, but I thought I should mention this.

#### gophert

##### Well-Known Member
Why don't you use the Raspberry Pi to turn on / off for the desired time - it has a real-time clock. You can use the AT command to execute some code at sesired clock times or use Python to toggle a GPIO pin on the Pi.

Your problem with the timer chip is common for the first cycle.

#### crutschow

##### Well-Known Member
What is the actual high voltage output from the GPIO pin?
It sounds like it may not be going to 5V.
If not, a 10k pullup resistor should work.

#### gophert

##### Well-Known Member
What is the actual high voltage output from the GPIO pin?
It sounds like it may not be going to 5V.
If not, a 10k pullup resistor should work.
Good point, Raspberry Pi is a 3.3V cpu.

#### crutschow

##### Well-Known Member
If the Pi only outputs 3.3V then a pull-up resistor won't work..
Will need to rethink the trigger input circuit.

Edit: Okay, I've rethought it.
If the output is only 3.3V, reduce the value of R3 (in the post #3 schematic) from 100k ohm to 10k ohm and see if that helps.

Last edited:

#### maiksebben

##### New Member
If the Pi only outputs 3.3V then a pull-up resistor won't work..
Will need to rethink the trigger input circuit.

Edit: Okay, I've rethought it.
If the output is only 3.3V, reduce the value of R3 (in the post #3 schematic) from 100k ohm to 10k ohm and see if that helps.
Perfect, will give that a try. I think you're right, the output is 3.3v, so that explains it. Will keep you updated. Thanks.

#### maiksebben

##### New Member
Yes that worked perfectly, I can now reset the timer using a GPIO, it acts the same way as if I was pressing the switch, many thanks for that hint.

I'm going to ask something, I hate to ask at this point in time when all is fixed and working, but the only thing I guess I would like to change is, can the timer start ON? Today it begins (as soon as the circuit is powered) with the mosfet off, and then turns on. Can that be reversed, so that when the circuit power is applied, the mosfet starts ON? This means reversing the timer order... I don't know if that can be done... but not a big deal. That's all! Thank you "CRUTSCHOW", you have been very helpful, I would have never resolved it without you!

#### crutschow

##### Well-Known Member
Can that be reversed, so that when the circuit power is applied, the mosfet starts ON?
Never satisfied, huh?

#### maiksebben

##### New Member
Never satisfied, huh?
lol!!! Man you're the best!!!!! I appreciate it, this circuit will be very useful for me, it's 100% perfect now!

#### crutschow

##### Well-Known Member
I just noticed that modification means the first time-out is about 50% longer than those following.
If you want the first period to be the essentially the same as the rest, connect C1 to the junction of R4-R5 instead of ground.

#### maiksebben

##### New Member
Working great with your last suggestion! A++++

-- If you're curious about why I needed this project, here's a bit of info:
I have a Raspberry PI that runs a simple software to control another device, and once a month or so, the RPI freezes, for an unknown reason. My friend who's a programmer looked into this issue and couldn't find any software bug, and we couldn't reproduce the error since it only happens once in a blue moon... we just don't know what triggers this issue. Every time the RPI would freeze, I had to go to the other room to physically reset its power. It was annoying!

Now with this circuit, the MOSFET keeps the RPI power on for as long as the RPI sends a reset pulse signal, indicating to me that the RPI is alive. If the software ever freezes again, the RPI will stop sending the reset pulse signal, and after 5 minutes or so the power will automatically reset! Simple, but VERY helpful! Thanks again my friend!

#### gophert

##### Well-Known Member
Working great with your last suggestion! A++++

-- If you're curious about why I needed this project, here's a bit of info:
I have a Raspberry PI that runs a simple software to control another device, and once a month or so, the RPI freezes, for an unknown reason. My friend who's a programmer looked into this issue and couldn't find any software bug, and we couldn't reproduce the error since it only happens once in a blue moon... we just don't know what triggers this issue. Every time the RPI would freeze, I had to go to the other room to physically reset its power. It was annoying!

Now with this circuit, the MOSFET keeps the RPI power on for as long as the RPI sends a reset pulse signal, indicating to me that the RPI is alive. If the software ever freezes again, the RPI will stop sending the reset pulse signal, and after 5 minutes or so the power will automatically reset! Simple, but VERY helpful! Thanks again my friend!

If you did an upgrade 8nstead of a fresh install, some freezing issues have been reported. A fresh install is always the best option when you want to upgrade the OS.

Second, if the freezing always happens in a fixed time period, you may have a code issue. One example I know, a student was counting things into an unsigned Long variable which they thought would take an eternity so no fear of a roll over. Unfortunately, the variable was updated much more often that the student expected (programming as a team caused a miscommunication) and the variable rolled over in about 4 weeks. The roll over left the code stuck in a loop and we couldn't get any interrupts to end the code or escape. A very patient individual stepped through the code and eventually found the problem - sloppy logic and miscommunication with the team.

#### maiksebben

##### New Member
I just noticed that modification means the first time-out is about 50% longer than those following.
If you want the first period to be the essentially the same as the rest, connect C1 to the junction of R4-R5 instead of ground.
Is there a way to speak to you? I'm new to the site and I tried sending you a message but got an error...

#### maiksebben

##### New Member
I couldn't send a message, so I'll post it here. I just hope I'm not breaking any rules to this website:
--------------------------------------------------------------
The circuit you designed for me is great, would you be willing to make an improvement, and I'll pay you \$ for it?!

CURRENT DESIGN:
The timer you created for me takes care of the "power restart". Once the countdown pulse signal disappears, it indicated the RPI froze or the software in it has quit, and, after 5 minutes or so, the power automatically resets, fixing the issue by itself.

IMPROVEMENT:
I want to know when it happens! My idea was to use another 555 timer that will trigger in bistable mode when the mosfet resets (powers off). I can use a GPIO as input connected to the output of the new 555 timer. Once the RPI power resets and the software is back up, I will know of the state change on that GPIO, and that's exactly what I want! I can then send a ground signal (via another GPIO as an output) to reset the 555 back to its original state.

That's it! If you can draw a new schematic, please let me know how I can reward you. Thanks in advance.