X-doc
Published

Hall Sensor and Temperature Sensor in ESP32

This is a simple project using M5Stick and MicroPython in order to obtain data from the Hall sensors and temperature embedded in the chip.

BeginnerProtip1,495

Things used in this project

Hardware components

M5StickC ESP32-PICO Mini IoT Development Board
M5Stack M5StickC ESP32-PICO Mini IoT Development Board
×1

Software apps and online services

MicroPython
MicroPython

Story

Read more

Code

Hall.py

MicroPython
main
from esp32 import *
axp.setLDO2Vol(2.7)
lcd.font(lcd.FONT_Small, transparent=False, fixedwidth=False)
lcd.orient(lcd.LANDSCAPE_FLIP)

def cl():
    lcd.fillScreen(lcd.BLACK)
    lcd.line(0, 40, 160, 40, lcd.GREEN)
    lcd.line(0, 50, 160, 50, lcd.GREEN)
    lcd.line(0, 60, 160, 60, lcd.GREEN)
    temp = round((((raw_temperature() - 32) / 1.8)), 1)
    bat = round((axp.getBatVol() / 1000), 2)
    lcd.print('CPU:' + str(temp), lcd.RIGHT, 0)
    lcd.print('BAT:' + str(bat), lcd.RIGHT, 10)

cl()
x = 0
color = lcd.WHITE

while True:
    hall = hall_sensor()
    #lcd.print(str(hall_sensor()), lcd.CENTER, 0, lcd.WHITE)
    lcd.text(lcd.CENTER - 20, 0, "  " + str(hall) + "  ", lcd.WHITE)
    time.sleep_ms(50)
    #lcd.clear(lcd.RED)
    #x += 1 if x < 159 else x = 0
    if x < 159:
        x +=1
    else:
        x = 0
        cl()
    #lcd.pixel(x, 50 + hall, color)
    lcd.line(x, 50, x, 50 + hall, color)

Credits

X-doc

X-doc

1 project • 0 followers

Comments

Add projectSign up / Login