Hello Everybody,
I have an analog pressure sensor and a digital flow sensor whose data are sent to arduino uno.
I have implemented a simple RC filter (R=69Kohm,C=270nF, fcut=8,5 Hz) for the analog singnal.
The problem is that I get low noisy data if I directly connect the analog signal to arduino A0 port, while I have really bad data passing through the RC filter.
-Which might be the problem?
-How can I know the sampling frequency of the analog signal?
I also plot the data with “Processing” and I don’t know if the delay introduced between the acquisition and serial printing may be responsible of the noise when i cut the frequency.
This is the arduino sketch:
#include <Wire.h>
#define address 0x40
#define offset 32768
#define scale_factor 120
unsigned int d;
byte a,b,c;
int a1,b1,c1;
float flusso;
int pin=8;
int i=0;
void setup() {
pinMode(pin,INPUT);
Wire.begin();
Serial.begin(9600);
}
void loop() {
if (digitalRead(pin)==HIGH){
if( i==0 ){
Wire.beginTransmission(address);
Wire.write(16);
Wire.write(0);
Wire.endTransmission();
i=i+1;
}
Wire.requestFrom(address,3);
a=Wire.read();
b=Wire.read();
c=Wire.read();
a1 =int(a);
b1=int(b);
d=(a1*256)+b1;
Serial.print("\t");
flusso=((d-offset)/float(scale_factor));
Serial.print(flusso);
Serial.print("\t");
int sensorValue=analogRead(A0);
float pressione=(sensorValue*0.3965)-40.3512-160;
Serial.print("|");
Serial.print("\t");
Serial.println(pressione);
}
else if (digitalRead(pin)==LOW){
i=0;
}
delay(30);
}
The second strange thing is that if “flusso=((d-offset)/float(scale_factor));” is done before the first “Serial.print(”\t");" the data printed are completly wrong.
- Which could be the problem here?
Thank you