Project Eight - Thermostat


The final project in our series may seem complex, but is quite simple. We use the potentiometer to allow user input of a temperature value, and using the temperature sensor – if the ambient temperature rises above the value set via the potentiometer the relay is activated.
  1. Connect the Temperature Sensor to the Analog A0/A1 input jack, like it was in Project 7.
  2. The Grove produces an analog voltage on its D1 output, which is connected to Arduino A0 analog input on the A0/A1 input jack.
  3. Connect the Potentiometer to the Analog A4/A5 input jack.
  4. The Potentiometer produces an analog voltage on its D1 output, which is connected to Arduino A4 analog input on the A4/A5 input jack. Connect the Relay to the D2/D3 input jack.
  5. The Arduino’s D2 pin sends a signal to the Relay on the D1 connector. The Relay’s red light indicates whether the relay is on or off, and the relay makes a clicking sound when it switches.
Now upload the following Arduino sketch:
// Project Eight - Thermostat // int a,c,d; int z=3975; int relaypin=2; float b, q, resistance, temperature; void setup() { pinMode(relaypin, OUTPUT); } void loop() { a=analogRead(4); b=0.0488*a; c=int(b); q=analogRead(0); resistance=(float)(1023-q)*10000/q; temperature=1/(log(resistance/10000)/z+1/298.15)-273.15; d=int(temperature); if (d>=c) { digitalWrite(relaypin, HIGH); delay(500); } if (d<c) { digitalWrite(relaypin, LOW); delay(500); } }
Try turning the potentiometer to the right and left and see if the relay turns on or off.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking