Go to advanced search

by bananaboat
Thu Apr 08, 2021 1:06 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

So you are not using any of the code I posted but something you have put together yourself. So exactly what code are you running and how does it not work. I tested the code you posted. Both on my test setup (with just jumper cables) that worked as it should, and on the 'production' setup which did ...
by bananaboat
Thu Apr 08, 2021 6:43 am
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

If something is wrong with the resistors than why did it work in my previous setup? It doesn't compute... I am not saying some thing has gone wrong with the resistors. On your test bench you have short cables and you are using the built in 50K pull up resistor. Now you have moved to the actual real...
by bananaboat
Wed Apr 07, 2021 7:28 am
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

So what resistors are you using , for cable runs of 2-3 meter you should really be using external pull up resistors as the software pull up will not be sufficient, you ground should be provided from the pi, not via a ground from somewhere else. may be you need to read about pull ups on this site fo...
by bananaboat
Mon Apr 05, 2021 7:59 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

On the test setup it works smoothly. On the IRL setup the button does not respond. Cables are about 2-3 meters long including resistors. Could it be the time.sleeps? So are you sure you have the switch with the external resistors wired correctly for a pull up like you had in the code , if you are u...
by bananaboat
Mon Apr 05, 2021 7:26 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

On the test setup it works smoothly. On the IRL setup the button does not respond. Cables are about 2-3 meters long including resistors. Could it be the time.sleeps? Ps. my previous code (cam temporarily time out) I used this (that worked fairly good) import RPi.GPIO as GPIO import time GPIO.setmode...
by bananaboat
Mon Apr 05, 2021 3:53 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

pcmanbob wrote:
Mon Apr 05, 2021 3:32 pm
This would be another way of doing it
...
This way you only execute the loop once for each press and release of the button , and switch the camera on or off just the once,
It would also stop the camera from flip flopping form on to off if you kept the button pressed.
Great!
by bananaboat
Mon Apr 05, 2021 3:48 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Re: Execute file only once after status change in loop

You need to add some logic so that once the file has been called once the logic changes to prevent it being called again. like this ( note untested ) You could apply this to the whole bit of the code after each if statement , so it only sets the outputs, runs the file and prints once. a few tiny ty...
by bananaboat
Mon Apr 05, 2021 2:02 pm
Forum: Python
Topic: Execute file only once after status change in loop
Replies: 21
Views: 1120

Execute file only once after status change in loop

I have a script that does what it needs to do. Push button change the status and turns of the camera until it is pushed again. However the loop keeps executing the external file even when it is not necessary. Is there a way to have the external file been executed once until the status change? import...
by bananaboat
Sat Feb 20, 2021 6:17 pm
Forum: Python
Topic: What am i missing in my py code
Replies: 5
Views: 294

Re: What am i missing in my py code

This works, but i assume it is not the way how it should be done :lol: #!/usr/bin/python import RPi.GPIO as GPIO import time #GPIO SETUP water = 7 pump = 14 GPIO.setmode(GPIO.BCM) GPIO.setup(water,GPIO.IN) GPIO.setup(pump,GPIO.OUT) def callback(water): if GPIO.input(water): print ("Te droog...&...
by bananaboat
Sat Feb 20, 2021 5:52 pm
Forum: Python
Topic: What am i missing in my py code
Replies: 5
Views: 294

Re: What am i missing in my py code

The only thing i am missing is that once if GPIO.input(water): is True it runs down the script only one time. But i should check after xx seconds and rerun if it is still True...
by bananaboat
Sat Feb 20, 2021 5:27 pm
Forum: Python
Topic: What am i missing in my py code
Replies: 5
Views: 294

Re: What am i missing in my py code

seems like mixed up
GPIO.output(pump,GPIO.LOW)
GPIO.output(pump,GPIO.HIGH)
by bananaboat
Sat Feb 20, 2021 5:24 pm
Forum: Python
Topic: What am i missing in my py code
Replies: 5
Views: 294

Re: What am i missing in my py code

no mention about indentation.

I am running the script in python2. Brackets are required in python3 (correct me if i am wrong).
by bananaboat
Sat Feb 20, 2021 3:02 pm
Forum: Python
Topic: What am i missing in my py code
Replies: 5
Views: 294

What am i missing in my py code

Goal is straight forward. No water detect will activate the relay for x seconds and than turns off. Separately the work as expected. Combined they don't (i tried several things) #!/usr/bin/python import RPi.GPIO as GPIO import time #GPIO SETUP water = 7 pump = 14 GPIO.setmode(GPIO.BCM) GPIO.setup(wa...
by bananaboat
Sun Jan 31, 2021 11:59 am
Forum: Troubleshooting
Topic: Correct GPIO <-> capacitor <-> resistor order?
Replies: 7
Views: 463

