Last stage debugging - Help !![SolveD]

Do i need to take another reading on same pin and ignoring the previous or can i take a sample of 2 to 3 readings and then calculate an average ?

Average subsequent readings if you like, but ignore the first one.

Thats great bill, . .

I did as you suggested, reading the pin twice, and ignoring the first reading,. . Im getting my real temperature reading . . Room temperature actually reading 26.86 *C . .

My only issue now is, the pump time off . .

Will be looking in that!

Thanks again . . + karma for you .. :smiley:

Room temperature actually reading 26.86

Is your temperature sensor REALLY capable of 0.01 degree C resolution?

No not all.. its just displaying up to 2dp.. i think it has an incremnt value of 0.5.. aprox. if im not wrong.. i know the lm35 has a resolution of 10 mv per degree celsius.. ..

i do know that it will be far better if this voltage would have been amplifie before being read by the analog pin .. but still its fair enough for the actual project.

Any help on my pump time off issue.. i did try to change values of the timerRate but to no avail.. is there anything im missing.. ??

is there anything im missing.. ??

The latest code?

And how is the pump supposed to behave?

Im actually not at home with my pc.. i cannot post the latest code right now.. i shall do it as soon as i can!

The way the pump behave is i made it run for 7 seconds before going off or moist percentage is > than 90 ..

Actually i just simulated it with a led, the reason behind such action is my pump output flow is quite big, so to prevent any flooding from happening i think of this.

my led representing the pump would light on for 7 sec on removing the soil probe,since i kept these in the air,my led will flash off and then on again because its still under 85 % ..

since i updated my code with a timer for my lcd display as being flashy, my pump wont stop with the timer 7 sec, only if soil percent >90% ..

I shall post the code at soonest ..

thanks!!

Hello . .

Find attached code still titled under Rev 5 (Updated Version) :slight_smile:

All is well, except for the "Pump time off" .. .. as explained above in regards to control behavior of pump.

Thanks . .

taz ..

GreenHouse_Rev_F_05.ino (11.3 KB)

Minor but you can remove some some code in that -

'lcd.begin' performs a ''lcd.clear''
'lcd.clear' sets the cursor position to 0, 0

It looks to me as though you should set lastPump to millis() when you turn the pump on, not adjust it when you're turning it off.

Minor but you can remove some some code in that -

'lcd.begin' performs a ''lcd.clear''
'lcd.clear' sets the cursor position to 0, 0

Will remove some codes as explained above...

wildbill:
It looks to me as though you should set lastPump to millis() when you turn the pump on, not adjust it when you're turning it off.

As if i can see that working .. :), anyway i shall test it in the afternoon and update the post here.

Thanks

Regards

Taz ..

Hello,

I did try the change in updating lastPump to millis, when my pump is set to on, here also its not working as it should.

changes brought to code:

void pumpControlON (){
  if ( percentage_Moist <= 85.00 ){
    digitalWrite(pump_Active,HIGH);
    pump_Status = true;
    lastPump = millis();
  }
}


void pumpControlOFF (){
  if (( millis() - lastPump >= timerRateX ) || (percentage_Moist >= 90.00)){
    //lastPump += timerRateX;
    digitalWrite(pump_Active,LOW);  
    pump_Status = false; 
  }
}

The thing i observed is before adding up the conditional function as displaying active and inactive onto the lcd. It did work very well, that is pump run for 7 secs and goes off, if moist percentage still under 85%, it runs again. Since my probe was kept in the air, my led would flashed off after a duration of 7 sec.

May be there are too much things going on in parallel, like displaying percent moist, displaying if pump is active or inactive and checking if threshold value is reached.

Any suggestion ?

Post the latest complete with changes as they are hard to visualize ...

The code attached with not much changes, only this part of lastPump = millis(), trying to remove the small bug, concerning my pump not getting off after a delay.

GreenHouse_Rev_F_06.ino (11.4 KB)

I'm sure that it has been mentioned that adding time variables is not a good thing.

Why is the lastPump = millis() line commented out in pumpControlON()? That is where you should be record when the pump was turned on. Recording some time in the future in pumpControlOFF() is just plain wrong.

I added the code lastPump = milli(); in the pumpControlON() while first commenting the line //lastPump += timerRateX;, to test if things changed, but unfortunately it remained the same..

So i commented it out, to return my code to original to see if there was any contrast between the change.

No change in behavior detected, but the thing which keeps tickling me,is how come it worked before I added the timer for the LCD, i did try to remove the timer for LCD to see if it works, but to no avail . . .

I'd suggest then, that you put your pump control code into a much simpler sketch to test it in isolation. If that doesn't solve it, it may help to take the moisture sensor out of the equation too and simulate it, using the serial port for instance.

Edit: Before resorting to serial, just using a pot to get a simulated moisture reading might help.

Hello everyone,

It seems i undertood the philosophy behind the pump control, and why it was not working, and how it did work as present. :smiley:

taz3m:
The thing i observed is before adding up the conditional function as displaying active and inactive onto the lcd. It did work very well, that is pump run for 7 secs and goes off, if moist percentage still under 85%, it runs again. Since my probe was kept in the air, my led would flashed off after a duration of 7 sec.

Today i did observed the real scenario taking place, as such, my Soil percentage value on lcd displayed around 83 %, with my led for pump lighted on, part of code concerned :

void pumpControlON (){
  if ( percentage_Moist <= 85.00 ){
    digitalWrite(pump_Active,HIGH);
    pump_Status = true;
      }
}

void pumpControlOFF (){
  if (( millis() - lastPump >= timerRateX ) || (percentage_Moist >= 90.00)){
    lastPump += timerRateX;
    digitalWrite(pump_Active,LOW);  
    pump_Status = false; 
  }
}

Here is the control philosophy: If percentage moisture is < 85%, my pump is set to ON, and my timer start counting until 7 secs, if after this time duration, my percentage moisture is > 85% (we should not get confused here with the upper threshold of moisture percentage 90% set), my pump would go off after the counted millis algorithm reached its 7 secs.

Remember i did underline that pump did go off, with the led flashing off, before adding,conditional function for displaying active and inactive onto the lcd, as reference to the above quote, i was wrong in pointing out the culprit :). At that time i was still running under code GreenHouse_Rev_F_04, where i noted that my serial port was still opened and running all my Serial commands.. These Serial.commands; explained why my led will flashed off after the 7 secs even when moisture percentage was showing 0 %, while my probe was in the air.

As far as i did understood the cycle of the code, with the serial command lines running, the Uno(slowed) would have time to process the 7 secs millis algorithm, until it updated its percentage moisture.
With program running under code GreenHouse_Rev_F_05, where the serial port communication is disabled, the Uno response time increased, the moisture percentage reading get updated before 7 secs millis algorithm is processed, and since % is reading < 85%, there will be no led flashed off, NO Pump Off . . 8) as mentioned above in the control philosophy.

I did observed this whole situation, with the real scenario occuring today, where my soil moisture percentage was displayed with the value in the range of 83 to 87 % , this time i was not simulating dry soil in placing the probe in the air.

wildbill:
Edit: Before resorting to serial, just using a pot to get a simulated moisture reading might help.

we were close . . . :wink:

Any suggestions, views and analysis are welcomed towards the observation made to confirm if i did understood it correctly.

Thanks

taz . . .

Hello everyone,

Would like to thanks all of you who brought me much help in understanding and debugging my codes.

I did put it under observation for almost 1 week and found it working as expected. moving towards circuit building now.

Thanks again for your time.

Regards

Tazlim.