Introduction: Solar Water Differential Temperature Controller
I'm participating on Solar Contest so, If you like it, please vote :)
This Instructable is about making a cheap differential temperature controller to activate/deactivate solar system circulation water pump and see the data values (graphics) on the web .
You can read about it in Wikipedia:
A solar controller is an electronic device that controls the circulating pump in a solar hot water system to harvest as much heat as possible from the solar panels and protect the system from overheating. The basic job of the controller is to turn the circulating pump on when there is heat available in the panels, moving the working fluid through the panels to the heat exchanger at the thermal store. Heat is available whenever the temperature of the solar panel is greater than the temperature of the water in the heat exchanger. Overheat protection is achieved by turning the pump off when the store reaches its maximum temperature and sometimes cooling the store by turning the pump on when the store is hotter than the panels.
- English is not my main language
- You will work with 220V
- I'm not responsible for ANY problem you may have doing this Instructable. Do it at your own risk.
Used materials / software:
- Micro-controller ESP8266 (ESP-01 or ESP-12)
- 2 x DS18B20 Digital Temperature Sensors
- 3.3v / 5V Power Supply or AMS1117/LM1117/LD1117 to power on ESP8266 with 3.3v and a 5V power supply like a standard phone charger
- Relay to connect to 220v
- 2N2222 NPN transistor (found on computer power supply)
- 2 x 1K resistor
- 47K resistor
- FTDI232 USB to Serial converter
- Thingspeak - Internet of Things platform
- Arduino IDE with esp8266 support
You can buy most of this parts on Ebay or Amazon or any other electronics site.
Step 1: Hardware
Micro-controller ESP8266 (ESP-01 or ESP-12) is a really tiny micro-controller with integrated Wifi. ESP-01 has 2 usable pins and ESP-12 has 8 usable pins.
Now its easy to program it like Arduino with Arduino IDE but you have to use a USB to Serial converter like FTDI232. There is a lot of tutorials explaining that, like here. If you want short instructions you can check my notes or check next step.
For this project we will use ESP-01 because we just need 2 pins, one for connecting two DS18B20 temperature sensors (GPIO2) and another one to switch on/off the relay(GPIO0). We can connect more than one temperature sensor to just 1 pin. You can read more about that here.
ATTENTION: ESP8266 works with 3.3v NOT 5v. You will need 5V just to power up the relay (vcc)
If you are comfortable with electronics you can savage some computer motherboards or any other kind of boards and try to find a 3.3v AMS1117 or LM1117 or LD1117. Then you can connect it to a 5v Phone charger so you have a 5V and 3.3V to power on ESP8266 to power ON the relay. There is a lot of schematics for that on google. Here you have an example.
ATTENTION AGAIN: WORKING WITH 220V: We will use a 5v Relay to switch on/off the circulation pump. There is a very simple and good tutorial about relays here.
Step 2: Working With Arduino IDE + FTDI232 + ESP-01 / ESP-12
This tutorial will not cover in detail this part, there is a lot of Instructables covering that part, but, here I give some quick instructions:
Connect it like picture
Instructions for flashing/uploading sketches with Arduino IDE:
- Power on FTDI and make sure computer is detecting it**
- Connect GPIO0 to Ground
- Power on a separated power supply (3.3V) (USB PORT CAN'T SUPPLY ENOUGH CURRENT FOR FTDI232 and ESP8266)
- Upload sketch
- Power off power supply
- Disconnect GPIO0 from Ground
- Power on power supply
Try with BLINK example but change PIN 13 to PIN 2 to enable the BUILTIN_LED
** On linux, if you execute "dmesg" you will have something like: " FTDI USB Serial Device converter now attached to ttyUSB0 "
On Windows you can see on Device Manager if it's present and OK.
On Arduino IDE, it must show the port on: Tools -> Port (in my case ttyUSB0)
Step 3: Code
Now its time to upload the code.
In the code its defined that pump will start if there is 7C degrees of differential and then switch off if there is 5C degrees of differential,so, if you need other values you have to change it.
Before you upload the code, don't forget to:
2. Set lower and upper differential limits:
const int minLimit = 5; const int maxLimit = 7;
3. Change the Wifi Name and Password here:
char ssid = "++++++++"; // your network SSID (name) char pass = "++++++++"; // your network password
4. Change to your Channel Number and APIKey created on Thingspeak here:
unsigned long myChannelNumber = +++++++; const char * myWriteAPIKey = "++++++++";
Later, if you feel comfortable with coding, you can do other stuff like change the alarms for each sensor and implement email or SMS notifications :) maybe I will do it later...
After you upload the code, if you open serial monitor, you can see the output like on second image.
Here you have the CODE
This code was adapted from the Thingspeak library examples.
Step 4: Wiring
Ok, now it's time to connect all together.
THIS STEP IS VERY IMPORTANT BECAUSE
Almost every tutorials I've found in Internet shows the relay module directly connected to ESP8266, like in 2nd image. It didn't work with my 3 different relay modules!
They worked fine with Arduino but not with ESP8266. I was having different behaviors with every module.
ESP8266 will not boot if you have GPIO pins (0 and 2) connected to relay module. This is because these pins are used to change boot modes (eg: Enable flashing , Serial programming, etc). Maybe they work with some relay types but it didn't work with mines, so, I had to connect it like in the 1st image with the 2N2222 NPN transistor.
This schematic is based on this tutorial.
Another interesting thing is the working mode of the relays. For example, relay of picture 3 is the inverse of picture 4. The one on Picture 3 switch's ON if it's HIGH (on code). The one on Picture 4 switch's ON if it's LOW (on code). So, you have to change it depending of your relay module.
THANK YOU FOR READING THIS INSTRUCTABLE.
If you like it please vote :)
PS: Please tell me if you find any error