Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Water flow sensor question

    Scheduled Pinned Locked Moved Discussion
    2 Posts 2 Posters 36 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Smart Farming
      last edited by Smart Farming

      hi everyone. we have the FS400A G1 flow sensor, and been working with the lopy4, but we are very confused about how to implementate the RPM function. i hope some answer in mycropython to be used on a lopy4. thank's

      from time import sleep
      import machine
      
      rmt = machine.RMT(channel=3)
      
      rmt.init(gpio="P4", rx_idle_threshold=16000)
      lt = 0
      
      while True:
          data = rmt.pulses_get(timeout = 5000)
          print(data)
          print()
      

      And arduino code

      // Fórmula:   f(Hz) = K * Q(L/min) 
      // Sensor de ¼”:   S
      // Sensor de ½”: 7,5
      // Sensor de ¾”: 5,5
      // Sensor de 1″: 4,8
      
      
      
      volatile int CantPulsos;  //Variable que acumula los pulsos recibidos
      int LxM;      //Variable que acumula el calculo de Litros por Minuto 
      int pinsensor = 2;    //Numero de pin donde conectamos el sensor
      float FacConv = 4.8;    //Factor de Conversion para calcular caudal
      
      
      void rpm ()  {      //Función que se ejecuta durante la interrupción
        CantPulsos++;   //Incrementa el contador de pulsos
      } 
      
      
      void setup() { 
        pinMode(pinsensor, INPUT);    //inicializa el pin digital 2 como entrada
        Serial.begin(9600);       //inicializa el puerto serie
        attachInterrupt(0, rpm, RISING);  //(Interrupcion 0(Pin2),funcion rpm,Flanco de subida, cuando pasa de LOW a HIGH)
      } 
      
      
      void loop () {
        CantPulsos = 0;           //Pone en 0 el contador de pulsos
        sei();               //Habilitamos las interrupciones, equivalente a sei();
        delay (1000);           //Esperamos un segundo
        cli();               //Deshabilitamos las interrupciones, equivalente a cli();
        LxM = (CantPulsos / FacConv);     //Calcula los Litros por Minuto 
        Serial.print (LxM, DEC);    //Imprime la cantidad de litros por minuto
        Serial.print (" L/min\r\n");    //Imprime "L/min" y salta a una nueva linea
      }
      
      1 Reply Last reply Reply Quote 0
      • C Offline
        cromagnon
        last edited by cromagnon

        I provided a general solution to pulse counting in the following post:
        https://forum.pycom.io/topic/6006/water-flow-sensor-looking-for-advice/2?_=1632413513467

        At some point I may provide a micropython library for this.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom