The project demonstrates how to create a smart plug that can be controlled by an IoT device and that can retrieve information from the cloud. The smart plug can be used to turn lights ON and OFF.
Adafruit IO Settings
We will be using Adafruit IO for creating a switch on the cloud. Follow the instructions:
- Create a new Feed named Light.
- Create a new Dashboard named Light Control.
- Edit the Dashboard and add a Toggle Block.
- Connect the Light feed to the block and click on Next Step.
- Edit the Block Setting and click on Create Block.
- Block is added. You can try to toggle the switch.
- Go to the Light feed. You will observe the value of the feed changing as we click on the switch on the Dashboard.
The bulb is connected to the smart plug which is controlled with a relay.
If the relay is ON, the smart switch gets ON, turning on the light. The relay has the following connections:
- GND Pin connected to GND of the Quarky Expansion Board.
- VCC Pin connected to VCC of the Quarky Expansion Board.
- Signal Pin connected to Servo 4 of the Quarky Expansion Board.
The logic is the following – We’ll connect to the Adafruit IO account, fetch the switch state from the cloud, and use and if block to turn the relay on or off accordingly.
IoT Enabled Smart Plug Upload Mode
You can also make the IoT Enabled Smart Plug work independently of PictoBlox using the Upload Mode. For that switch to upload mode and replace the when green flag clicked block with when Quarky starts up the block.
You can download the code from here: IoT enabled Smart Plug – Upload Mode