Page 1 of 1

Camera could not initialize when I set of a buzzer.

Posted: Sun Dec 02, 2018 5:14 pm
by 6hearts
My pi camera stops on my RPI zero working when I execute the code:

Code: Select all

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(23, GPIO.OUT)
GPIO.output(23, GPIO.HIGH)
I've got my active buzzer (those small round black ones) connected directly to pin 23 and GND. The buzzer starts, but the camera then fails to init.
I can see three reasons:
1) The picamera module does not like it when I set the mode to GPIO.BCM
2) Pin 23 messes with camera pins?!
3) The buzzer draws too much power and the camera stops working.

My testing would suggest that the camera only fails if the buzzer is actually plugged in, so option 3) seems to be the right one...
Oh, I also see that the buzzer is 5V, should it be a problem if I power it with the 3.3V pin?
Is there a simple solution? Plug in a resistor?

Re: Camera could not initialize when I set of a buzzer.

Posted: Mon Dec 03, 2018 11:08 am
by gordon77
I would assume 3 is the problem. You need an interface eg transistor to run the buzzer from 5v

Re: Camera could not initialize when I set of a buzzer.

Posted: Mon Dec 03, 2018 7:58 pm
by 6hearts
Ah, nevermind. I think I found the problem.
I was initializing the camera inside a library which I used in a program running in the background.
But when I was setting the pin to high, I included this library, so two processes were accessing the camera...

sorry.