5

I recently bought a compressor and now I want to be able to turn it on and off programmatically using my Raspberry Pi Model B.

Since I know nothing about electronics, it seems like the safe option would be to do to not mess with mains power but to switch the power on or off after the adaptor where the voltage is lower.

This is the adaptor:

Power adaptor

And this is the sticker on the compressor:

Power adaptor

Assuming I'm a programmer who knows nothing about electronics, how can I switch the power on or off using Python or preferably C on my Raspberry Pi?

PS. I don't mind the cost of buying equipment. If there's a solution that costs more but requires less work, that is preferable.

6

You'll need just two things:

Make use of the GPIO pins

Using the GPIO port of the Pi is possible with numerous libraries for all significant languages. Finding one that interfaces well with Python or C is no trouble at all. Just have your pick, e.g.

Use a relay to control the 12V power line

A simple transistor is sufficient to drive a small relay from the Pi's GPIO pin. Just pick a relay that supports more than 2 A, but that should not be a big deal. Or go for one of the custom addon boards for the Pi, e.g. the PiFace.

  • 2
    Another interesting product is piface digital which has a number interfaces built in---including 2 relays. – Tyson Nov 14 '15 at 20:21
2

For the relay just go to amazon and search (JBtek 4 Channel DC 5V Relay Module). It is $6 and a lot easier then trying to wire it up yourself. Also I would suggest (T Cobbler Plus 40 Pin GPIO Expansion) that way it easy to connect to the pi and if you pi dies you just plug in a new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.