GithubHelp home page GithubHelp logo

babelouest / taulas Goto Github PK

View Code? Open in Web Editor NEW
8.0 5.0 0.0 40 KB

Arduino source files for Angharad system devices

License: GNU General Public License v3.0

Arduino 37.84% Makefile 2.98% C 59.18%
arduino-uno arduino arduino-device ulfius

taulas's Introduction

Taulas

Multiple sensors and web interface using an Arduino UNO and an HTTP interface (ESP8266 or linux).

Part of the Angharad project for house automation. This source code files allows to get sensors values from an HTTP interface, and send an alert to another HTTP API when the motion sensor is triggered.

Arduino device

The Arduino used is an Arduino UNO, it has 4 different sensors:

  • A DHT22 temperature and humidity sensor on pin 2
  • A DS18B20 temperature sensor for outdoor temperature on pin 7
  • A PIR Motion sensor on pin 2
  • A light sensor on analog pin 0

Arduino communication protocol

Taulas protocol 2.0

The command format uses < and > to delimit a command and a response, and the response data is in json format. The response will have the command without the parameters as a prefix.

For example, sending the command MARCO to the device must be of the following form: <MARCO> And the response will have the following format: <MARCO:{"result":"POLO"}>

An OVERVIEW command response will have the following format: <OVERVIEW:{"sensors":{"SE1":{"value":33,"unit":"C"},"SE2":45},"switches":{"SW1":0},"dimmers":{"DI1":25}}>

ESP8266 Wifi to serial device

This device is between the Arduino UNO and the Wifi network, and allows to send command and get answers to the Arduino UNO via a HTTP Web interface. It has 2 leds wired to its pins 0 and 2. The first one blinks, and then lights on when the network is connected, the second one blinks, and then lights on when the communication is established with the Arduino UNO.

Basically, this device accepts commands on the url, transmits it to the Arduino, and then sends back the answer in the response. When an alert is triggered, the ESP8266 calls a specific HTTP API. The ESP8266 sets COMMANDSENDBACK to true but only to check that the answer it reads corresponds to the command it asked. The command is skipped from the answer sent to the client.

ESP8266 HTTP API

This device has 2 different endpoints:

  • taulas/alertCb?<callback_url>: specify the callback url api to call when an alert is triggered
  • taulas?command=<COMMAND>: send a command to the Arduino and send back its answer in the response

Raspberry Pi to serial device

A taulas interface application has been implemented for a Raspberry Pi (or any linux based device) using a USB cable between the RPi and the Arduino Taulas device.

The source code is available in the taulas_raspberrypi_serial folder. You need Ulfius to compile. When Ulfius and its dependencies are installed, run the following commands:

$ make
$ ./taulas-rpi-serial

This program has default parameters that can be overwritten, the online help will provide the list of parameters:

$ ./taulas-rpi-serial -h

taulas-rpi-serial, serial interface with a taulas arduino device
Options available:
-h --help: Print this help message and exit
-p --port: TCP Port to listen to, default 8585
-u --url-prefix: url prefix for the webservice, default 'taulas'
-s --serial-pattern: pattern to the serial file of the arduino, default '/dev/ttyACM'
-b --baud: baud rate to connect to the Arduino, default 9600
-t --timeout: timeout in seconds for serial reading, default 3000
-l --log-level: log level for the application, values are NONE, ERROR, WARNING, INFO, DEBUG, default is 'DEBUG'
-m --log-mode: log mode for the application, values are console, file or syslog, multiple values must be separated with a comma, default is 'console'
-f --log-file: path to log file if log mode is file

Example with Taulas 2.0 protocol

When the 2 devices are on and connected, a call has the following format:

  • The client calls the url: http://esp8266.ip.address:858/taulas?command=OVERVIEW for an ESP8266 or http://rpi.ip.address:8585/taulas/?command=OVERVIEW for taulas-rpi-serial.
  • The ESP8266 or the Rpi sends the following command to the Arduino UNO: <OVERVIEW>
  • The Aruino UNO sends back the following answer: <OVERVIEW:{"sensors":{"SE1":{"value":33,"unit":"C"},"SE2":45},"switches":{"SW1":0},"dimmers":{"DI1":25}}>
  • The ESP8266 or the RPI skips the command in the Arduino answer and sends back to the client the following response: {"sensors":{"SE1":{"value":33,"unit":"C"},"SE2":45},"switches":{"SW1":0},"dimmers":{"DI1":25}}

taulas's People

Contributors

babelouest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.