Arduino Arduino library for the CloudStorage server project. The library provides easy access to server-stored values and operations.

arduino-library-badge Build Status

Arduino-CloudStorage

Arduino/ESP8266 library that allows you to easly store and retreive data from a remote (cloud) storage in a key/value fashion. CloudStorage server can be found here.

This project allows for storage and retrival of numbers (floats, ints), strings and even arrays and complex objects. The project lets you listen for changes in real time so you can keep your IOT devices connected and synced.

Open an issue or contact me if you need any help!

Quick Jump:

How To Install

  1. Just go to your local folder for Arduino projects (usually User/Documents/Arduino/).
  2. Step into the folder called libraries
  3. Clone the repository in the libraries folder and restart the Arduino IDE.
  4. Should be good to go! Try to load the example sketches from the menu, "File" -> Examples" -> "ArduinoCloudStorage"

For more information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries

Features & Syntax

  1. Store key/value pairs to the server
storage.put<int>("age", 20);
storage.put<float>("temperature", 25.8);
storage.put<bool>("switch_state", false);
  1. Fetch key/value pairs from the server
int age = storage.get<int>("age");
float temperature = storage.get<float>("temperature");
bool isSwitchOn = storage.get<bool>("switch_state");
  1. Add values to an array in the server
storage.add<float>("sensor_values", getCurrentSensorValue());
storage.add<String>("startup_dates", "17.12.2018");
  1. Pop values from an array in the server
String color = storage.pop<String>("colors_to_show", PopFrom_End);
float temp = storage.pop<float>("tempertures", PopFrom_Start);
// More advanced example of pop. In the previous example the returned value is 
// implicitly casted into the required return type (String, float etc..)
while(true) {
  auto popResult = storage.pop<String>("lines_to_print", PopFrom_Start);
  if(popResult.isOK == false) break;
  proccessLine(popResult.value);
  if(popResult.hasNext == false) break;
}
  1. Get an aggregate of a collection
int average = storage.avg("samples");
int min = storage.min<int>("samples");
int max = storage.max<int>("samples");
  1. Atomic operations
int newValue = storage.inc("some_key");
int newValue = storage.dec("some_key");

// Will only set "some_key" to 3.2 if it is less than what already in some_key and returns the new value
float newMin = storage.put_min<float>("some_key", 3.2f);

// Will only set "some_key" to 1234.5 if it is more than what already in some_key and returns the new value
float newMax = storage.put_max<float>("some_key", 1234.5f);

// Puts a timestamp in the key "datetime_key" and returns the new value
String currentDatetime = storage.datetime("datetime_key");
  1. Listen for changes (beta)
// listen for changes on key "temperture"
storage.listen("temperture");

// Do something when a key changes
storage.onChange([&](String key){
  if(key == "temperture") {
    // Do Something
  }
});

// Process events
while(true) {
  storage.loop();
}

Requirements

  • This library uses the ArduinoJson library as a depedency. arduino-library-badge
  • This library uses the ArduinoWebsockets library. arduino-library-badge
  • You must have an instance of CloudStorage Server running.
  • You must have valid username and password (on your CloudStorage Server)

Public Experiment Server

As of 18.12.2018, you could use my public instance as server (As BASE_URL): http://cloudstorage.gilmaimon.xyz:5050. You can Click Here to register a new user on that server. 11.01.2019 Update: Server moved to port 5050.

NOTE:

  • This server will not stay alive forever.
  • IP and/or Port might change, take that into considiration.
  • Please, don't abuse bandwith/storage (IP will be blocked and/or server will be taken down)

Known Issues

  • Bad error reporting and handling
  • No explanation on setting up a server.

Examples

See all the examples HERE.

Increment Value in Server

This example sketch:

  1. Connects to a WiFi network
  2. Initializes a value in the server
  3. Increment the value in loop()
CloudStorage storage("BASE_URL", "USERNAME", "PASSWORD");

