GithubHelp home page GithubHelp logo

basirsharif / devicehub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from khinds10/devicehub

0.0 1.0 0.0 45 KB

Simple RESTful API to persist Internet of Things information to central data hub

PHP 55.91% Hack 1.13% JavaScript 42.96%

devicehub's Introduction

Device Hub

Generalized data hub to persist RaspberryPi project generated data for reporting and analysis

Installation

Copy the files from this project to a PHP enabled webhost of your choice with a MySQL instance available for use

Create the MySQL DB (having connectivity to your PHP webhost)

CREATE DATABASE my_devices;

USE my_devices;

CREATE TABLE devices ( entry INT NOT NULL AUTO_INCREMENT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, device VARCHAR(50), value1 VARCHAR(500), value2 VARCHAR(500), value3 VARCHAR(500), value4 VARCHAR(500), value5 VARCHAR(500), value6 VARCHAR(500), value7 VARCHAR(500), value8 VARCHAR(500), value9 VARCHAR(500), value10 VARCHAR(500), PRIMARY KEY (entry) );

ALTER TABLE devices ADD INDEX device (device); ALTER TABLE devices ADD INDEX time (time);

Configure Site Settings

Copy the settings.shadow.php file to a file named settings.php with the correct credentials for your MySQL instance

Also if you have the Temperature API project (https://github.com/khinds10/TemperatureAPI) installed that's also producing heatmaps, configure URLs here as well.

RPi Project python example to upload data

Python dependancy

sudo apt-get install python-requests

Code Snippet

import requests

r = requests.post("http://yourweb.com/api/log/", data={'device': 'weather-clock', 'value1': '78', 'value2': '56', 'value3': '', 'value4': '', 'value5': '', 'value6': '', 'value7': '', 'value8': '', 'value9': '', 'value10': ''}) print(r.status_code, r.reason) print(r.text)

weather-clock indentified device persisting value1 = 78 and value2 = 56 (value1 is *F and value2 is humidity % implied in this case)

Read Device Data Back

http://yourweb.com/api/read/?device=weather-clock

Additional API usage examples

http://yourweb.com/api/hello Output: HELLO WORLD

http://yourweb.com/api/test?var=testing_get_method Output: testing_get_method

devicehub's People

Contributors

khinds10 avatar

Watchers

James Cloos 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.