The beginning!
Hi all!
This is mostly just a repeat of what I said over at the Arduino forum about my greenhouse automation project. I basically wanted to take some inputs from the physical world and use them to control some conditions and effect the outputs. I originally decided to use a Pi with the project but I turned that into a media center. I therefore decided to give the Arduino a go and I have to say I'm finding it to be a quality piece of kit.
I have myself an Uno and a few components. For the temperature sensor I decided to go with a AD22100STZ. Its quite user friendly, it does all the linearisation on the chip so all I have to use is an equation given by the manufacturer on the data-sheet. I get about 0.2 DegC sensitivity due to the -50 to 150 and 10bit ADC ranges. I have here a quite precise stand alone temperature probe that I am going to carry out some comparison tests with which I will post when I have the results. I may be able to tweak the equation to get better accuracy.
The code is coming along nicely with some variable integer and floats. I am communicating and printing through the serial port. I have some if statements based on my required temperature setpoints which are currently just controlling a digital output which I will soon change to a PWM output to my servomotor which I just need to sort a power supply out for.
The code for anyone interested:
//temperature readout code int outputpin = 13; int inputpin = 1; int inputmemory = 0; //use for the serial read float tempout = 0; //use for temperature out float setpointhigh = 26.00; //high temperature setpoint float setpointlow = 25.00; //low temperature setpoint void setup() { Serial.begin(9600); pinMode(outputpin, OUTPUT); } void loop() { inputmemory = analogRead(inputpin); //read analogue pin on pin 1 tempout = ((inputmemory*(5.0 / 1024))- 1.375) / 0.0225; Serial.print ("Temperature: "); Serial.println(tempout); //print temperature value to serial Serial.print ("ADC value: "); Serial.println(inputmemory); //print ADC value to serial if (tempout >= setpointhigh) digitalWrite(outputpin, HIGH); //high setpoint if (tempout <= setpointlow) digitalWrite(outputpin, LOW); //low setpoint delay(1000); //delay 1 second before next read }
And some photos:
The boards |
Testing a digital output turning on/off when my set points are reached |
The code and serial monitor |
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home