MA, il mio problema è che, in bravo noob ho cercato in rete uno sketch da modificare per provare il mio sensore ma le mie ricerche mi portano (incluse quelle nei vari forum del sito arduino.cc) tutte sullo stesso sketch che però da me da errori
// reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com
volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int hallsensor = 2; //The pin location of the sensor
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the
hall effect sensors signal
}
// The setup() method runs once, when the sketch starts
void setup() //
{
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is
initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
in L/hour
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
Qualcuno potrebbe aiutarmi? Non sono in grado di farlo funzionare
POI, in un secondo momento (quando funzionerà) vorrei usare questo sensore per controllare il flusso di un filtro come ho detto sopra, quindi vorrei fare in modo che mi indichi quando devo fare una manutenzione.
Per fare questo ho pensato di pulire il filtro e rilevare il valore che mi darà il sensore per farne il 100% (del filtro), poi con una formula/riga di sketch che non sono in grado di scrivere, vorrei che quando il flusso rilevato dal sensore scende sotto al 70% (del valore originale) allora mi si accende un led.
PS : accendere il led sarei anche in grado, è tutto il resto che non sono in grado di fare da solo, a cominciare col far funzionare il sensore!!
Grazie mille per l'aiuto, però non capisco lo sketch su seeed wiki è lo stesso che avevo trovato io nei vari forum e non funziona mi dà vari errori.
Capisco quello che mi hai scritto purtroppo non sono in grado da solo a farlo funzionare.
Capisco la resistenza di pull up da 10k, capisco che ha un sensore di t° (che non saprei utilizzare), capisco la formula F = 7.5 * Q ma non so utilizarla con Arduino.
Purtroppo avrei bisogno di essere guidato.
In tanto grazie per le info e il link che mi hai girato!
Chiedo scusa, pensavo che se faceste copia/incolla dello sketch nella vostra IDE che ho condiviso prima vi sarebbero comparsi i stessi errori.
In allegato i primi due errori, il primo riguarda hall (cos'è?).
Per provare ho messo questa riga come commento, e allora mi è comparso un altro errore come da secondo allegato.
Non ho fatto altre prove per ora.
Quelle 2 righe sono commenti che vengono scritti su una seconda riga perché troppo lunghi per una riga. Adesso visto che ci fai avere delle immagini e non il Sketch non so dire la causa perché una pare del Commento viene considerata una nuova riga e percu interpretato come una funzione / variabile o struttura che é sbagliata.
Cancella i newline per unire le righe
NbTopsFan++; //This function measures the rising and falling edge of the
hall effect sensors signal
Serial.begin(9600); //This is the setup function where the serial port is
initialised,
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
in L/hour
Ciao Uwe, grazie mille per l'aiuto l'ho sistemato.
Ho pubblicato il programma nel mio primo messaggio non capisco perché non lo vedi, eccolo qui di nuovo ma adesso funziona
// reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com
volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int hallsensor = 2; //The pin location of the sensor
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the
//hall effect sensors signal
}
// The setup() method runs once, when the sketch starts
void setup() //
{
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is
//initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (NbTopsFan * 60 / 5.5); //(Pulse frequency x 60) / 5.5Q, = flow rate
//in L/hour
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
Comunque adesso funziona, non avevo visto che fosse un commento su una seconda riga
Ma adesso se volessi modificare questo sketch per impostare un valore come 100% di efficienza, e per fare in modo che se questo valore passa sotto a 70% mi accende una led (per ora, più avanti vorrei una notifica email) come devo fare?
Tu hai calcolato nella variabile Calc la portata della tua pompa. Ora basta fare un confronto con l'istruzione "if" per verificare se il valore è per te sufficiente. In caso contrario attivi un'uscita.
Guarda l'esempio IfStatementConditional sull'IDE
Collegandomi a quanto scritto da tapirinho, come primo passo dovresti fare il tuo 100% del filtro.
Quindi, una volta collegato tutto l'hardware, caricato lo sketch su arduino, e pulito bene il filtro, quello che trovi stampato nel monitor seriale è il valore di "filtro pulito".
Ad inizio codice metterai int Riferimento = xx;
Al posto di xx, metti la parte intera (senza decimali) del 70% che a te interessa.
Ad esempio, quando fai il 100%, come valore vedi scritto 200 L/Hour.
Quindi il tuo 70% è pari a 140, allora scriverai int Riferimento = 140;
A questo punto dovrai effettuare un if fra il valore Calc e quello di Riferimento.
Se Calc<=Riferimento accenderai il led, altrimenti lo spegni.
Questo if lo posizionerai subito dopo l'ultimo serial.print che c'è ora nel loop.
Ciao Ragazzi, vi scrivo perché non riesco a fare funzionare il mio sensore di flusso.
L'ho controllate con un multimetro e funziona, ma con arduino non mi da niente nella finestra Monitor Serial.
Perché?!?
Il sensore è collegato al pin digitale 4.
// reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com
volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int hallsensor = 4; //The pin location of the sensor
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the
//hall effect sensors signal
}
// The setup() method runs once, when the sketch starts
void setup() //
{
pinMode(hallsensor, INPUT); //initializes digital pin 4 as an input
Serial.begin(9600); //This is the setup function where the serial port is
//initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (NbTopsFan * 60 / 5.5); //(Pulse frequency x 60) / 5.5Q, = flow rate
//in L/hour
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
Perché leggo "0 L/hour" nel Monitor Serial quando faccio andare il sensore??!
Allora oggi ho fatto progressi, nel senso che sono riuscito ad avere una lettura nella finestra Serial.
Ho preso lo sketch in internet di nuovo, senza modificare il pin nello sketch (loro lo hanno sul pin 2 invece io lo mettevo sul 4).
Stranamente sul due funziona. Ma se sposto sul 4, modificando lo sketch
int hallsensor = 2;
invece che due originalmente non mi funziona più.
Non capisco perché però?!
Perché non posso sposarlo su un altro pin? c'è altro da modificare oltre
int hallsensor = 2;
?
// reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com
// Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com
// http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com
volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int hallsensor = 2; //The pin location of the sensor
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling edge of the
//hall effect sensors signal
}
// The setup() method runs once, when the sketch starts
void setup() //
{
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
Serial.begin(9600); //This is the setup function where the serial port is
//initialised,
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
}
Ciao, scusa potresti spiegarmi come fare per usare il sensore di temperatura?
Con il sensore di flusso ho finalmente combinato Ma non trovo info sul sensore di temperatura incorporato, non so come usarlo ne la precisione del sensore ne niente.
Grazie!
ciao
molti sketch che trovi in rete non vanno presi per oro colato, il tuo sketch usa l'interrupt e con arduino, devi usare solo il pin 2 o 3 quindi ovvio che adesso vedi qualcosa, per quanto riguarda le formule devo leggere il datasheet
avrei ancora bisogno di aiuto con questo sensore :
#include <DHT.h> //For DHT22 & AM2302 library
#include <OneWire.h> //For DS18B20
#include <LiquidCrystal.h>
#include <Bridge.h>
#include <HttpClient.h>
#define DHTPIN 3 //DHT22
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float h = 0;
float t = 0;
const byte DS18B20_Pin = 4; //DS18B20 Signal pin on digital 4
OneWire ds(DS18B20_Pin); // on digital pin 4
int Calc; //Sensore flusso
volatile int NbTopsFan; //measuring the rising edges of the signal
int hallsensor; //The pin location of the sensor is 2 (int0 on Yun = Pin 2)
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling
//edge of the hall effect sensors signal
}
unsigned long ora = 0;
unsigned long ultimaEsecuzione = 0;
long intervalloEsecuzione = 10000;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
pinMode(6, OUTPUT); //LED ROSSO ds18b20
// ***For Flow sensor*****************************************
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
attachInterrupt(1, rpm, RISING); //and the interrupt is attached
// ***********************************************************
// Bridge takes about two seconds to start up
// it can be helpful to use the on-board LED
// as an indicator for when it has initialized
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
Serial.begin(9600);
lcd.begin(16, 2);
dht.begin(); //DHT22
while (!Serial); // wait for a serial connection
}
void loop()
{
ora = millis();
dht22();
ds18b20();
flusso();
//emoncms();
//emoncms_async();
//delay(1000); //just to slow down the output it's easier to read
}
void flusso()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
//attachInterrupt(0, rpm, RISING);
//delay (1000);
//detachInterrupt(0);
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour
Serial.print ("Eheim : ");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.println (F(" L/hour\r\n")); //Prints "L/hour" and returns a new line
/*
lcd.setCursor(0, 0);
lcd.print("Flusso: ");
//lcd.setCursor(0, 1);
lcd.print(Calc, DEC);
lcd.println(" L/h ");
*/
}void flusso()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
delay (1000); //Wait 1 second
cli(); //Disable interrupts
//attachInterrupt(0, rpm, RISING);
//delay (1000);
//detachInterrupt(0);
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour
Serial.print ("Eheim : ");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.println (F(" L/hour\r\n")); //Prints "L/hour" and returns a new line
/*
lcd.setCursor(0, 0);
lcd.print("Flusso: ");
//lcd.setCursor(0, 1);
lcd.print(Calc, DEC);
lcd.println(" L/h ");
*/
}
Quando provo il sensore mi da una lettura fino a 4000 e passa L/H, il che è strano perché il sensore è dato per una lettura fino a 1800l/h max.... intuisco un'errore nelle formule ma non capisco dove... qualcuno saprebbe aiutarmi?
Grazie mille!
Gli interrupt sono abilitati di default da arduino per cui inizi a misurare da quando fai attachInterrupt, invece di scrivere cli() e sei() stacca l'interrupt per un secondo salvati il valore del contatore e azzeralo, fai il calcolo usando il valore del contatore salvato e riattacchi l'interrupt.
Tra l'altro se usi cli() la seriale, twi, ecc non funzionano.
Ciao.