void setup() {
  Serial.begin(115200);
  
  // Try to connect to a wifi network
  WifiConnection::tryConnect("WIFI_SSID", "WIFI_PASSWORD");  

  // Give the ESP some time to connect
  delay(3 * 1000);
  
  // initialize value to 0
  if (WifiConnection::isConnected()) {
    storage.put<int>("count", 0);
  }

}

void loop() {
  Serial.println("Checking Connection");
  if (WifiConnection::isConnected()) {
    
    // Get the current value
    int val = storage.get<int>("count");

    // Log
    Serial.print("Got value: ");
    Serial.print(val);
    Serial.println(" . Updating...");
    
    // Increment by 1 and store in the server
    storage.put<int>("count", val + 1);
    
  } else {
    Serial.println("No Connection");
  }

  delay(1000);
}

Log Sensor Values

This example sketch:

  1. Connects to a WiFi network
  2. Then, in loop(): reads and logs sensor value to the server
CloudStorage storage("BASE_URL", "USERNAME", "PASSWORD");

void setup() {
  Serial.begin(115200);
  
  // Try to connect to a wifi network
  WifiConnection::tryConnect("WIFI_SSID", "WIFI_PASSWORD");  

  // Give the ESP some time to connect
  delay(3 * 1000);
}

void loop() {
  Serial.println("Checking Connection");
  if (WifiConnection::isConnected()) {
    
    // get some sensor value to log
    float value = getSomeSensorValue();

    // add that value to array in the server
    storage.add("sensor_values", value);
    
  } else {
    Serial.println("No Connection");
  }

  delay(5 * 1000);
}

Open an issue or contact me if you need any help!

Owner
Gil Maimon
Professional Copy-Paster & Hobbist Programmer. I enjoy C++, Python and everything in between. I also maintain some Arduino libraries for personal and public use
Gil Maimon
Similar Resources

The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32

The Approximate Library is a WiFi Arduino library for building proximate interactions between your Internet of Things and the ESP8266 or ESP32

The Approximate Library The Approximate library is a WiFi Arduino Library for building proximate interactions between your Internet of Things and the

Dec 7, 2022

A simple two-axis gimbal built using two servo motors, an mpu6050 gyro and accelerometer sensor, and an Arduino (Uno)

A simple two-axis gimbal built using two servo motors, an mpu6050 gyro and accelerometer sensor, and an Arduino (Uno)

Makeshift Gimbal Project A simple two-axis gimbal built using two servo motors, an mpu6050 gyro and accelerometer sensor, and an Arduino (Uno). A shor

Jun 17, 2022

Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages.

107-Arduino-NMEA-Parser Arduino library for interfacing with any GPS, GLONASS, Galileo or GNSS module and interpreting its NMEA messages. This library

Jan 1, 2023

Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485

Arduino, esp32 and esp8266 library for ABB (ex PowerOne) Aurora Inverter, implement a full methods to retrieve data from the Inverter via RS-485

ABB Aurora protocol You can refer the complete documentation on my site ABB Aurora PV inverter library for Arduino, esp8266 and esp32 I create this li

Nov 22, 2022

An Arduino library with additions to vanilla Serial.print(). Chainable methods and verbosity levels. Suitable for debug messages.

advancedSerial This library provides some additions to vanilla Serial.print(): 1. Chainable print() and println() methods: // you can chain print() a

Dec 13, 2022

Arduino library for sending email and SMS from nothing but the ESP8266!

Arduino library for sending email and SMS from nothing but the ESP8266!

Did you know your ESP8266 could send Email and SMS without any special hardware or paid services like Twilio? With AlertMe, your ESP8266 project can:

Feb 24, 2022

Open Sound Control(OSC) Library for Arduino - modern IDE's (1.6.2 and above)

for Arduino firmware 1.0rc-1 tested Arduino Ethernet http://www.arduino.cc/en/Main/ArduinoBoardEthernet Installation ArdOSC folder into .. Mac ~/Do

Feb 14, 2021

Arduino Library for the Atmel/Microchip ECC508 and ECC608 crypto chips

ArduinoECCX08 Arduino Library for the Atmel/Microchip ECC508 and ECC608 crypto chips License Copyright (c) 2018 Arduino SA. All rights reserved. This

