What’s the best way to control a power outlet with a RPi? I’m really not sure how it’s meant to work, but conceptually, I’m sort of thinking that my RPi will be plugged into a power board, and I want to control the switching on and off of another outlet on that board. In short, I’m trying to control a light, and the light is plugged into a power outlet.
While some of our parts are rated for that use, we recommend that those decisions are made qualified technicians that are licensed to work with mains power. That goes for the work itself, it is a legal requirement anyhow.
To wrap-up: Mains power isn’t just lethal. It’s lethal.
Stay safe & keep to low voltage projects. Or employ a contractor to help.
Personally i would just grab a smart home wall switch, that way your aren’t messing with 240v at all.
A good way to go about it is to use a remote controlled GPO relay. Purchasing a commercial 433MHz, IR, or WiFi activated relay is a great way to do it.
That way, the mains voltage side of things is all taken care of by engineers who sign their lives away that it’s safe for consumer use, and you can just work with hacking together something to reproduce the control signals to your liking, which allows you to stay safe by only working with ELV components.
The relay just takes in a voltage to control it - how you supply that voltage is up to you. You’ll need to combine a few principles to get a system that works for your purpose. Here’s some handy tutorial links:
And a few on different methods of communicating with a device remotely (you can then send a signal to a device to switch the relay):