Open JonyBest opened 1 month ago
@JonyBest It is described in the docs how to update a state and push a new value to the web interface: https://theelims.github.io/ESP32-sveltekit/statefulservice/#read-update-state
You could define your sensor class
class SensorState {
public:
uint32_t sensorValue = 255;
// remaining code like in the lightstate example
};
and update it in your Arduino loop()-function
void loop()
{
uint32_t readSensor = sensor.read();
sensorStateService.update([&](SensorState& state) {
state.sensorValue = readSensor;
return StateUpdateResult::CHANGED;
}, "loop");
delay(100);
}
Help, I can't figure out how to transfer the sensor value to the web interface. You can use a detailed example with an explanation.