AJB2K3
Published © CC BY-NC-SA

M5GO IOT Starter Kit Part 5 EZData2

The Label say IOT Starter Kit so Let do some Internet of Things with the kit and M5Stack EZData2 servers.

IntermediateProtip1 hour36
M5GO IOT Starter Kit Part 5 EZData2

Things used in this project

Hardware components

M5GO IoT Starter Kit
M5Stack M5GO IoT Starter Kit
×1

Software apps and online services

M5Stack UIFLow2

Story

Read more

Code

Expanding the ENVIII code to communicate with the EZData2 server.

MicroPython
import os, sys, io
import M5
from M5 import *
from hardware import *
from unit import ENVUnit
from ezdata import *
import time



title0 = None
T = None
P = None
H = None
F = None
i2c0 = None
ez_0 = None
ez_IOT_cbac = None
env3_0 = None


def setup():
  global title0, T, P, H, F, i2c0, ez_0, ez_IOT_cbac, env3_0

  M5.begin()
  Widgets.fillScreen(0x222222)
  title0 = Widgets.Title("M5GO IOT GUIDE P5", 65, 0xffffff, 0x0000FF, Widgets.FONTS.DejaVu18)
  T = Widgets.Label("Temperature: ", 3, 56, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  P = Widgets.Label("Pressure: ", 3, 88, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  H = Widgets.Label("Humidity: ", 3, 121, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
  F = Widgets.Label("fetch", 3, 167, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)

  i2c0 = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
  env3_0 = ENVUnit(i2c=i2c0, type=3)
  ez_0 = EzData('c6082b33946547ac9062fbab6a2392a4', 'IOT')
  ez_IOT_cbac = EzData('c6082b33946547ac9062fbab6a2392a4', 'IOT')


def loop():
  global title0, T, P, H, F, i2c0, ez_0, ez_IOT_cbac, env3_0
  M5.update()
  T.setText(str((str('Temperature: ') + str((env3_0.read_temperature())))))
  P.setText(str((str('Pressure: ') + str((env3_0.read_pressure())))))
  H.setText(str((str('Humidity: ') + str((env3_0.read_humidity())))))
  F.setText(str(.get()))
  .set({'Temperature':(env3_0.read_temperature()),'Pressure':(env3_0.read_pressure()),'Humididty':(env3_0.read_humidity())}, is_file=False)
  time.sleep(30)


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")

Credits

AJB2K3

AJB2K3

50 projects • 31 followers
I have always had an interest in electronics but having failed my school exams, it has taken me 20+ years to produce products to share.

Comments