I have the M5StickC Plus (https://shop.m5stack.com/products/m5stickc-plus-esp32-pico-mini-iot-development-kit) and soon the AtomU (https://shop.m5stack.com/products/atomu-esp32-development-kit-with-usb-a). My goal is to write something to capture noise levels in decibels and graph that data externally. However I want to do that with Micropython since I'm more familiar with python or even blockly at this point. I just can't figure out how. Here's the blockly/micropython code to just capture data on button press and nothing more...
from m5stack import * from m5ui import * from uiflow import * from easyIO import * setScreenColor(0x111111) while True: if btnA.isPressed(): M5Led.on() lcd.clear() lcd.print((analogRead(34)), 0, 0, 0xffffff) else: M5Led.off() lcd.clear() wait_ms(2)
The problem is that it shows a number
1270 but that doesn't fluctuate based on sound. It's a constant number. Why?
Looking at https://docs.m5stack.com/en/core/m5stickc_plus it shows that GPIO34 is the pin. Do you need to activate/enable this pin?
Also, I don't see any mention of
analogRead in github https://github.com/m5stack/M5Stack_MicroPython/search?q=analogRead&type=code so I don't even know where to look for this in code. Closest example of using microphone I can find is in Arduino https://github.com/m5stack/M5StickC-Plus/blob/master/examples/Basics/Micophone/Micophone.ino but can't figure out how to translate that into micropython. There is no
i2s_read in the micropython library which is what Arduino uses. Maybe it's some permutation of