Free hot water for Motorhome
Hot water tank for eMotorhomes Caravans or RVs powered by solar panels without flattening the battery with remote temperature monitoring.
Devices & Components
Arduino Nano 33 IoT
Immersion heater
Hot Water Tank
24V water heater
Relay 24 Volts
Project description
Code
IoT controller software
arduino
Monitors water and air temperature, prevents over temperature.
1// 6 July 2021 build 2 3/* 4 Sketch generated by the Arduino IoT Cloud Thing "Hot_Water_Tank" 5 https://create.arduino.cc/cloud/things/9e616343-890c-45e8-a788-e54373992d4f 6 7 Arduino IoT Cloud Variables description 8 9 The following variables are automatically generated and updated when changes are made to the Thing 10 11 CloudTemperatureSensor batTemp; 12 CloudTemperatureSensor wtemp; 13 bool overTemp; 14 bool wboost; 15 CloudTime boostTime; 16 17 Variables which are marked as READ/WRITE in the Cloud Thing will also have functions 18 which are called when their values are changed from the Dashboard. 19 These functions are generated with the Thing and added at the end of this sketch. 20*/ 21#include "thingProperties.h" 22#include <NTPClient.h> 23 24// Basic sketch for Onewire temperature measureing devices. Devices can be connected in parallel on same digital pin 25// note that a 4.7k resistor is needed to pull up the pin. 26// for the Q hardware, digital pin 2 is used for the sensor 27//Include the libraries we need 28// onewire device ID = 284E1F4F351901FA is Battery temperature 29// onewire device ID = 289765E32220016C is hot water temperature 30#include <OneWire.h> 31#include <DallasTemperature.h> // DallasTemperature(Galileo) for i586 - Version: Latest 32#define ONE_WIRE_BUS 2 33#define TEMPERATURE_PRECISION 9 34 35#define boostPin 4 // To switch on Boost relay (2 off 25V heaters) 36#define overtempPin 3 // To prevent low power auto heater from turning on when high temp 37 38// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 39OneWire oneWire(ONE_WIRE_BUS); 40DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. 41DeviceAddress batTempID, wtempID; // for final version 42// DeviceAddress wtempID; 43// arrays to hold Temperature device addresses 44// DeviceAddress tempBat = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; 45// DeviceAddress tempWater = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 }; 46// ensd of Temperature defines 47 48WiFiUDP ntpUDP; 49// By default 'pool.ntp.org' is used with 60 seconds update interval and 50// no offset 51NTPClient timeClient(ntpUDP); 52 53int count; 54float elTime; // elapsed time in seconds since last measurement 55unsigned long currentSec = timeClient.getEpochTime(); // Epoch time = seconds since 1Jan1970 56 57// boolean Wboost = 0; // Turns off relay 58boolean OverTemp = 0; //turns off over temperature output 59int boostTimer = -1; // if boost timer less than one wBoost os off 60 61//**************************************************************** 62 63void setup() { 64 pinMode(LED_BUILTIN, OUTPUT); 65 pinMode(boostPin, OUTPUT); 66 pinMode(overtempPin, OUTPUT); 67 68 Serial.begin(115200); // Initialize serial and wait for port to open: 69 // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 70 delay(1000); // wait for stabilisation) 71 blinks(5); // blink inbuilt LED 5 times to show startup 72 digitalWrite(boostPin, LOW) ; 73 boostTime = 1 ; // setup initial time for larger 25V heater is on, in minutes 74 75 // Defined in thingProperties.h 76 initProperties(); 77 78 // Connect to Arduino IoT Cloud 79 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 80 81 /* 82 The following function allows you to obtain more information 83 related to the state of network and IoT Cloud connection and errors 84 the higher number the more granular information you’ll get. 85 The default is 0 (only errors). 86 Maximum is 4 87 */ 88 setDebugMessageLevel(2); 89 ArduinoCloud.printDebugInfo(); 90 boostTimer = -1 ; 91 wboost = LOW; // ensure boost is off to start with 92 93 timeClient.begin(); // start looking for accurate time from server 94 sensors.begin(); // Start up the Temp Sensor library 95 96 Serial.print("Locating devices..."); 97 Serial.print("Found "); 98 Serial.print(sensors.getDeviceCount(), DEC); 99 Serial.println(" devices."); 100 delay(1500); 101 Serial.print("Parasite power is: "); 102 if (sensors.isParasitePowerMode()) Serial.println("ON"); 103 else Serial.println("OFF"); 104 105 if (!sensors.getAddress(batTempID, 0)) Serial.println("Unable to find address for Device 0"); 106 if (!sensors.getAddress(wtempID, 1)) Serial.println("Unable to find address for Device "); 107 sensors.setResolution(wtempID, TEMPERATURE_PRECISION); 108 sensors.setResolution(batTempID, TEMPERATURE_PRECISION); 109 110 111 112 113} 114 115//**************************************************************** 116void loop() { 117 118 119 ArduinoCloud.update(); 120 delay(100); 121 Serial.print("Requesting temperatures..."); 122 sensors.requestTemperatures(); 123 Serial.println("DONE"); 124 wtemp = sensors.getTempC(wtempID); // Hot Water Temperature 125 batTemp = sensors.getTempC(batTempID); // Battery Temp device ID 126 127 Serial.print(" batTemp - wtemp = "); 128 Serial.print(wtemp); 129 Serial.print("- "); 130 Serial.println(batTemp); 131 132 133 if (wtemp > 78) { 134 digitalWrite(overtempPin, HIGH); // turn off low power heater if water temp >78C 135 overTemp = HIGH; 136 digitalWrite(boostPin, LOW); // turn off boost heater as well 137 boostTimer = -1; // reset boost timer 138 wboost = LOW; 139 } 140 if (wtemp < 72) { 141 digitalWrite(overtempPin, LOW); // turn on heater circuit if weter temp lower 142 overTemp = LOW; 143 } 144 Serial.print(" Timer = "); 145 Serial.println(boostTimer); 146 147 if (boostTimer > 0) { 148 digitalWrite(boostPin, HIGH); 149 boostTimer = (boostTimer - 2); // 2 second loops converted to minutes 150 wboost = HIGH; 151 blinks(2); 152 } 153 else { 154 digitalWrite(boostPin, LOW); 155 boostTimer = -1; 156 wboost = LOW; 157 blinks(1); 158 } 159 160 Serial.print("wboost = "); 161 Serial.println(wboost); 162 // ++++++++++++++++++++++++++ 163 boolean xboost; 164 xboost = digitalRead(boostPin); 165 Serial.print("xboost= "); 166 Serial.println(xboost); 167 168 169 delay(2000); // 2 second loops 170} 171 172void onOverTempChange() { 173 // Do something 174} 175 176void onWboostChange() { 177 boolean xboost; 178 xboost = digitalRead(boostPin); 179 Serial.print("xboost= "); 180 Serial.println(xboost); 181 if (wboost >= 1 && wtemp < 78) { 182 boostTimer = (boostTime * 30) ; 183 Serial.print("Boost Timer = "); 184 Serial.println(boostTimer); 185 186 } // Loops time = 2 seconds, converted to minutes 187 188 Serial.println(boostTime); 189} 190 191void blinks(int howmany) { // blinks for the number of times passed to the routine 192 do { 193 digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 194 delay(200); // wait for half a second 195 digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 196 delay(200); // wait for half a second 197 howmany = howmany - 1; 198 } while (howmany > 0); 199} 200 201 202void onBoostTimeChange() { 203 // Do something 204} 205 206 207 208 209 210
IoT controller software
arduino
Monitors water and air temperature, prevents over temperature.
1// 6 July 2021 build 2 3/* 4 Sketch generated by the Arduino IoT 5 Cloud Thing "Hot_Water_Tank" 6 https://create.arduino.cc/cloud/things/9e616343-890c-45e8-a788-e54373992d4f 7 8 9 Arduino IoT Cloud Variables description 10 11 The following variables are automatically 12 generated and updated when changes are made to the Thing 13 14 CloudTemperatureSensor 15 batTemp; 16 CloudTemperatureSensor wtemp; 17 bool overTemp; 18 bool wboost; 19 20 CloudTime boostTime; 21 22 Variables which are marked as READ/WRITE in the 23 Cloud Thing will also have functions 24 which are called when their values are 25 changed from the Dashboard. 26 These functions are generated with the Thing and 27 added at the end of this sketch. 28*/ 29#include "thingProperties.h" 30#include 31 <NTPClient.h> 32 33// Basic sketch for Onewire temperature measureing devices. 34 Devices can be connected in parallel on same digital pin 35// note that a 4.7k 36 resistor is needed to pull up the pin. 37// for the Q hardware, digital pin 2 is 38 used for the sensor 39//Include the libraries we need 40// onewire device ID = 41 284E1F4F351901FA is Battery temperature 42// onewire device ID = 289765E32220016C 43 is hot water temperature 44#include <OneWire.h> 45#include <DallasTemperature.h> 46 // DallasTemperature(Galileo) for i586 - Version: Latest 47#define ONE_WIRE_BUS 48 2 49#define TEMPERATURE_PRECISION 9 50 51#define boostPin 4 // To switch on 52 Boost relay (2 off 25V heaters) 53#define overtempPin 3 // To prevent low power 54 auto heater from turning on when high temp 55 56// Setup a oneWire instance to 57 communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) 58OneWire 59 oneWire(ONE_WIRE_BUS); 60DallasTemperature sensors(&oneWire); // Pass our oneWire 61 reference to Dallas Temperature. 62DeviceAddress batTempID, wtempID; // for final 63 version 64// DeviceAddress wtempID; 65// arrays to hold Temperature device addresses 66// 67 DeviceAddress tempBat = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }; 68// DeviceAddress 69 tempWater = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 }; 70// ensd of Temperature 71 defines 72 73WiFiUDP ntpUDP; 74// By default 'pool.ntp.org' is used with 60 seconds 75 update interval and 76// no offset 77NTPClient timeClient(ntpUDP); 78 79int 80 count; 81float elTime; // elapsed time in seconds since last measurement 82unsigned 83 long currentSec = timeClient.getEpochTime(); // Epoch time = seconds since 1Jan1970 84 85// 86 boolean Wboost = 0; // Turns off relay 87boolean OverTemp = 0; //turns 88 off over temperature output 89int boostTimer = -1; // if boost timer less 90 than one wBoost os off 91 92//**************************************************************** 93 94void 95 setup() { 96 pinMode(LED_BUILTIN, OUTPUT); 97 pinMode(boostPin, OUTPUT); 98 99 pinMode(overtempPin, OUTPUT); 100 101 Serial.begin(115200); // Initialize 102 serial and wait for port to open: 103 // This delay gives the chance to wait for 104 a Serial Monitor without blocking if none is found 105 delay(1000); // wait for 106 stabilisation) 107 blinks(5); // blink inbuilt LED 5 times to show startup 108 109 digitalWrite(boostPin, LOW) ; 110 boostTime = 1 ; // setup initial time for larger 111 25V heater is on, in minutes 112 113 // Defined in thingProperties.h 114 initProperties(); 115 116 117 // Connect to Arduino IoT Cloud 118 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 119 120 121 /* 122 The following function allows you to obtain more information 123 related 124 to the state of network and IoT Cloud connection and errors 125 the higher number 126 the more granular information you’ll get. 127 The default is 0 (only errors). 128 129 Maximum is 4 130 */ 131 setDebugMessageLevel(2); 132 ArduinoCloud.printDebugInfo(); 133 134 boostTimer = -1 ; 135 wboost = LOW; // ensure boost is off to start with 136 137 138 timeClient.begin(); // start looking for accurate time from server 139 sensors.begin(); 140 // Start up the Temp Sensor library 141 142 Serial.print("Locating devices..."); 143 144 Serial.print("Found "); 145 Serial.print(sensors.getDeviceCount(), DEC); 146 147 Serial.println(" devices."); 148 delay(1500); 149 Serial.print("Parasite 150 power is: "); 151 if (sensors.isParasitePowerMode()) Serial.println("ON"); 152 153 else Serial.println("OFF"); 154 155 if (!sensors.getAddress(batTempID, 0)) Serial.println("Unable 156 to find address for Device 0"); 157 if (!sensors.getAddress(wtempID, 1)) Serial.println("Unable 158 to find address for Device "); 159 sensors.setResolution(wtempID, TEMPERATURE_PRECISION); 160 161 sensors.setResolution(batTempID, TEMPERATURE_PRECISION); 162 163 164 165 166} 167 168//**************************************************************** 169void 170 loop() { 171 172 173 ArduinoCloud.update(); 174 delay(100); 175 Serial.print("Requesting 176 temperatures..."); 177 sensors.requestTemperatures(); 178 Serial.println("DONE"); 179 180 wtemp = sensors.getTempC(wtempID); // Hot Water Temperature 181 batTemp 182 = sensors.getTempC(batTempID); // Battery Temp device ID 183 184 Serial.print(" 185 batTemp - wtemp = "); 186 Serial.print(wtemp); 187 Serial.print("- "); 188 189 Serial.println(batTemp); 190 191 192 if (wtemp > 78) { 193 digitalWrite(overtempPin, 194 HIGH); // turn off low power heater if water temp >78C 195 overTemp = HIGH; 196 197 digitalWrite(boostPin, LOW); // turn off boost heater as well 198 boostTimer 199 = -1; // reset boost timer 200 wboost = LOW; 201 } 202 if (wtemp < 72) { 203 204 digitalWrite(overtempPin, LOW); // turn on heater circuit if weter temp lower 205 206 overTemp = LOW; 207 } 208 Serial.print(" Timer = "); 209 Serial.println(boostTimer); 210 211 212 if (boostTimer > 0) { 213 digitalWrite(boostPin, HIGH); 214 boostTimer = 215 (boostTimer - 2); // 2 second loops converted to minutes 216 wboost = HIGH; 217 218 blinks(2); 219 } 220 else { 221 digitalWrite(boostPin, LOW); 222 boostTimer 223 = -1; 224 wboost = LOW; 225 blinks(1); 226 } 227 228 Serial.print("wboost 229 = "); 230 Serial.println(wboost); 231 // ++++++++++++++++++++++++++ 232 boolean 233 xboost; 234 xboost = digitalRead(boostPin); 235 Serial.print("xboost= "); 236 237 Serial.println(xboost); 238 239 240 delay(2000); // 2 second loops 241} 242 243void 244 onOverTempChange() { 245 // Do something 246} 247 248void onWboostChange() { 249 250 boolean xboost; 251 xboost = digitalRead(boostPin); 252 Serial.print("xboost= 253 "); 254 Serial.println(xboost); 255 if (wboost >= 1 && wtemp < 78) { 256 boostTimer 257 = (boostTime * 30) ; 258 Serial.print("Boost Timer = "); 259 Serial.println(boostTimer); 260 261 262 } // Loops time = 2 seconds, converted to minutes 263 264 265 Serial.println(boostTime); 266} 267 268void blinks(int howmany) { // 269 blinks for the number of times passed to the routine 270 do { 271 digitalWrite(LED_BUILTIN, 272 HIGH); // turn the LED on (HIGH is the voltage level) 273 delay(200); // 274 wait for half a second 275 digitalWrite(LED_BUILTIN, LOW); // turn the LED 276 off by making the voltage LOW 277 delay(200); // wait 278 for half a second 279 howmany = howmany - 1; 280 } while (howmany > 0); 281} 282 283 284void 285 onBoostTimeChange() { 286 // Do something 287} 288 289 290 291 292 293
Downloadable files
300W solar controller
Monitors battery voltage so that at 92% charge, it switches on the 300W water heater to keep the charge at this level to optimise battery cyclic life.
300W solar controller
300W solar controller
Monitors battery voltage so that at 92% charge, it switches on the 300W water heater to keep the charge at this level to optimise battery cyclic life.
300W solar controller
Hot Water Tank Arduino controller
Measures water and air temperature, prevents water temp exceeding 80C , can switch the 600W boost relay via IoT dashboard.
Hot Water Tank Arduino controller
Comments
Only logged in users can leave comments