10-12-2014 03:15 AM
Hello,
I am a newbie and have had some success with LIFA. I am trying to get EC readings using the Senduino EC probe but can't quiet figure it out. I would apprecitate any help. If someone could point me in the right direction I will crunch awat. I posted the sketch. Thx in advance.
#define SAMPLES 100
#define ECinputPIN 6
#define enablePIN 7
void setup() {
pinMode(ECinputPIN ,INPUT);
pinMode(enablePIN ,OUTPUT);
Serial.begin(9600);
}
float ECa=1;
float ECb=1;
long highPulseTime;
long lowPulseTime;
void loop() {
digitalWrite(enablePIN ,HIGH);
delay(100);
lowPulseTime=getLow(ECinputPIN);
Serial.print(lowPulseTime);
Serial.print(" ");
highPulseTime=getHigh(ECinputPIN);
digitalWrite(enablePIN ,LOW);
Serial.print(highPulseTime);
Serial.print(" ");
Serial.println(lowPulseTime+highPulseTime);
delay(2000);
}
long getHigh(int pin) {
long pulseTime=0;
for(unsigned int j=0; j<SAMPLES; j++){
pulseTime+=pulseIn(pin, HIGH);
}
pulseTime= pulseTime/SAMPLES;
return pulseTime;
}
long getLow(int pin) {
long pulseTime=0;
for(unsigned int j=0; j<SAMPLES; j++){
pulseTime+=pulseIn(pin, LOW);
}
pulseTime = pulseTime/SAMPLES;
return pulseTime;
}
10-12-2014 03:34 PM
If the code that you posted is accurate, you will not be able to use the sensor with LIFA because LIFA does not provide the capability to use the pulseIn() function.
Also, since LIFA is no longer being developed and is very old, you should consider using LINX. You will still probably need to request for someone to make support for the sensor but there is more activity for LINX. If you do post, please post a link to the datasheet for the sensor you are using.
10-12-2014 03:54 PM
Thanks Nathan. You have taught me a lot onhere. Thank you for all your work!! I will get LINX and repost.
10-13-2014 01:05 PM
I use Read pulse width in LINX toolkit, works perfect.
10-13-2014 01:08 PM
Awesome, that is great to hear.