This tool controls a TP-Link smart outlet based on the status of a magnetic sensor. This repo is meant to install the Adafruit-WebIDE on a Raspberry Pi to make it easier for new programmers to edit code on the Pi-Zero. It includes steps to configure a smart outlet and use a Python script using the web IDE. The installation instructions are Mac OS specific but can be translated to other operating systems.
-
Insert SD card into the Mac card reader
-
Open the
finder
app and change the name of the SD card toboot
-
Install the Raspberry Pi Imager on your MacOS
-
Open the Raspberry Pi Imager application
-
Use the command strokes
command-shift-x
to open the advanced option menu. At the time of this writing, it is required to use the advanced option menu to configure Wifi. See this blog post for more information. -
**Note**
If you are using Wifi to connect the Pi-Zero to the internet follow this step. If not then skip this step. Use theConfigure Wifi
section to enter your Wifi SSID and password. Note: Raspberry Pi Zero only supports 2.4GHz. -
If configuring more than one Raspberry Pi on a network use the
Set hostname
setting to configure a unique hostname for each Pi -
Do not select "Eject media when finished"
-
Click the
SAVE
button -
Select the
Raspberry Pi OA (32-bit)
option and the SD card storage options -
Write the OS to the SD card
-
After the RPi Imager has finished writing to the card open the
terminal
application and run the following commands. This will copy installation scripts to allow the Pi to install and configure the web IDE automatically.cd /tmp git clone https://github.com/andrewmarklloyd/pi-sensor-light-demo.git cd pi-sensor-light-demo/install/ ./configure-boot-drive.sh
-
At this point the SD card is fully configured and can be safely ejected
-
Insert the SD card into the Pi and power it up. After a few minutes the installation will complete and you can navigate to http://
hostname
.local:3000 in your web browser to view the Web IDE, using thehostname
you set when writing the pi.
On your smartphone download the Kasa Smart
app.
Follow the setup instructions in the app to connect the smart outlet to Wifi. Note the Kasa Smart Plug requires a 2.4Ghz WPA2 password protected Wifi network.
Connect one jumper wire to GPIO 18 and the other to a ground pin.
In the Web IDE, create a new filed named main.py
and copy main.py into it.
- Raspberry Pi 3 but any Raspberry Pi will work
- Kasa Smart Plug Mini
- Surface Mount Alarm Magnetic Contact
- If using ethernet instead of Wifi: Ethernet Adapter