using pine64 gpio to control a 120VAC light bulb

I’ve used gpio on various SBCs to drive small signal relays  on a few projects, but never any high-current, high-voltage stuff.  The principle is exactly the same, I just hadn’t used it before.  The elegoo 37-sensor kit I just got had a handy break out board for a 10A 250VAC relay.  I used a gpio line on a pine64 to drive the relay coil using a PN2222A transistor circuit.  The script is no different than blinking an LED.

pine64 gpio driving a 10A 250VAC relay circuit using a PN2222A NPN transistor to provide ground

 

 

pine64 turning on and off light bulb
perl script for pine64 relay control

Next, I controlled the relay by reading the voltage drop across a photo resistor voltage divider using an MCP3004 10-bit ADC.  When the OP code from the ADC rose above 400, the light comes on (because it is dark).

Controlling a relay by reading the voltage drop across a photo resistor using an MCP3004 ADC
Controlling a relay by reading the voltage drop across a photo resistor using an MCP3004 ADC

Leave a Reply

Your email address will not be published. Required fields are marked *