few hours with… Arduino/ Elegoo thermometer with relay and Bluetooth connection (Part 2)

few hours with…
5 min readNov 29, 2020

In part two I planning to add to the project some screen and some control mechanism for my thermostat. What's done till this you can find here.

All details I will use in this tutorial comes from my Elegoo Starter Kit (wrote a blog about it here). First I will connect the LCD module just to be sure it works. In the Starter Kit book, you can find a wiring diagram, how to connect it which looks like this:

image from “THE MOST COMPLETE STARTER KIT TUTORIAL FOR MEGA 2560”

This is LCD 1602 module, you can find it in my affiliate link here. I'm not sure if this is the best option for a screen but I already have it so I'm using it. If you decide to use it then one more important detail is the 10k potentiometer (detail with a black circle in middle on a breadboard). When you connect all you will need to adjust the potentiometer till you can read what's written on your screen.

After wiring everything together open your Arduino software, delete all, and past in the code from here. If everything went well then you should get the same result as in the image. I'm not sure if the latest Arduino software has a built-in LiquidCrystal library, if not then you will have to install it (you can find it in Elegoo Starter kit materials). Another thing — don't forget about the potentiometer. Turn it clockwise or counter-clockwise until you have clear text on the screen. If everything works, then we can proceed to the next detail in our thermostat.

image from “THE MOST COMPLETE STARTER KIT TUTORIAL FOR MEGA 2560”

Next, let's connect the LCD display with the IR receiver module and IR remote. On a quick search, I did not find Elegoo IR remote selling separately from some kind of kit but here is a similar product that should work similarly, affiliate link here.

upgraded image from “THE MOST COMPLETE STARTER KIT TUTORIAL FOR MEGA 2560”

IR receiver model has three pins so wiring is very easy. Let’s add the IR receiver module to the previously wired LCD display. Code for the next part you can find here. Now you should be able to press buttons on the remote and buttons name or number will appear on display. If you want to add a different control mechanism, you can do it. The idea why I chose IR remote was because it requires fewer pins to the microcontroller. In the third part, I'm planning to replace the Elegoo microcontroller with smaller, probably Arduino nano.

If everything went well now let's connect everything with components from part one.

To our new wiring diagram let's add the Bluetooth module, 5Vrelay, and temperature sensor. The final code is here.

The final code is made so we can see on screen the current temperature in celsius “T=24C”. Next “H= 54” stands for humidity value in %. The next part “On<10” shows when the 5V relay will turn on the power on the power extension cable. In this case, when the temperature will be below 10 degrees relay will switch on. This is the starting value, you can change it with remote pushing VOL+ or VOL-.

I'm planning to use a heating device, so my project's default value is 10 degrees and the device turns on when it's below this value. If you have the opposite situation and need to add some ventilation device you can make small code changes to do that. Before we start changing code remember — all temperature values are in celsius. If you need some other values, you will have to do some math.

Three code lines which need to be changed if you need opposite functionality:

In code on line 18 you will find the following code “int onOffValue = 10;”. Here you can change the default value for the on/off switch. Just change number 10 to temperature what's necessary for you.

In code line 73 you will find the following code “lcd.print(“On<”);”. This is line prints “On<” on the LCD display. If necessary, here you can change the smaller symbol to larger, just change “<” to “>”.

In code line 85, you will find the following code “if(temperature < onOffValue)”. Here change the “<” symbol to “>”.

One more thing which was important to me was capturing the lowest and highest temperature during the time it's working. So I added in code two values which change when the temperature reaches new highs or new lows. So small “m23” shows the lowest temperature and “M24” shows the highest temperature from the time it was turned on.

And part 2 final wiring diagram is here:

upgraded image from “THE MOST COMPLETE STARTER KIT TUTORIAL FOR MEGA 2560”

For the third part, I'm planning to put everything in a nice 3D printed box. If everything will go with a plan in the third part everything will be soldered together on a perf board then make a 3D model for the box were put all components in. I have ordered some final pieces for this project so hope to get them soon and finish this project.

End of part two…

--

--

few hours with…

Writing a blog about learning and exploring new stuff just for fun.