GithubHelp home page GithubHelp logo

jamesmoulding / opensensorsio-arduino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opensensorsio/opensensorsio-arduino

0.0 1.0 0.0 31 KB

An arduino MQTT library to connect to opensensors.io

C++ 24.99% Arduino 75.01%

opensensorsio-arduino's Introduction

Arduino Client for OpenSensors

This is the OpenSensors client for Arduino boards with Ethernet or WiFi connectivity. It uses MQTT v3.1 and the Arduino MQTT client by Nick O'Leary (MIT licensed) as a dependency.

Hardware prerequisites

You need an Arduino board with a network interface (Ethernet wire or WiFi), for example, an Arduino UNO and Arduino ethernet shield without PoE, or a single Arduino shield.

Software prerequisites

Arduino IDE or another IDE, Codebender.cc etc.

Using the Library

  1. Download the Arduino MQTT client dependency, created by Nick O'Leary from here.

  2. Import the Arduino MQTT client file you just downloaded into the Arduino IDE. To do this we go to the Arduino IDE toolbar, go to Sketch -> Import Library -> Add library and add PubSubClient.zip

  3. Restart the Arduino IDE

  4. Download the OpenSensors Arduino Client from here.

  5. Import the OpenSensors Arduino Client into the Arduino IDE, mirroring step 2, add osio_client.zip

  6. To implement in your sketch, you will need to now add the library to your sketch. Navigate to Sketch -> Import library, select pubsubclient and then osio_client from the drop down list. Alternatively, type:

#include <pubsubclient.h>
#include <osio_client.h>

Library reference

This client library realized as C++ class named OSIOClient. There are such public methods to work with it:

Constructors which initialize necessary connection parameters. There are some overrides of it ("server name" and "callback" parameters are not mandatory):

OSIOClient::OSIOClient(Client & client, char * userName, char * deviceId, char * devicePassword);
OSIOClient::OSIOClient(Client & client, char * userName, char * deviceId, char * devicePassword, char * serverName);
OSIOClient::OSIOClient(Client & client, char * userName, char * deviceId, char * devicePassword, void (*callback)(char*,uint8_t*,unsigned int));
OSIOClient::OSIOClient(Client & client, char * userName, char * deviceId, char * devicePassword, char * serverName, void (*callback)(char*,uint8_t*,unsigned int));

Method to process iteration of receiving data (callback supplied in constructor (if necessary)):

boolean OSIOClient::loop();

Method to publish message to topic:

boolean OSIOClient::publish(char* topic, char* payload);

Method to subscribe for topic:

boolean OSIOClient::subscribe(char* topic);

Code Examples

Some examples can be found in the sample directory.

opensensorsio-arduino's People

Contributors

andrey-barkanov avatar malcolmsparks avatar michaelklishin 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.