Dec 14, 2022

A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)

A library for writing modern websockets applications with Arduino (ESP8266 and ESP32)

Arduino Websockets A library for writing modern websockets applications with Arduino (see prerequisites for supported platforms). This project is base

Dec 26, 2022
Comments
  • Pass new value on real time updates

    Pass new value on real time updates

    The server does sent the newly changed value to the client, but it is as json and cannot simply be passed because it can be of any type. Should implement something like std::any that will hold the value as a string and parse it according to the requested type. For example:

    void onChangeCallback(String key, AnyValue value) {
      // if we know its boolean
      bool newValue = value.as<bool>();
    
      // if we know it is X
      X newValue = value.as<X>();
    }
    
  • Add support for CloudStorage websockets real-time updates

    Add support for CloudStorage websockets real-time updates

    Add support for listening to key changes via websockets as supported in the server's beta version 0.6.0 https://github.com/gilmaimon/CloudStorage-Server/pull/9

  • Specify library dependencies in library.properties

    Specify library dependencies in library.properties

    Specifying the library dependencies in the depends field of library.properties causes the Arduino Library Manager (Arduino IDE 1.8.10 and newer) to offer to install any missing dependencies during installation of this library.

    arduino-cli lib install will automatically install the dependencies (arduino-cli 0.7.0 and newer).

    Reference: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#libraryproperties-file-format

  • Add subkey support for min/max

    Add subkey support for min/max

    Add support for sorting objects (getting aggregate min/max) by subkey instead of default comparator. subkey parameter should be added to relevant http requests.

Arduino library for SPI and I2C access to the PN532 RFID/Near Field Communication chip

Adafruit-PN532 This is a library for the Adafruit PN532 NFC/RFID breakout boards This library works with the Adafruit NFC breakout https://www.adafrui

Dec 23, 2022
This class provides functionality useful for debugging sketches via printf-style statements.

Arduino_DebugUtils This class provides functionality useful for debugging sketches via printf-style statements. How-To-Use Basic Arduino_DebugUtils ha

Dec 13, 2022
Arduino polyphonic synthesizer project (not a Moog) for ESP32 - STM32 - Teensy and more
Arduino polyphonic synthesizer project (not a Moog) for ESP32 - STM32 - Teensy and more

ml_synth_basic_example Arduino polyphonic synthesizer project (not a Moog) for ESP32 - STM32 - Teensy and more link to the video My intention was to m

Dec 7, 2022
Arduino web server library.

aWOT Arduino web server library. Documentation 1. Getting started Hello World Basic routing Application generator Serving static files 2. Guide Routin

Jan 4, 2023
Arduino library to connect your project to IRC (Internet Relay Chat)

IRC Client Library for Arduino Connects your arduino project to an IRC server. Features Easy connection to an IRC server through a Client implementati

Aug 19, 2022
Arduino library for making an IHC in or output module using an Arduino

Introduction This is an Arduino library for making an IHC in or output module using an Arduino. (IHC controller is a home automation controller made b

Mar 26, 2020
ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT Cloud

ArduinoIoTCloud What? The ArduinoIoTCloud library is the central element of the firmware enabling certain Arduino boards to connect to the Arduino IoT

Dec 16, 2022
Server side minimalistic HTTP protocol implementation for the Arduino platform.

ArduinoHttpServer Server side minimalistic Object Oriented HTTP protocol implementation for the Arduino platform. ArduinoHttpServer is a simple HTTP r

Oct 17, 2022
An easy to use C++ Library to interact with the Algorand Blockchain.
An easy to use C++ Library to interact with the Algorand Blockchain.

Algoduino An easy to use Library to interact with the Algorand Blockchain. Lead Maintainer: Ted Nivan Documentation You can find installation instruct

Nov 25, 2022
AlmaviosLitMqtt allows an easy connection(IoT) to cloud providers

AlmaviosLitMqtt A simple arduino library provisioning a client to connect with Cloud Providers, via MQTT. It is looking for agnostic connection. This

Nov 20, 2020