EzData is an IoT cloud data storage service provided by M5Stack. Different devices can insert or retrieve data from the storage queue through a unique Token
to achieve data sharing.
≤1000
entries.setData
to insert new data into the queue using a stack method (last in, first out), each insertion adds the data to the head of the queue.getData
to retrieve the data at the head of the queue. The original data will be deleted from the sequence.addToList
to insert new data into the list; each insertion appends it to the end of the list.getData
to read list data of a specified index or range. The returned data is a list.Open UiFlow Web IDE version 1.0, click the EzData
option in the Blockly list to view the Token of the current browser. To ensure the uniqueness of the Token, please use a fixed browser and do not use incognito mode.
This example program uses the CoreS3 device to test Ezdata data upload and retrieval. Before compiling the program, you need to install the following dependent libraries, and fill in the Token and Wi-Fi information in the code.
#include "M5Unified.h"
#include "M5_EzData.h"
const char* ssid = "ssid";
const char* password = "password";
const char* token = "token";
void setup()
{
M5.begin();
M5.Display.println("Wi-Fi connecting...");
if (setupWifi(ssid, password)) {
M5.Display.println("Wi-Fi connected!");
} else {
M5.Display.println("Wi-Fi connect failed");
}
}
void loop()
{
// Save the data 100 to the top of the testData topic queue.
if (setData(token, "testData", 100)) {
M5.Display.println("Success sending data to the testData");
} else {
M5.Display.println("Fail");
}
delay(5000);
// Save 3 data in sequence to the first place of testList.
for (int i = 0; i < 3; i++) {
if (addToList(token, "testList", i)) {
M5.Display.printf("Success sending %d to the list\n", i);
} else {
M5.Display.println("Fail");
}
delay(100);
}
delay(5000);
// Get a piece of data from a topic and store the value in result.
int result = 0;
if (getData(token, "testData", result)) {
M5.Display.printf("Success get data %d\n", result);
} else {
M5.Display.print("Fail to get data\n");
}
delay(5000);
// Get a set of data from a list and store the values in the Array array.
int Array[3] = {0};
if (getData(token, "testList", Array, 0, 3)) {
M5.Display.print("Success get list\n");
for (int i = 0; i < 3; i++) {
M5.Display.printf("Array[%d]=%d,", i, Array[i]);
}
M5.Display.println("");
} else {
M5.Display.println("Fail to get data");
}
delay(5000);
// Remove data
if (removeData(token, "testData"))
M5.Display.printf("Success remove data\n");
else
M5.Display.println("Fail to remove data");
if (removeData(token, "testList"))
M5.Display.printf("Success remove data from the list\n");
else
M5.Display.println("Fail to remove data");
delay(5000);
M5.Display.fillScreen(BLACK);
M5.Display.setCursor(0, 0);
}
If you need to view or share data, you can visit the EzData control panel page through the following URL by passing in the Token parameter.
# https://ezdata.m5stack.com/debugger/?token=dCtdfg3u5id72J8xxxxxxxxxxxxxxx
https://ezdata.m5stack.com/debugger/?token={token}
Function Prototype:
int setData(const char *token, const char *topic, int val);
Function Description:
val
to the head of the specified topic queue.Parameters:
Return Value:
Function Prototype:
int getData(const char *token, const char *topic, int &result);
Function Description:
result
.Parameters:
Return Value:
Function Prototype:
int addToList(const char *token, const char *list, int val);
Function Description:
Parameters:
Return Value:
Function Prototype:
int *getData(const char *token, const char *list, int *Array, int offset, int count);
Function Description:
Parameters:
Return Value:
Function Prototype:
int removeData(const char *token, const char *field);
Function Description:
Parameters:
Return Value: