Monitor and log temperature of wood fire boosted Solar hot water heater
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
MQTT1.pyPython code to connect to a MQTT Broker and subscribe to a bunch of topics and save the data to a sqldatabase.x-python-script - 3.06 kB - 10/23/2016 at 04:19 |
|
|
Water_temp_16_10.ino.inoTHe installed verison of the firmware reads 4 sensors and updates a MQTT Broker with the data every 15minutesino - 5.44 kB - 10/16/2016 at 09:48 |
|
|
Water_temp_10_10.ino.inoCurent Firmware for 10/10/16 see log for detailsino - 5.59 kB - 10/10/2016 at 09:40 |
|
|
Water_temp_7_10.ino.inoFirst stage of the Firmware - reads temp sensors and Battery voltage and prints vaules out. ready to implement the Wifi connectionino - 3.17 kB - 10/07/2016 at 10:55 |
|
I had previous written about a failure of the temp sensor submerged in the tank - damn ebay "water proof" sensors... After going through a couple of them after 6 months or so I finaly drilled a hole in the side of the tank covering and embedded a new sensor in through the insulation and next to the tank and sealed the hole - no more submerged sensor. Problem solved I thought, but alas the sensor has again failed I can only put it down to the constant extreme temperature has cooked the sensor - aledgedy the sensors are good for 125deg C but a constant 90degC or so is just too much for them. is this now a case of chinese knock off dallas sensors or they just cant handle the heat?
I still hadnt got around to relocating the Tank temperature sensor to protect it from the boiling water and so needed to replace the Tank Sensor again. No problems just fit a new one up and update the code to accept the new address. 10 minute job and shes apples right - 24Hours later and lost of cursing and going over my code like it was working all I did was change ONE temperature sensor address.
After much F*&king around I discovered that only 5 of the 6 senors were updating. but for no obvious reason -
After banging my head against the wall it finally dawned on me since developing this project and the subsequent updates to it I had shifted most of my development from my desktop to a Laptop. A quick checked confirmed I Was running Arduino 1.8x on my Laptop and 1.6x on my desktop - recompiled on the desktop and loaded the NODEMCU board up from the desktop and off it went.
Arduino people WHY the FK does the update have to actually break working code?? No Errors it just kind of worked. Thats a day of my life I wont get back. I know my codeing skills are rather poor but dont make it any harder than it needs to be.
hmm the system has been running well for a number of weeks now.
Logging data happily and producing web pages and graphs - I added a 1.5w solar pannel to keep the battery topped up and that has been working well though a small miscalculation of the divider resistors for the battery voltage monitoring has a max vin of 13v.
But big issue yesterday afternoon I noticed the tank temperature dropped suddenly from around 90deg to 0. Given the system is still spitting out valid data for other sensors I suspect strongly the tank sensor which is submersed in water has failed - so much for a water proof sensor - I guess they aren't realy designed for continuous submersion in our rather nasty town water.
I'll replace the sensor in a day or two and maybe rework the voltage divider as well to increase the battery monitoring range. Might even add a over voltage cut off to protect the battery from over chargeing.
Well after some head banging and stuff Ive got soem working python code. if its a bit dodgey sorry its my first attempt at python and quiet frankly I dont have a clue what Im doing but the end result is t will connect to my MQTT broker and subscribe to my MQTT topics and write the data to an SQLlite3 database.
So now I can get on with loghing the data which I have desperately wanted to do all winter - now winter has come to an end - Oh well I expect to see lots of very high temps by lunchtime most days.
Interesting just while its beenrunning and Ive been playng with it I have already found the freeze point in the system which has caused me to have no hot water on a couple of days this year - its been a very mild wet winter here so not much problem with freezing but next year will probably be nasty.
I have a lot tlearn about writing python so now im not trying to make this project work Ill go back and do some tutorials and learn what Ive done and come back and fix things like my bunch of global variables in a function.
This is a type while thinking log.
Ive already installed SQL lite on the Pi so for the time being thats what ill use - this may change in the future but will do for now.
Things I have - Data set every 15minutes from the Hotwater heater
Each value is published to its own MQTT Topic.
What I need now is a way to read the values published and store them in a database and include the time they are stored.
I am planing to use a python script to do the dirty work.
It needs to know when new data is written to each topic and write it to the DB.
My data base needs
Date Time Battery_Voltage Ambient_Temp Tank_Temp Booster_Temp Inlet_Temp
I created a db solarwater.db
then created the table
BEGIN; CREATE TABLE Hotwater (tdate DATE, ttime TIME, Battery NUMERIC, Ambient NUMERIC, Tank NUMERIC, Booster NUMERIC, Inlet NUMERIC); COMMIT;
Now to get Python to read the Topics and populate the DB
Now that I have regular data coming from the hotwater heater now I need to store that data in a database and make it available for retrieval.
I initaly plan is to use a python scriptto subscribe to the MQTT topics and place the data into a SQLlite db along with a time stamp ready for access and analysis.
From my previous experiments with NODEMCU boards running off a battery I was only getting about a week from a device updating every 2 seconds running of a 12V 7AH battery. Now I figgured a 2 second update is a bit excessive and between samples the NODEMCU is just sucking power so I have added
ESP.deepSleep(15 * 60 * 1000000);
after all the data has been sent to the broker.
What this does is put the ESP to into deep sleep for 15 minutes after which it wakes up connectes to the AP sends the data to the broker and goes back to sleep.
In order to have the NODE MCU wake its self up it was necesary to connect D0 to RST
I also noticed on the board I omitted the 4K7 pull up resistor for the one wire data bus.
I Was happy with the way this all worked so I popped the module in a box - I have a pile of cheap plastic food starage conatiners and theyare great as reasonably water proof enclosures for these pseudo temperay projects.
The sensors are now mounted on the HW heater -
I did implement a 5th sensor for the water temp to the booster which comes from the bottom of the tank but i decided in the end that this was of limited vaue and required etending the leads to the sensor some what whaich at this stage I dont feel is of benfit - I may implement it at some later stage.
So now the NODEMCU sends data to the MQTT broker on the raspberry PI and the latest values can be viewd by subscribing to the appropriate Topic.
Currently
Unfortunatley due to lead length constraints the inlet temp sensor is too close to the tank so reads substantialy high - a modified location is needed and the ambient temp senor needs to be moved away from the tank also as the actual temp is curently 17.5deg C
I had been struggling with sending a floating point value to the MQTTserver. The MQTT implememtation sends a string and message was formatted by using snprintf to create a string array from the data but it doesnt seem to work with floating point values.
I had been getting around it by multiplying the temperature and volatge readings by 100 converting to and int and then sending that figgure. The plan was to read the value later and divide by 100 to recreate the 2 decimal places I wanted - 1 decimal place would be more than adequate but.
Figgureing someone else must have had to deal with this situation I applied some good google foo and found a Home Assistant tutorial by Paulus Schoutsen that did just what I wanted and he used
client.publish(temperature_topic, String(temp).c_str(), true);
https://home-assistant.io/blog/2015/10/11/measure-temperature-with-esp8266-and-report-to-mqtt/
.c_str() was just what I needed so updated my client.publish and gotrid of the *100 business - all much tidier.
Thanks Paul :)
Now having seen the Home Assistant project I think that might give mesome more toolsto use in what I wish to achieve.
I now have the firmware working to read the DS1820 temp sensors and battery voltage and print the vaules on the arduino serial monitor.
This doesnt seem like much and could have just used one of the example files of the net but that would not integrate nicely with my next step of sending the data to my MQTT server via wifi.
A point of interest when designed the board to hold the NodeMCU module I mistakenly caluclated the resitive divider network for the Battery monitor believing that the NODEMCU had a 1V ADC input as per the ESP8266 but the NODEMCU board already has a divider built in to allow the Ain to read up to 3V.
I Would like to monitor
Use a Node MCU Board
5 DS1822 water proof Sensors
From experience using the NODE MCU board running a logging system updateing a BLYNK server every 2 seconds a 12V 12AH SLA last about a week.
I dont think I need that kind of resolution so will initially set the update rate to once every 15minutes and put the ESP8266 to sleep between updates. As I will me monitoring the battery voltage I will be able to reasses the energy requirements once I start to obtain real data
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates