Coder Social home page Coder Social logo

thomas-bouvier / auto-door Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 1.0 724 KB

Raspberry Pi 3 based garage door opener with Node.js and React Native

License: MIT License

JavaScript 12.97% HTML 3.32% Python 48.24% Java 2.23% Objective-C 6.15% Makefile 27.09%
raspberry-pi socket-io nodejs home-automation react-native garage-door-opener

auto-door's Introduction

auto-door

Raspberry Pi 3 based garage door opener with Node.js and React Native.

Build the React Native application

Android

On macOS, you will need Node (8.3 or newer), the React Native command line interface, a JDK, and Android Studio. On Windows, you will need Node (8.3 or newer), the React Native command line interface, Python2, a JDK, and Android Studio.

cd app/HomeAutomation
npm install
react-native run-android

Fore more detailed instructions, please refer to the official guide (make sure to select Android as your target OS).

iOS

You will need Node (8.3 or newer), Watchman, the React Native command line interface, and Xcode (a Mac is necessary).

cd app/HomeAutomation
npm install
react-native run-ios

Fore more detailed instructions, please refer to the official guide (make sure to select iOS as your target OS).

Install the Node server on the Raspberry Pi

Connect to your Raspberry Pi and clone this repository in /var/www.

Webserver

You will need to install a webserver (nginx ?) to handle incoming requests. Don't forget to configure your router to allow incoming connections. By default, the HTTP protocol uses port 80, and SSH uses port 22. These are the two internal ports you need to expose.

Although nginx is listening on port 80, the Node server itself is listening on a different port (8080). Therefore, you need to configure nginx to act as a reverse proxy :

server {
    listen 80;
    root /var/www/auto-door/server;
    server_name 192.168.x.x;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

Don't forget to reload nginx.

Node.js

Node.js can easily installed thanks to the node-arm project:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

Once it is installed, you can check if it's working by running node -v.

Configuration

Don't forget to configure the Node server in server:

cd /var/www/auto-door/server
cp config.example.js config.js
vi config.js

The auth key must match with the application configuration.

Node server

Don't forget to install the dependencies :

cd /var/www/auto-door/server
npm install

The Node server can then be started with npm start.

forever-service

I like to use forever-service to provision the Node server as a service, allowing it to automatically start on boot.

cd /var/www/auto-door/server
sudo forever-service install auto-door --script server.js

// to delete it
sudo forever-service delete auto-door

The service is now created and can be started by running sudo service auto-door start. A list of running services can be obtained by running sudo forever list.

auto-door's People

Contributors

thomas-bouvier avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

verstaadtech

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.