Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
A

aesanto

@aesanto
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Water Flow sensor
    A aesanto

    Hi,

    Here you can find a simplified version of the WaterFlow node.
    This version only sends to the GW the current flow volume in liters/hour.
    I don't know your model (G??) as the pulses per liter/hour vary from different flow sensors. Mine is G1" so the math is for this sensor.

    I had a problem with interrupts, and this was the way i found to work.

    Hope this helps!

    #include <SPI.h>
    #include <MySensor.h>  
    
    #define DIGITAL_INPUT_SENSOR 3                  // The digital input you attached your sensor.  (Only 2 and 3 generates interrupt!)
    #define SENSOR_INTERRUPT DIGITAL_INPUT_SENSOR-2        // Usually the interrupt = pin -2 (on uno/nano anyway)
    
    #define CHILD_ID 1                              // Id of the sensor child
    
    int READ_INTERVAL = 3;           // Read interval to count the pulses (in seconds). 
    
    long lastReadStart;
    int flow;
    
    MySensor gw;
    MyMessage flowMsg(CHILD_ID,V_FLOW);
    
    
    int READ_INTERVAL_MILLIS=READ_INTERVAL * 1000;        // Just to simple the math!
    volatile unsigned long pulseCount = 0;   
    
    void setup()  
    {  
      gw.begin(); 
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Water Meter", "1.2");
    
      // Register this device as Waterflow sensor
      gw.present(CHILD_ID, S_WATER);       
    
      pulseCount = 0;
    
      lastReadStart = millis();
    
      attachInterrupt(SENSOR_INTERRUPT, onPulse, RISING);
    }
    
    
    void loop()     
    { 
      unsigned long currentTime = millis();
    	
    
      if (currentTime - lastReadStart > READ_INTERVAL_MILLIS)
      {
        flow = pulseCount*60/READ_INTERVAL;  //Need to change here for the G type
        lastReadStart=currentTime;
         
    
    
          Serial.print("l/hour:");
          Serial.println(flow);
          gw.send(flowMsg.set(flow));
          
          pulseCount = 0;
      }
    }
    
    
    void onPulse()
    {
      pulseCount++; 
    }```
    My Project
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular