pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

EzData 2.0

EzData 2.0 is an IoT cloud data storage service provided by M5Stack, allowing different devices to insert or extract data into a storage queue through a unique token, enabling data sharing.

Example

import os, sys, io
import M5
from M5 import *
from ezdata import *

ez_0 = None
ez_item = None

def setup():
  global ez_0
  M5.begin()
  Widgets.fillScreen(0x222222)
  ez_0 = EzData('b1112ac5e9644f26af381c15c4a0e1da', 'age')
  ez_0.set("res/img/default.png", is_file=True)

def loop():
  global ez_0
  M5.update()
  ez_0.set(18, is_file=False)
  print(ez_0.get())
  ez_0.set([1, 2, 3], is_file=False)
  print(ez_0.history())
  ez_0.delete()
  for ez_item in get_key_list(device_token=_).iterms():
    print(ez_item[0])
    print(ez_item[1])

if __name__ == '__main__':
  try:
    setup()
    while True:
      loop()
  except (Exception, KeyboardInterrupt) as e:
    try:
      from utility import print_error_msg
      print_error_msg(e)
    except ImportError:
      print("please update to latest firmware")
ez_0 = EzData('b1112ac5e9644f26af381c15c4a0e1da', 'age')
  • Initialize EzData, optionally filling in the online device token and the corresponding key to access.
ez_1 = EzData('b1112ac5e9644f26af381c15c4a0e1da', 'hello_M5')
  • Initialize EzData, customizing the device token and the corresponding key to access.
ez_4 = EzData('b1112ac5e9644f26af381c15c4a0e1da', '', public=True)
  • Initialize EzData, customizing only the device token.
ez_3 = EzData('795efd86c2a6478eb9c3bb414376bb6b', 'age')
  • Initialize an EzData dataset object, optionally filling in the device token and the corresponding key to access.
ez_0.set(18, is_file=False)
  • Modify the value corresponding to a specified key.
ez_0.set({'hello_M5':'hello M5'}, is_file=False)
  • Save a data Value to the value corresponding to a specified key.
ez_0.set([1, 2, 3], is_file=False)
  • Save an array list to the value corresponding to a specified key.
ez_0.set({'hello_M5':'hello M5'}, is_file=False)
  • Create an array map, and save the array map to the value corresponding to a specified key.
ez_0.set("res/img/default.png", is_file=True)
  • Customize an image resource file and upload it to the value corresponding to a specified key.
ez_0.set("res/img/default.png", is_file=True)
  • Select an image resource file to upload to the value corresponding to a specified key.
ez_0.get_file('helloM5.png')
  • Update an image resource file to the value corresponding to a specified key.
print(ez_0.get_update_time())
  • Retrieve the last update time of the data.
print(ez_0.get())
  • Retrieve the data Value corresponding to a specified key.
print(ez_0.has_new_data())
  • Retrieve the latest data corresponding to a specified key.
print(ez_0.history())
  • Retrieve the historical records of data corresponding to a specified key.
for ez_item in get_key_list(device_token=_).iterms():
  • Iterate through all lists in the EzData object.
print(ez_item[0])
  • Retrieve all keys corresponding to the EzData list being iterated through.
print(ez_item[1])
  • Retrieve all data values from the list corresponding to a specified key.
ez_0.delete()
  • Delete the key object corresponding to the current device's EzData.
On This Page