Giter Site home page Giter Site logo

rf433-api's Introduction

RF433 REST API

REST API to use an RF 433 MHz transmitter as a remote control. It currently only supports the Chacon DIO 1.0 and Chacon 54662 protocols.

It has only been tested on an ODROID-C4 board and uses an ODROID-specific WiringPi version. It should be easy to adapt it for other boards (e.g. Raspberry Pi).

Installation

Execute the following commands on a Debian or Ubuntu system to install the required dependencies:

apt-get update
apt-get install -y build-essential python3-dev python3-pip
pip install -r requirements.txt

Usage

First, connect an RF 433 MHz transmitter to the GPIO pin of your choice. Take note of the corresponding WiringPi pin number (see pinout.xyz).

Server

Execute the following command to run the server locally:

./app/server.py

You may then go to http://127.0.0.1:8001 to browse the documentation and test the API.

The following arguments are available:

./app/server.py [-h] [-a ADDRESS] [-p PORT] [-g GPIO] [-l LOG_LEVEL]

Optional arguments:
  -h, --help                           Show help message and exit
  -a ADDRESS, --address ADDRESS        Address to bind to (default: 127.0.0.1)
  -p PORT, --port PORT                 Port to listen on (default: 8001)
  -g GPIO, --gpio GPIO                 GPIO WiringPi pin number (default: 0)
  -l LOG_LEVEL, --log-level LOG_LEVEL  Log level: CRITICAL, ERROR, WARNING, INFO, DEBUG (default: INFO)

A Docker image is also available for the arm64 architecture:

docker run -it --rm --privileged -p 8001:8001 ghcr.io/fcrespel/rf433-api:master [-h] [-a ADDRESS] [-p PORT] [-g GPIO] [-l LOG_LEVEL]

You may want to run it in the background using commands such as the following:

# Create and start container
docker run -d --name rf433-api --privileged -p 127.0.0.1:8001:8001 ghcr.io/fcrespel/rf433-api:master

# Stop server
docker stop rf433-api

# Start server
docker start rf433-api

# Show live logs
docker logs -f rf433-api

NOTE: the API port is not secured, make sure to only expose it locally or to trusted clients.

Client

You may call the API with any HTTP client such as curl:

# Replace 12345678 with the actual Chacon DIO 1.0 sender code (arbitrary 26-bit integer)

# Get button 1 status:
curl -sSf -XGET http://127.0.0.1:8001/chacondio10/12345678/1

# Set button 1 to ON:
curl -sSf -XPUT http://127.0.0.1:8001/chacondio10/12345678/1 -d 1

# Set button 1 to OFF:
curl -sSf -XPUT http://127.0.0.1:8001/chacondio10/12345678/1 -d 0

rf433-api's People

Contributors

fcrespel avatar

Watchers

 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.