Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web interface #56

Open
JonyBest opened this issue May 11, 2024 · 1 comment
Open

web interface #56

JonyBest opened this issue May 11, 2024 · 1 comment

Comments

@JonyBest
Copy link

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.

@theelims
Copy link
Owner

@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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants