Back again with some form of control for my soil heater and some test results, graphs yay!
This bit of scribble outlines the basic testing setup with two temperature sensors, one on top, one on the heater. The mosfet and heater is fed from a separate 5V supply and switched by pin 13 on the Uno.
The graph below shows some promising results, the heater temperature was limited to 40C and the soil temp to 30C, after about 800 seconds the heater could start to back off and just maintain a constant soil temp of 30C.
The graph above is still very noisy, so I set out to change the voltage reverence for the analogue to digital conversions to the quieter 3.3V. In addition I added some decoupling close to the tmp36 sensors.
The code was re-arranged to provide the needed temperature control and ADC settling time (apparently the atmegas ADC is multiplexed and needs time to settle in-between samples).
/* * initialize the serial connection */ void setup() { Serial.begin(9600); //Start the serial connection //to view the temperature open the serial monitor analogReference(EXTERNAL); pinMode(12, OUTPUT); } int twoSeconds = 0; void loop() { //getting the voltage reading from the temperature sensor analogRead(0); delay(1000); int reading1 = analogRead(0); analogRead(1); delay(1000); int reading2 = analogRead(1); //conversion from reading to voltage float voltage1 = reading1 * 3.3; voltage1 /= 1024.0; //converting from 10 mv per degree with 500 mV offset float temp1 = (voltage1 - 0.5) * 100 ; float voltage2 = reading2 * 3.3; voltage2 /= 1024.0; float temp2 = (voltage2 - 0.5) * 100 ; twoSeconds++; //comma separated output Serial.print(twoSeconds);Serial.print(" , "); Serial.print(temp1);Serial.print(" , "); Serial.print(temp2);Serial.print("\n"); if(temp1 < 30){ if(temp2 > 40){ digitalWrite(12, LOW); } else{ digitalWrite(12, HIGH); } } else{ digitalWrite(12, LOW); } }
Here is another graph with the temperature sensors output swing halved. Clearly showing the measures taken to reduce the power supply noise and allowances for ADC settling time having a positive effect.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.