Re: Correct GPIO <-> capacitor <-> resistor order?

If the GPIO is an input to the RPI my order would be: GPIO - resistor - cable | capacitor | GND plus a pullup or pulldown resistor on the GPIO pin. I would not expect to need such a large capacitor that a polarised type would be appropriate. What value capacitor would you go for? And the capacitor ...
by bananaboat
Thu Jan 21, 2021 6:08 pm
Forum: Troubleshooting
Topic: Correct GPIO <-> capacitor <-> resistor order?
Replies: 7
Views: 463

Re: Correct GPIO <-> capacitor <-> resistor order?

WhyNine wrote:
Thu Jan 21, 2021 5:25 pm
  • Uni- vs bi-directional data
What would be the case of GPIO?
by bananaboat
Thu Jan 21, 2021 12:04 pm
Forum: Troubleshooting
Topic: Correct GPIO <-> capacitor <-> resistor order?
Replies: 7
Views: 463

Correct GPIO <-> capacitor <-> resistor order?

Interference on longer cables connected to GPIO pins does have quite an impact on the stability when it comes to false positives. But what is the correct order in order to place them? And what thresholds would be recommended? Obviously, it depends of the many external factors. Using a better insulat...
by bananaboat
Wed Jan 20, 2021 1:55 pm
Forum: Troubleshooting
Topic: "python script.py &" does not continue
Replies: 1
Views: 114

Re: "python script.py &" does not continue

Deleting GPIO.cleanup() in led.py did the trick.
by bananaboat
Wed Jan 20, 2021 1:46 pm
Forum: Troubleshooting
Topic: "python script.py &" does not continue
Replies: 1
Views: 114

"python script.py &" does not continue

Hi, I have a doorbell script and after some debugging i discovered than problem wasn't in the hardware (cables or knob) but in the software. I write a line of code in the /etc/rc.local for scripts that need to be active continuously, like so: python /home/pi/script.py & However after one run it ...
by bananaboat
Tue Jan 19, 2021 7:19 pm
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

my bad. I will try the resistors.

Fun fact. Plugging the COB LED driver into another power outlet fixed the false positives. Strange, that is has so much impact.
by bananaboat
Tue Jan 19, 2021 4:24 pm
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

The internal pulls are not very strong (about 50K), I'd use a stronger external pull-up. Maybe a 10K resistor, but you could go as high as 1K if needed. I assume you mean: maybe a 1K but could go as high as 10K? No, I meant what I said. 10K is a stronger pull than 50K, but not as strong as 1K. 10K ...
by bananaboat
Tue Jan 19, 2021 1:31 pm
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

rpdom wrote:
Tue Jan 19, 2021 1:23 pm
The internal pulls are not very strong (about 50K), I'd use a stronger external pull-up. Maybe a 10K resistor, but you could go as high as 1K if needed.
I assume you mean: maybe a 1K but could go as high as 10K?
by bananaboat
Tue Jan 19, 2021 1:07 pm
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

I suspect the action you need to take to solve both problems is to read up about pull-ups and pull-downs on GPIO inputs. I tested on my test setup throughout and worked correct (with short jumper cables). Problems occur when IRL environment with regular (and longer) cables. I ran into several GPIO ...
by bananaboat
Tue Jan 19, 2021 8:56 am
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

I suspect the action you need to take to solve both problems is to read up about pull-ups and pull-downs on GPIO inputs. I tested on my test setup throughout and worked correct (with short jumper cables). Problems occur when IRL environment with regular (and longer) cables. I ran into several GPIO ...
by bananaboat
Tue Jan 19, 2021 8:47 am
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

Re: GPIO interference

LTolledo wrote:
Mon Jan 18, 2021 9:29 pm
very elementary....

dont use the COB driver....ever!
Why?
by bananaboat
Mon Jan 18, 2021 8:59 pm
Forum: Troubleshooting
Topic: GPIO interference
Replies: 14
Views: 366

GPIO interference

I have 2 pi's running. A raspberry 3B+ and a model A version. The first is used as a doorbell. GPIO pin 6 (ground) and 8 (GPIO14). The cable is 1 meter long and on beginning of the cable, connected to pin 8 i have added a capacitor 1uF. It works once, than 24-48 hours it does not register any trigge...

Go to advanced search