@@ -535,50 +535,50 @@ The M4 core needs to have the **`rpc-flow-sensor.ino`** uploaded to collect and
535535FlowSensor flowSensor(SENSOR_TYPE, SENSOR_PIN);
536536
537537void count() {
538- flowSensor.count();
538+ flowSensor.count();
539539}
540540
541541// Function to get Flow Rate (for RPC)
542542float getFlowRate() {
543- flowSensor.read();
544- float flowRate = flowSensor.getFlowRate_m(); // Get flow rate in L/min
543+ flowSensor.read();
544+ float flowRate = flowSensor.getFlowRate_m(); // Get flow rate in L/min
545545
546- if (isnan(flowRate) || isinf(flowRate)) {
547- return 0.0; // Default to 0 if no valid reading
548- }
549- return flowRate;
546+ if (isnan(flowRate) || isinf(flowRate)) {
547+ return 0.0; // Default to 0 if no valid reading
548+ }
549+ return flowRate;
550550}
551551
552552void setup() {
553- SerialDebug.begin(115200);
554- //while (!SerialDebug);
553+ SerialDebug.begin(115200);
554+ //while (!SerialDebug);
555555
556- SerialDebug.println("Starting Flow Sensor ");
556+ SerialDebug.println("Starting Flow Sensor ");
557557
558- flowSensor.begin(count); // Initialize the Flow Sensor
558+ flowSensor.begin(count); // Initialize the Flow Sensor
559559
560- // RPC Binding: Function to get flow rate
561- RPC.bind("flow_rate", [] {
562- return 11 ;
563- });
560+ // RPC Binding: Function to get flow rate
561+ RPC.bind("flow_rate", [] {
562+ return getFlowRate() ;
563+ });
564564
565- // RPC Binding: Receive classification results
566- RPC.bind("classification", [](std::string const& input) {
567- SerialDebug.print("Classification Received: ");
568- SerialDebug.println(input.c_str());
569- return 1;
570- });
565+ // RPC Binding: Receive classification results
566+ RPC.bind("classification", [](std::string const& input) {
567+ SerialDebug.print("Classification Received: ");
568+ SerialDebug.println(input.c_str());
569+ return 1;
570+ });
571571
572- SerialDebug.println("Setup complete.");
572+ SerialDebug.println("Setup complete.");
573573}
574574
575575void loop() {
576- float flowRate = getFlowRate();
577- SerialDebug.print("Flow Rate: ");
578- SerialDebug.print(flowRate);
579- SerialDebug.println(" L/min");
576+ float flowRate = getFlowRate();
577+ SerialDebug.print("Flow Rate: ");
578+ SerialDebug.print(flowRate);
579+ SerialDebug.println(" L/min");
580580
581- delay(1000);
581+ delay(1000);
582582}
583583```
584584
0 commit comments