Introduction: Arduino Climate Monitor

So living in a city with high electricity bills I've wanted to reduce how much I spend each year but I don't really want to live in an uncomfortablely warm or cold room. I've also had a real passion for passive climate design for houses and did a bit of research. (A quick summary is provided down the page so don't worry.)

What I thought would be a cool idea would be to actively try to heat up and cool down the rooms I'm in by collecting the data from some sensors.

This project, as the title says, is about creating an arduino device that tracks and records the temperature and humidity values and is able to send it via bluetooth or wires to a recieving device. Additionally if there is no device it gives you real time feedback through an RGB LED. (The colour values can easily be changed by for this purple is the set "ideal" temp and the bluer it gets the colder, and the redder the hotter.

Above you will find the coding for the Arduino as well as STL files to 3D print your own case for this.

What ISN'T provided in this Instructable is how to connect the arduino to a Bluetooth device, although the option is there I haven't provided this but there are plenty of tutorials on how to do this.

Now lets begin.

Step 1: Material Lists

The bill of material required is mostly simple and cost effective.

  • Arduino Uno Board (The one that comes in a starter kit will work fine.)
  • Arduino Temperature and Humidity Sensor (For this I used the Arduino DHT 22, I have also tried the DHT 11 and that works just fine)
  • Arduino PIR Motion Sensor (It looks like a hemisphere and are quite common to find)
  • Arduino Wireless Bluetooth Module
  • A Power Source (Although I used a battery pack here, you can quite easily use a power cable. Just make sure it is the correct wattage and amperage for your area)

Also You will need a lot of wires, here I have split and soldered them together so additionally you will need

  • A lot of wires
  • Solder Station
  • Heat Shrink.

Step 2: Setting Up the Hardware for Testing

I've never been a big fan of bread boards so this may be a bit tricky for some people. Hopefully its not that bad.

Looking at the code its pretty easy to follow.

The DHT22 (or other temp/hum sensor) goes in Analog 1, (or A1)

The Motion Sensor will go into digital pin 7.

The Bluetooth goes in Digital Pin 2 for RX, and Digital Pin 3 for TX. (Youi can read it on the sensor)

For the LED, Red will go in 8, Green in 9, and Blue in 10. I use the same colour wires to make it easier to spot, also on a UNO board there is a gap between 7 and 8 so its easier to see when trouble shooting.

Now for the part that gets people, I made up a few split cables by soldering them together.

As seen in the photos, the Power (or VCC) Cable will need 2 outputs (female ports) to 1 input (male port). For the Ground, you will need 4 outputs (female ports) to 1 input (male port), 1 less output if you are not using bluetooth.

For the Ground, plug each female port into all the sensors where there is a "GRD" or " -" sign and plug the male pin into the GRD port on the Arduino UNO.

Only the motion Sensor and the DHT need Power, so plug the female ports into the pin labled "VCC" and plug the male pin into the 5V port on the Arduino UNO.

Step 3: The Meat & Potatos (The Coding)

You can download the code in the link. You can copy and poaste it and it should work correctly if all the libraries and ports are correct. Below I will explain parts of the code and how to change it for what you want.

Everything before the set up is pretty straight forward, make sure the libraries are properly installed, make sure the wires are plugged into the correct pins (or change the code to match the correct pins).

In variables, you may want to change some of the values to suit your needs.

  • "IdealTemp" is what you want the ideal temperature of the room to be at, if it goes outside of a set value it will act upon it.
  • "changer" is the value for how quickly the light will fade. By default is is set to 5 (out of 100) and will take 20 ticks to go from 0 to 100 and 40 ticks to do a full fade. The higher the number, the quick it will fade.

In setup, keep most of it the same, if you are not using Bluetooth then remove the "BTSerial.begin(115200)" line.

  • Remember to have BTSerial.begin(XXXXX) & Serial.begin(XXXXX) with different channels otherwise issues can occour.
  • 'brightness' is only set to 50 here because if it is at 0 or 100 it can cause issues as well.

In loop, if youare not using Bluetooth then remove the BTSendInfo line. By default the delay is 1/2 a second (so 2 ticks a second). change this as you wish.

In "TempAndHumSensor", you can add in the line if you want to work in Fahrenheit as by default it is in Celcius. Sometimes the hardware is precise but not accurate and needs adjusting in a linear fashion. For my code I had to change it to 666.1 to get both a precise and accurate readout by comparing it to another thermometer that I knew worked. If it is working for you without altering it then change this number to 0.

"setColour(int RedValue, int GreenValue, int BlueValue)" is a pretty standard command for changing all the values for the LEDs in one line. just leave this one as is.

In "BrightnessSetting" with will make the LEDs fade by using the brightness and changer value.

  • Brightness gets in/decreased by changer and is constantly changing between 0 & 100
  • By changing "changer" in variables it will fade quicker or slower.

"LightBehaviour" is a complicated one that looks messy but is where you can really personalise this. By default this code works with Blue, Red, and Purple.

  • The 2 lines "ColourValue = ((255/100) * brightness) +130" is the main line for fading the light, 255 is the standard max value for arduino LEDs and by dividing it by 100 you make it a percentage. When you times is by "brightness" it is changing the max value into a percentage relevant to 255. E.g. if brightness is 50 then the ColourValue will be 127.5 because its 50% of 255.
    • The +130 is for hardware issues, sometimes the LED will turn off before it reaches 0, this way you can manually adjust the code to match what the hardware is doing. If you don't need this then change it to +0.
  • The lines "comparison < -5" are how far the actual temp is away from the ideal temp before it says its too hot/cold. If you are going to change this buffer (by changing 5 to whatever you want) then make all the 5's the same new number.
  • REMEMBER: These colours are easy to edjust, I used Red, Blue, & Purple because they are easy. If you want to put the time in you can make them become whatever colour you want with the right code values.
    • E.g.
      • setColor(255, 0, 0); // red
      • setColor(0, 255, 0); // green
      • setColor(0, 0, 255); // blue
      • setColor(255, 255, 0); // yellow
      • setColor(80, 0, 80); // purple
      • setColor(0, 255, 255); // aqua

The "SetLight" cammond is a messy one that doesn't seem to make too much sense, but it the right (or wrong) situation the code can pretty easily break when you try to optimise it.

  • As we don't want it running all the time having the motion sensor will put it into more of a Sleep mode when you are not around. By default, if it doesn't detect motion for 10 seconds then it turns off the light. This is because we currently have a 0.5 second delay per tick, and it increases the "lag" value by 1 each tick (except on the first tick as that one is increased by 2.
    • This delay can be increased by changing the "(lag > 20)" to a larger number. E.g 120 for 60 seconds.
      • Or by increasing the delay from 500 to 1000

The "PrintData" lines is where you can do any troubleshooting you need. by default it will only show the temp and humidity values but you can very easily show or hide whatever you need to test out.

Happy Huntings.

Step 4: Just for Show (3D Printed Case & Installation)

Attached you will find an STL file for the shell in the images titled "Backing" and "Case". Once 3D printed you can install the components into the shell. (You will need microscrews for the best result. Ideally it would be best to by a glasses repair kit which has hundreds for tiny screws for fixing hinges and such in glasses.)

All the mounts will make is possible to attach the sensors but the wires can sometimes be a bit tricky because of the restricted room.

You can see in the photos where to screw in each sensor. The DHT22 is only needed to be screwed on the 2 bottom ones, the top mount is for support. A few times printing the shell I needed to sand down the top support to get it at the right angle because of thick threads though so keep that in mind.

The motion sensor is really easy to install because of the symmetry, although I fond it easier installing it so the cables were on the bottom to save space.

The LED was a bit tricky and depending on if you want to use just a single one or a strip will determine how you mount it. For me I attached it to the Arduino board so it lit up the back of the motion sensor for a cool effect.

The Arduino UNO is easy to screw on but because of the hole sizes you will probable need washers to connect the board.

The Power back is easily screwed on but it is recommended to use countersunk screws so you can still fit in the patteries.

Once all of the Parts are mounted, then screw on the backing and mount it on a wall.

Step 5: The Final Thing

So now you have it up and running. Hang it up and test it out.

Arduino Contest 2017

Participated in the
Arduino Contest 2017