EARTH Unit

Support the following products:

EARTH

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from unit import EarthUnit
 9
10
11label0 = None
12earth_0 = None
13
14
15def setup():
16    global label0, earth_0
17
18    M5.begin()
19    Widgets.fillScreen(0x222222)
20    label0 = Widgets.Label("label0", 132, 109, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
21
22    earth_0 = EarthUnit((36, 26))
23
24
25def loop():
26    global label0, earth_0
27    M5.update()
28    label0.setText(str(earth_0.get_digital_value()))
29
30
31if __name__ == "__main__":
32    try:
33        setup()
34        while True:
35            loop()
36    except (Exception, KeyboardInterrupt) as e:
37        try:
38            from utility import print_error_msg
39
40            print_error_msg(e)
41        except ImportError:
42            print("please update to latest firmware")

UIFLOW2 Example:

example.png

earth_core_example.m5f2

class Earth

Constructors

class Earth(port)

Create an Earth object.

The parameters is:
  • port Is the pin number of the port

UIFLOW2:

init.svg

Methods

EARTH.get_analog_value()

This method allows you to read the analog captured by EARTH and return an integer value. The value ranges from 0 to 65535.

UIFLOW2:

get_analog_value.svg

EARTH.get_digital_value()

This method allows you to read the amount of numbers collected by EARTH and return an integer value. The value ranges from 0 to 1.

UIFLOW2:

get_digital_value.svg

EARTH.get_voltage_mv()

This method allows you to read the voltage value collected by EARTH and return an integer value. It ranges from 0 to 3300.

UIFLOW2:

get_voltage_mv.svg

EARTH.humidity()

This method allows you to read the voltage value collected by EARTH and return a floating-point value. Range 0.0 to 1.0.

UIFLOW2:

humidity.svg

EARTH.set_calibrate()

This method allows setting the maximum (0-3300) and minimum (0-3300) values for calibrating the EARTH sensor.

UIFLOW2:

set_calibrate.svg