Hello, I have cobbled together a semi working sketch of an ESP-01 and two MPU6050 sensors. The code was frankensteined from a few sketches on the web. Right now the module boots up, connects to wifi and waits for a “1” on a MQTT topic it subscribes to. Once a “1” is received it then sends the sensor data to a MQTT topic. This works. The problem is that it only sends the sensor data when a “1” is detected once. It will send the data each time a “1” is sent, but I want it to send the sensor data until a “0” is detected on the subscribed topic. I cant figure out how to loop it until that happens. I am not very experienced with coding ESPs or Arduinos, but I can cobble something together most of the time. Can you guys help me out? Where am I going wrong?
Sketch attached
dual-mpu-mqtt_activated.ino (8 KB)