InfluxDB_RJL (community library)


Name Value
Name InfluxDB_RJL
Version 0.1.0
Installs 1329
License LGPL
Author Richard Lyon
Download .tar.gz

InfluxDB library for Particle Easy upload of time series data to an InfluxDB database.

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

InfluxDB Particle library

A Particle library for InfluxDB.

About InfluxDB Particle library

InfluxDB is a time series database built to handle high write and query loads. It's a good backing store for timestamped IoT sensor data. More information can be found here. InfluxDB Particle library is a simple client for writing Particle data to an InfluxDB database.


Create an InfluxDB database called test, add the InfluxDB library to your project, and follow this simple example:

#include "authenticate.h" // InfluxDB credentials
#include "InfluxDB.h"
InfluxDB idb = InfluxDB(USERNAME, PASSWORD);

long int timestamp;

void setup() {
// initialise InfluxDB
idb.setDatabase("test");        // defaults to 'sensordata'
idb.setDeviceName("elmon");     // defaults to "particle"
idb.setDebug(true);             // defaults to false

int batchcount = 0;
void loop() {
idb.add("single1", 1.0);

timestamp =;
idb.add("batch1", 2.0, timestamp);
idb.add("batch2", 3.0, timestamp);
idb.add("batch3", 4.0, timestamp);

idb.add("single2", 5.0);

if (idb.sendAll()) {            // call this to send points to InfluxDB
// Serial.println("InfluxDB updated");

See the examples folder for more details.


Create file authenticate.h with your InfluxDB authentication details as follows:

#define USERNAME "your_username"

#define PASSWORD "your_password"

Initialise the client with your InfluxDB authentication details:

InfluxDB idb = InfluxDB(USERNAME, PASSWORD);

InfluxDB supports a built-in HTTP API (described here). InfluxDB uses the Particle HTTPClient library to send a post request to the /write endpoint.

By default, InfluxDB library writes to InfluxDB database sensordata i.e.


Change the target database with:

idb.setDatabase("test"); // defaults to 'sensordata'

Ensure that test exists (future versions will check for you and create the database if necessary).

Points are stored as follows:


DEVICENAME is the measurement name in the InfluxDB database. Future versions will retrieve your device name from Particle Cloud and use it. It defaults currently to particle. For now, change it with:


DEVICEID is the ID of your device as returned by System.deviceID(). Each point is tagged in the database with the device ID.

VARIABLEID and VARIABLEVALUE are the id and value of variables.

UNIX_TIMESTAMP is the Unix time of the sample in seconds

Points are buffered prior to sending. There are two ways of adding points to the buffer.

idb.add("photoresistor", analogvalue);

will cause a single point to be written to the database, with the timestamp corresponding to the time add() is called.

timestamp =; idb.add("batch1", 2.0, timestamp); idb.add("batch2", 3.0, timestamp);

will cause all the points added at timestamp to be written to the datanbase in a single request, with the timestamp corresponding to timestamp.

Up to MAX_VALUES (currently, 10) can be added between updates to the database. Values added beyond this limit are ignored. (This is an arbitrary limit pending further investigation of the API limits.)

To write the point buffer to the database i.e. make the API request, call:


This returns true if the HTTP response code 204 (successful write operation) is received, false otherwise.

Put the device in debug mode with:


This will print to the serial line the data being sent to InfluxDB.

The library has been tested on a Particle Photon (System Firmware 0.6.3) and Core (unknown firmware version but recently updated).



Initial release.


Here's how you can make changes to this library and eventually contribute those changes back.

To get started, clone the library from GitHub to your local machine.

Change the name of the library in to something different. You can add your name at then end.

Modify the sources in and with the new behavior.

To compile an example, use particle compile examples/usage command in Particle CLI or use our Desktop IDE.

After your changes are done you can upload them with particle library upload or Upload command in the IDE. This will create a private (only visible by you) library that you can use in other projects. Do particle library add InfluxDB_myname to add the library to a project on your machine or add the InfluxDB_myname library to a project on the Web IDE or Desktop IDE.

At this point, you can create a GitHub pull request with your changes to the original library.

If you wish to make your library public, use particle library publish or Publish command.


Copyright 2018 Richard Lyon

Licensed under the GNU General Public license

Browse Library Files