What kind of cat loves raspberry?
…actually I know one, who is a huge fan of Raspberry Pi…it’s CHOCOLATE from the ConfigCat team 🙂
- Raspberry Pi 2/3 with:
- ConfigCat python SDK
- (‘GPIO Zero’ integration to any hardware) - optional
- ConfigCat subscription (free plan is enough :))
Step 0. – Prepare the device to run your code
I use my board with Raspbian OS but you can use any distribution. I prefer it because it (usually :)) contains all necessary components for my pet projects. Read more about Raspberry Pi OS installation here.
Install ConfigCat SDK with pip:
install gpiozero libs
By default the Raspbian desktop image contains the GPIO Zero package. On a different OS, you’ll have to use PIP:
Step 1. – Set up your ConfigCat projectLog in to ConfigCat
- Create a feature flag
- Copy your SDK Key from the
Step 2. – Code
Create a file (e.g. remoteswitch.py) with your favourite editor (I prefer nano) and implement the following code:
In line 9 you should add your own SDK KEY. This solution uses the ConfigCat SDK’s in manual polling mode. (Read more about polling modes here).
Step 3. – Test
Run your code with the following:
Depending on the value of setting the program prints the actual value of your switch on the ConfigCat Dashboard and turns on/off the OutputDevice as well.
Step 4. – Demo
For the demonstration I created a simple circuit.
The components I have used:
- LED diode to show the switch status
- one resistor to limit the current (500Ω)
- two wires to connect to GPIO#3 port and a ground
- Raspberry Pi to serve power to the LED (you won’t need external power supply)
Step 5. – Further development possibilities
- Set up a program as a daemon (always run, after reboot)
- Apply this solution with any wireless power switch on your home