Code Monkey home page Code Monkey logo

pi-sensor-light-demo's Introduction

pi-sensor-light-demo

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.


Installation

  • Insert SD card into the Mac card reader

  • Open the finder app and change the name of the SD card to boot

  • 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 the Configure 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 the hostname you set when writing the pi.

Configuring the Smart Outlet

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.

Connecting the Sensor

Connect one jumper wire to GPIO 18 and the other to a ground pin.

Running the Application

In the Web IDE, create a new filed named main.py and copy main.py into it.


Required Hardware

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.