I am using an ESP32 microcontroller to read data via the sensor MPU6050.
I am sending the data directly to my MQTT broker and then to a database (using Node-red).
My Question is, how can I send 100 values at once to the broker?
I tried the time.sleep
but then only one value is published every 1 second. I want that e.g. every 10 seconds the values to be published, like a batch of values are published.
Code:
from umqttsimple import MQTTClient
i2c= SoftI2C(scl=Pin(21), sda=Pin(22))
mpu= mpu6050.accel(i2c)
client = MQTTClient(b"bruecke", mqtt_server, 1883, user=mqtt_username, password=mqtt_password)
client.connect()
while True:
werte= mpu.get_values()
print(werte['AcY'])
client.publish(topic, str(werte['AcY']))
time.sleep(1)
print(werte['AcY'])