@herb Here you go:
https://github.com/m5stack/M5Stack/blob/master/examples/Unit/EARTH/EARTH.ino
Both analog and digital.
The earth sensor is rather...'simple'
Screenshot 2024-06-22 at 4.32.26 PM.png
from the docs page
https://docs.m5stack.com/en/unit/earth
you can see that the 'Ain' just reads the voltage across the sensor and the 'Din' is at least the threshold comparator, adjusted by the trim pot on back.