код микропитона
from machine import Pin, Signal, ADC, Timer
from dht import DHT11
adc = ADC(0)
led = Signal(Pin(2, Pin.OUT), invert=True)
MAX_HISTORY = 250
d = DHT11(Pin(5))
history = []
beat = False
beats = 0
def calculate_bpm(t):
global beats
print('BPM:', beats/6)
beats = 0
d.measure()
temp = d.temperature()
print('Temperature:', temp)
hum = d.humidity()
print('Humidity', hum)
timer = Timer(1)
timer.init(period=10000, mode=Timer.PERIODIC, callback=calculate_bpm)
while True:
v = adc.read()
history.append(v)
history = history[-MAX_HISTORY:]
minima, maxima = min(history), max(history)
threshold_on = (minima + maxima * 3) // 4 # 3/4
threshold_off = (minima + maxima) // 2 # 1/2
if not beat and v > threshold_on:
beat = True
beats += 1
led.on()
if beat and v < threshold_off:
beat = False
led.off()
Это мой рабочий код для извлечения данных с датчиков с использованием узла MCU. Есть ли способ, с помощью которого я могу хранить свои данные в базе данных Mysql, используя переменные, используемые в коде, например, beats, temp, hum. Если нет, то каким может быть другой способ хранения данных, чтобы в дальнейшем их можно было использовать на веб-сайте PHP.