Skip to content
m2mData library
C++ Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

REST services and M2mdata Arduino library

REST services (server functions or http calls) and a M2M Arduino library allow to use M2Mlight platform. First, you need to register the sensor, actuator or alert and obtain the api_key values in platform.

These REST services and Arduino library can be used to send and receive values between the m2mlight platform and a program in a microcontroller or computer (arduino, raspberry, esp8266, etc.) or in a mobile device (tablet or smartphone).

The communication with the m2mlight platform can be using Ethernet (Arduino Ethernet or ENC28J60 shields) or GSM (SIM800L module).

1. REST services

To upload/download data to m2mlight platform using http from a browser or program, you can employ the following server functions:

a) Sensors:

b) Actuators:

c) Alerts:

You can use these functions inside an C++ code (Arduino or Esp8266) or Python code (Raspberry). You can see and example in the file: If you are using an Arduino is better to use the M2MData library.

If you are using a GSM/GPRS chip like SIM800L then you can connect to directly with http commands. See example_use_sim800.ino.

2. M2mData Arduino Library

The m2mData Arduino Library allows you to store and retrieve data of sensors, actuators and alerts to/from m2mlight. You can use http or mqtt protocol.

You need to create a m2mData folder in your Arduino Libraries and download the files: m2mData.h and m2mData.cpp. You can see examples of use in the following files: examples_use_m2mdata.ino.

When arduino is connected to Internet, you have the following functions:

a) Sensors:

// Store a single "value" of a sensor identified with "api_key" using http protocol

void sendValue(char api_key[], float value);

// Store a single "value" of a sensor identified with "api_key" using mqtt protocol

void sendValueMqtt(char api_key[], float value);

// Store coordinates values of a location sensor identified with "api_key"

void sendCoordinates(char api_key[], float latitude, float longitude);

// Return the last single value of a sensor identified with "api_key"

float readValue(char api_key[]);

b) Actuators:

// Send an email about an action of an actuator identified with "api_key"

void sendEmailAction(char api_key[]);

// Return the star hour (HH:MM) of an actuator identified with "api_key"

String readActuatorHour(char api_key[]);

// Update the start hour "start_hour" (HH:MM) of an actuator identified with "api_key"

void updateActuatorHour(char api_key[], char start_hour[]);

c) Alerts:

// Send an email of an alert identified with "api_key"

void sendEmailAlert(char api_key[]);

You can’t perform that action at this time.