6hearts
Posts: 16
Joined: Sat Dec 26, 2015 1:25 pm

Camera could not initialize when I set of a buzzer.

Sun Dec 02, 2018 5:14 pm

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?

gordon77
Posts: 3609
Joined: Sun Aug 05, 2012 3:12 pm

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

Mon Dec 03, 2018 11:08 am

I would assume 3 is the problem. You need an interface eg transistor to run the buzzer from 5v

6hearts
Posts: 16
Joined: Sat Dec 26, 2015 1:25 pm

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

Mon Dec 03, 2018 7:58 pm

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.

Return to “Camera board”