Coder Social home page Coder Social logo

lightswitch's Introduction

lightswitch

Lightswitch is a set up that allows you to control your house lights with just a raspberry pi zero! All the set up files are in this repository. simply follow the instructions below.

This set up was made on a raspberry pi zero running raspbian jessie lite, while it may work on other distros, it has not been tested.

Setup

Install the necessary programs

You will need to run the following command to install all the required programs.

sudo apt-get install python nginx php5 php5-cli php5-fpm libssh2-1-dev libssh2-php

Once everything is installed, edit your nginx configuration to allow php. I would recommend you keep a backup of the initial configuration just in case. run the following commands.

cd /etc/nginx/
sudo rm ./sites-enabled/default
sudo cp ./sites-available/default ./sites-available/www
sudo ln -s /etc/nginx/sites-available/www /etc/nginx/sites-enabled/www
sudo nano ./sites-enabled/www

Add index.php where instructed in the file and remove the necessary comments from the php configuration. The final result should look something like this

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
       listen 80 default_server;
       listen [::]:80 default_server;

       # SSL configuration
       #
       # listen 443 ssl default_server;
       # listen [::]:443 ssl default_server;
       #
       # Self signed certs generated by the ssl-cert package
       # Don't use them in a production server!
       #
       # include snippets/snakeoil.conf;

       root /var/www/html;

       # Add index.php to the list if you are using PHP
       index index.php index.html index.htm index.nginx-debian.html;

       server_name _;

       location / {
               # First attempt to serve request as file, then
               # as directory, then fall back to displaying a 404.
               try_files $uri $uri/ =404;
       }

       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       location ~ \.php$ {
               include snippets/fastcgi-php.conf;
       #
       #       # With php5-cgi alone:
       #       fastcgi_pass 127.0.0.1:9000;
               # With php5-fpm:
               fastcgi_pass unix:/var/run/php5-fpm.sock;
       }

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #       deny all;
       #}
}

Now cd to where the website is stored (/var/www/html/) Place your website in this folder, you can use the one provided in the repo.

Place the lightswitch file in /usr/local/bin/.

Thats it, your new wireless light switch should work

It would be a good idea to create another user and have nginx and php run through that user for security reasons. Atleast the default password for the pi should be changed

You can use the following image as a guide layout

lightswitch's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.