For this project you need low cost hardware and open source software. requestment hardwere:
- raspberry pi or NodeMcu Arduino
- ds18b20 temperature sensors 55 to 125°C (-67°F to +257°F), ±0.5°C accuracy from -10°C to +85°C, 9 to 12 bit
- 4,7 kΩ resistor
- wifi or lan cnnection to raspbbery pi.
requstment software:
- influxdb
- influxdb client (telegraf)
- grafana If you use Raspberry pi you can use influxdb localy, for Arduino you need influx server.
When I installed heatp pump (water - water) I had a few problems. The amount of water and temperature in the draw well varied over time. My initial parameters that I took from books and from experts were not matching with current parameters. As a physicist, I needed to build monitoring system to solve problems and make fully autonomous heating system for next winter. I also lacked one piece of information for designing the heating system: average temperature in January. One heating engineer told me that it can be designed at 0°C degrees and that there are 20 days in the season with low temperatures that can be overcome with additional heat. However, my system was designed at -5 which turned out to be very accurate and not over sized.
Let’s see how to set up hardware. Connect the ds18b20 sensor in parallel between 3.3V and add a resistor.
Connect DS18B20
On the Raspberry Pi, you will need to add dtoverlay=w1-gpio"
(for regular connection) or dtoverlay=w1-gpio,pullup="y"
(for parasitic connection) to your /boot/config.txt. The default data pin is GPIO4 (RaspPi connector pin 7), but that can be changed from 4 to x
with dtoverlay=w1-gpio,gpiopin=x
.
Here’s what I did:
sudo echo dtoverlay=w1-gpio-pullup,gpiopin=4 >> /boot/config.txt
sudo modprobe w1_gpio && sudo modprobe w1_therm
Drivers
1-Wire drivers need to be loaded in order to create the connection between the physical sensor and the rPI. You can load them from the terminal (or from the bin/modules.sh script).
sudo modprobe wire
sudo modprobe w1-gpio
sudo modprobe w1-therm
Testing
After reboot test sensors.
cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves
cat /sys/bus/w1/devices/sensorID/w1_slave
If you have all right you can see result like image.
Influxdb and Grafana.
How to setup influxdb+telegraf and Grafana you can see here Telegraf have plugin for application lm-sensors, but his application have problem with multiple ds18b20 sensors. I write own aplication in golang and will write telegraf plugin or ds18b20 client for influxdb.
go get github.com/mishop/sensors
go bulid sensors
sensors
Output example
w1_temp:
temp0
temp0_output: 0.50
temp1
temp1_output: 11.00
temp2
temp2_output: -0.81
temp3
temp3_output: 13.06
telegraf.conf
[[inputs.sensors]]
## If true, a field name like 'temp1_input' will be changed to 'temp_input'.
#remove_numbers = true
Now you can add Grafana dashboard Now you can calculate energy, house energy lost etc. With simple calcualtion if otuput temperature is > 28°C heat pump working. This is simple mathematics trick with f(x)=(sgn(x) + 1)/2; (x >= 28 f(x) = 1, x < 28 f(x) = 0) multiple with your heating power. My heat pump is low temperature and have COP ~5. Make influxdb subquery.
SELECT (((abs(mean("temp_input") - 28 ) / (mean("temp_input") - 28) + 1 ) /2)/24) as uptime FROM "sensors" WHERE ("feature" = 'temp1') AND $timeFilter GROUP BY time(1m) fill(null)
If you add an outdoor temperature sensor you will have a real mini weather station where you can monitor the current temperature, average temperatures, etc. The data is very good because it can be used for heating design, and you can also calculate the heat loss of the building and how much savings you can make by adding insulation, replacing windows or doors … Based on the temperature difference, you can also make an estimate for the annual cost of energy. About how to calculate how many your heating costs annually on another occasion. You can also add one sensor to the house or connect existing and you will get full heat and energy monitoring system and house thermostat.
If you have solar systems, please feel free to let me know. Due to the current situation, I am unable to add it and would be happy to test it. In the next post, we will describe how remotely control heating system, make house thermostat, track changes on system and make heat optimization. Machine learning plugin is ready to test my system.