EcoRenovator (
-   Geothermal & Heat Pumps (
-   -   IOT heatpump controller (

Acuario 01-16-17 09:20 AM

IOT heatpump controller
5 Attachment(s)
Sadly my old Roca heat pump compressor died.

Fortunately my local scrap man turned up for a pickup and had a mid-size Daiichi external unit in the back of his van. I persuaded him to part with it on the off chance it worked, and as luck would have it it did, and it appeared to have been gassed down so still contained a charge, result!

So it was time for a new controller :D

I have come to several conclusions having built various controllers both for solar hot water and for heat pumps over the last few years:
  1. DS18B20 temperature sensors are a pain. Better and easier to use 10K NTC thermistors.
  2. PIC processors are fun but limited and libraries are few and often don't work. Ethernet or any networking is a big challenge.
  3. Arduino UNO and NANO are cheap and cheerful but have limited memory so adding a web server with various pages isn't really possible.
  4. Arduino Mega is better but becomes bulky with peripherals. Web pages are possible but need to be either on an sd card or coded into an output stream. It also struggles with performance serving web pages.

So, not too long ago a wizzy little chip appeared on the market and took the world by storm - the ESP8266.

This chip comes in various module flavours with different flash memory sizes and pin outs. For experimenting you can't go far wrong with the NodeMCU board as it comes with everything on the pcb, just plug it in to a USB port and you're ready to go. It even has an on board interpreter, LUA, however I'm not a fan so don't use that.

The great thing about the esp is that it has all the Arduino code available so you can use it as if it were an Arduino, even using the Arduino IDE (although I personally use Visual Studio with the Visual Micro add-on).

Most Arduino libraries work out of the box, others have been ported to the esp so it really is a dream.

It has built in WiFi, loads of memory, Works well as a web server and can be upgraded over the air (ota), which means you can send your updated code to it from anywhere, no need to plug in cables or even physically touch the device.

So, this was my choice for the new controller.

I recently designed a pcb for a generator auto start system that can take either an Arduino NANO or an ESP12 so I used one of them for the main controller.

The esp is mostly hidden as it needs 3.3V so I use a DC/DC converter from 5V which sits above the esp.

The control board is sparsely populated, in reality there are only 6 resistors and a few connectors used.

The esp only has one adc pin, this I use with a 10K thermistor for reading the actual temperature the water has reached . These you can buy for very little money with a waterproof case and connector lead from ebay.

As I have moved to thermistors for Reading temperatures I obviously need more analogue inputs. For the extra inputs I'm using a PCF8591 I2C module (from ebay) with 4 x sensors. Also for controlling the relays another I2C device, a PCF8574A expander, (ebay again). I wanted the control box inside and the relays/sensors out so running a 4 core cable and using I2C to talk to the peripherals works perfectly.

So, the esp is happy to serve up web pages so rather than as I have done in the past, add a display and keypad, as we are going IOT it should all be done via web pages, two to be precise, one to show status information and the other to perform setup operations, much prettier than an LCD display and much easier to use!

This is the status page showing current operating parameters:

And this is the setup page:

Being connected into my local network I can open up the port the controller is using, set up port forwarding on my internal router and can then access my controller from anywhere I can connect to the internet. And yes, it does have login security!


AC_Hacker 01-19-17 11:30 AM

Acuario Rules!!

AC_Hacker 01-19-17 11:33 AM

One more thing...

Were you ever able to achieve success in controlling a variable-frequency mini-split??


Acuario 01-19-17 12:10 PM

1 Attachment(s)
That's a Project I have pending and made much easier now I've mastered the esp and real time os. The machine is still in my shed connected up and waiting.

The problem to date (apart from time...) has been finding a device powerful enough and flexible enough to use for the project, this I think is now solved with the esp. I didn't really fancy trying it with a pi or c.h.i.p. although if the esp gives me problems I may try one of them.

By the way, aside from the heat pump controller I have "IOT'd" the controllers for both the solar hot water and solar central heating. With the hot water controller I added statistics for interest and have been surprised that even now in early January I've had just over 25 hours of running time in the last week.

pedro 01-20-17 08:02 PM

Can you describe a little more how you would control a pump? I looked up the expansion module. Do you just use that to control a relay that sends power to the pump?

Acuario 01-20-17 11:25 PM

The expansion module just gives me more outputs without the need to either use up GPIO ports on the esp or run extra cables. As it works on the I2C bus it uses the same 4 control wires as the ADC converter.

The outputs from the expander run 3 relays, 2 are on one of the little 2 relay boards that have all the driver circuit built onto the board. These run the fan and 3 way valve. The other is a solid state relay (SSR) for the compressor.

This is an old unit that has a capillary tube so there is no need to control an eev.

Ron342 01-24-17 10:03 AM

Well, i had been sitting here looking at this $6 ESP8266 i ordered and wondered if i would live long enough to be able to learn to get it to report temps over wifi to the web and controll my geo h/w heater build - and you've already finished it - great work guy!
There is also a esp based bpard for about $10 that has expansions with relays to report temp and humidity logging and control of pumps etc thru the relays but they are i think relays that need to be constantly powered on ie not tripped.
Google "Sonoff" they are all over the web.
I wonder how this stacks up against Xringers X10RF web control??
If you get a chance, when you finish, a detailed (read handholding) description of how you hooked it up and programmed it would be a huge boost to those of us who didn't grow up with this stuff!

Acuario 01-25-17 05:08 AM

I've seen the sonoff devices, good devices and can be re-programmed so could be used as a pre-built controller with a few additions.

The sonoff SC is the unit that has the humidity/temperature sensors but they have opted to use the atmega328P (read Arduino) for adc to overcome the esp limitation.

There's a detailed look with modifications here:
Sonoff SC with MQTT and Domoticz support - Tinkerman

Also a guy called Peter Scargill has done lots with them
IOT Technology Blog

I'll post more details in a subsequent post.


Acuario 01-25-17 09:30 AM

Putting it all together - how it works
4 Attachment(s)
If you haven't read my posting on the dew point monitor it would be advisable before reading this as it may make more sense...

Part 1 - the hardware

The schematics for all 3 parts of the project are incredibly simple.
There are 3 parts, 2 for the controller and the separate dew point monitor.

1. Main controller

This comprises of little more than a (not shown) 5VDC power supply, 5V to 3V3 power supply (not shown either), an ESP-12 and the resistors needed to make it work and a 10K thermistor connected to the adc input. The I2C bus (2 wires + 5V power) is fed out to the peripherals that are located inside the external unit. The RS232 connection is really only used to program the controller the first time (or if something really screws up!) as any code updates can be done remotely ota (over the air).

2. Peripherals

The peripherals comprise 3 x pre-built modules, one to read the temperatures using thermistors and the other a port expander to switch the relays (2 on a pre-built board) on and off. The main relay for the compressor is a 40A solid state relay.

3. Dew point, temperature and humidity monitor

Again ridiculously simple, an ESP-01 connected to a DHT-22 humidity/temperature sensor, a status LED and a button for WPS. Not shown is the 5VDC power supply.

Part 2 - the software

The whole system runs on the Arduino ESP8266 software API and is written in C for the main code and HTML for the web pages.

All the libraries used in the project are open source.

The libraries are:
  • Timezone - this allows the clock, which is synchronised from an NTP time server, to display my local time
  • ArduinoOTA - This enables ota updates
  • ESPAsyncWebServer - this is a much more responsive web server than comes with the standard Arduino ESP implementation
  • Ticker - This allows for co-operative multi tasking, i.e. deciding how often a particular code module will be run. There is little point reading tempertures every second, every 30 is more than sufficient whereas updating the clock every second gives a better visual display. This allows control of this.
  • Wire - This is for the communication over I2C from the controller to the peripherals.
  • EEPROM - Allows reading/writing to the ESP eeprom to store/retrieve operating parameters.
  • WiFiUdp - This is used for the UDP clients to communicate with both the NTP time server and the Dew point monitor.

The project also uses the ESP SPI file system (SPIFFS) for storing web pages and stuff required by the web pages.

The code is broken down into modules with discreet functions:
  • Read system settings - done once at start up
  • Read sensors - every 30 seconds
  • Check defrost step and manage defrost cycle (if defrost is running) - every second
  • Read dew point sensor - every 60 seconds
  • Read and/or refresh time from time server - every second to update time, every hour to synchronise
  • Logic to check if a defrost is needed - checks evaporator temperature and if < set defrost point for > defrost delay time, run a defrost cycle
  • Set relay states - turns relays on and off as needed

A web server is also running in the background to handle any user input. Updates are sent to the web browser using a protocol called server-sent events. This protocol is handled on Chrome (and others) but not Internet Explorer or Microsoft Edge. The alternative would have been to use AJAX but that would have needed to be initiated from the browser so immediate updates wouldn't have happened. Another possibility that I tried out was web sockets but I kept getting timeouts so ended up abandoning them.


jeff5may 01-18-21 03:45 PM

Ok so I decided to post in this thread as not to pollute the other, newer version thread.

I've recently been tinkering with more phase change monsters and have decided to have another go at the custom built interface. Nobody seemed to like the Arduino uno or nano modules, due to the limited functionality. Since these esp boards are super affordable, they look acceptable to me. The two main choices for the project look to be the esp8266 and the esp32 modules. I like the esp32 better, due to the more robust gpio and onboard flash memory. Double the price, but we're talking about 10 versus 20 dollars here. I believe the extra gimmicks are sufficient to satisfy the desires of a lot more tinkerers.

I could get by with the 8266 and a few extra expansions, but with the 32, it would only need "muscle" controls, with many options available for sensing and communication built-in. The 3.3 volt logic levels are no big deal, since there are so many compatible expansion modules available.

So here's the part where I respectfully beg for information. I'll take whatever you have to share. Since what you're using obviously works, I'd love to pilfer through source code and see how it ticks. I promise I won't break it and post up a bunch of stuff that doesn't work well.

With the uno, the code had to be small and simple to conserve resources. Not a lot of people could follow the kiss method or understand some things I did to keep it small. Communication with the outside world was a point of contention as well. Flashy lights vs 7 segment vs what have you, everyone had different desires. With WiFi and i2c interfaces onboard, as well as a gaggle of spare output pins available, someone could plausibly go their own way and not have to redo the core functionality.

All times are GMT -5. The time now is 11:18 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Ad Management by RedTyger