WiFi Waterbed and Freezer Temperature Control

The old mechanical thermostat failed ON so I replaced it with a WiFi NodeMCU system with web page HMI for control/monitoring.

Similar projects worth following
The ancient mechanical waterbed thermostat failed ON so the temperature kept climbing uncontrolled. Luckily we were home at the time. I tossed the faulty thermostat and in a few hours replaced it with another NodeMCU controller system.

All the new components fit inside the original plastic thermostat housing. All of the original 120VAC wiring is reused. Housing must be plastic for the NodeMCU WiFi antenna. Total cost of components is less than $15 Cdn from Chinese suppliers on ebay. Free shipping. Long delivery.

Heater is 325 Watts so significant power is involved although once it's up to temp it's only on about 20% of the time so small cost saving. It only heats now at low cost power Time of Use 7 pm to 7 am using the DS3231 battery backed clock module. Power failures don't affect the correct time now like they threw off the original mechanical timer. Temperature is controlled within +/-0.15C of setpoint. Resolution of digital temp sensor is set to 0.125C.

Daily kWh usage is calculated at midnight from the recorded previous day total daily seconds ON/3600 for hours X 0.325 kW.
In this case the cost savings are very small if the heater is only powered 7pm to 7am vs 24 hrs compared to other higher power devices like the electric hot water tank and hot tub.

AWAY mode will enable the bedside light to go on for a few hours in the evening for security. Random on and off times. 

randNumber = random(0, 59); // used for minutes that light goes on or off. Hour depends on day of week.

It uses a second of four available 10A relays.
I could have AWAY mode also turn off the waterbed but it would have to be turned on again long before returning because it could take more than 12 hrs to go from room temp to the setpoint again.
It could be programmed to turn on again based on the date of the day before returning or turned on remotely via MQTT. Temp is also monitored remotely via MQTT.  

A DS3231 RTC connected on I2C gives the controller year, month, day, hour, minute and second data. Battery backed so power failures don't affect correct time. Time is reset from internet time every day around 3 a.m. so very accurate. This also corrects for daylight or standard time.

You can also have it automatically put data into a cloud spreadsheet, viewable from anywhere, or send you an email or text via IFTT.

AUTO OFF means it is enabled all the time and only controls by temperature not time of day as well.

This is the sixth home automation project with NodeMCU. Total saving is $1,000+/year. Another example where a small change you won't notice can save you money.

Same components plus deicing cable used to preheat the long copper hot water line between the hot water tank and shower. This saves time, money, water and power.

Same components plus deicing cable used to keep birdbath/Frisbee from freezing.

NodeMCU, DS3231 clock and 30A 240VAC relay used to enable electric water heater only between 1 am and 7 am weekdays and weekends. Override from web page if needed.

Clock is also used to execute some code once only when t.Second() changes without using any delay(*)s.

I don't use Arduinos any more. Arduino IDE with add-ins is used to program NodeMCU.

Advantages of NodeMCU include:

1. Wireless programming. From the living room I can program any of the remote devices. You have to double and triple check you are connected to the right one before uploading.

2. Web page hosted on device for zero cost, zero I/O, high res, colourful display on phone, tablet or pc from anywhere on the same router using any browser.  No app needed.  To display the web page just put the local IP address of the NodeMCU device in any browser. Web page HTML code is among the control code. Only web page address of background JPEG is in the code not the JPEG file. No expensive, low res LCD display only available near device.

3. 32 bit chip. Far faster and more memory available for program, data and web page HTML instructions. Not limited to 16 bit 64K max integers. Seconds in a day is 86,400.

4. Smaller and cheaper than Arduino Uno.

5. Control and monitor from anywhere in the world with MQTT. 

6. Data can be put into a Google cloud spreadsheet automatically with IFTT.

7. Data or alarms can be sent to your phone with a text or email automatically with IFTT.

8. Although I/O is less than Arduino Uno the I/O can be used as I2C and OneWire buses to talk to multiple smart devices like a real time clock, digital temperature sensor and expansion I/O chips like MCP23017 on same wires. With digital and analog expansion chips you can connect and control many more I/O.

9. Very reliable. Many power failures are not a problem at all. Reboots, reconnects to WiFi and restarts program no problem. No battery backup needed.

Website detailing all NodeMCU projects including component costs and an educational section for...

Read more »

  • 1 × LoLin V3 NodeMCU12E - I prefer this 3.3V board since it includes 5V VU output from the USB charger to power relays.
  • 2 × 17X10 protoboard. I mount the NodeMCU board across two of them. This makes it easy to wire and creates two isolated areas.
  • 1 × Waterproof Stainless Steel DS18B20 digital temperature sensor
  • 1 × 4.7K pull up resistor. Connects yellow data wire to 3.3V on digital temp sensor. Can have multiple temp sensors on 1 input.
  • 1 × Male-Male and Male-Female Dupont wires

View all 10 components

  • Repurposed waterbed heater to warm seeds in Jiffy trays.

    nodemcu12ecanada04/30/2023 at 16:36 0 comments

  • Turn a mini fridge into a freezer

    nodemcu12ecanada04/29/2022 at 17:17 0 comments

    Our chest freezer suddenly died as well. With the same components I turned a mini fridge into a freezer until we get a new one. The thermostat wouldn't go low enough. So I replaced it with a digital temperature sensor and microcontroller. Clock is used to delay restart for 200 seconds after power failure or compressor OFF. Refrigeration compressors need to be off for some time before restarting so they don't try to start under running pressure. Added a 12V pc fan inside and a USB fan blowing on the compressor.

  • Implemented Away Mode

    nodemcu12ecanada01/09/2022 at 13:24 0 comments

    Implemented Away mode described above. Bedside light turns on for a random time while we are away. Waterbed heater also turns totally off and turns back on 2 days before we return since it takes a long time to heat from room temp back to 29C. It typically only loses 2C in 12 hours when it's off 7 am to 7 pm but it takes 3 hours to get back to 29C. I also record waterbed temp every hour now using Adafruit free MQTT. I highly recommend this method to record data to the cloud. Once you get the hang of it, it's very easy to create a cloud based HMI and storage and display of data. I can see the waterbed turning back on and heating up from anywhere now.

View all 3 project logs

Enjoy this project?



Dan Maloney wrote 05/07/2020 at 16:18 point

Interesting how many options moving to a microcontroller gave you over the original thermostat. I particularly like the calculation of power used. Nice job!

  Are you sure? yes | no

nodemcu12ecanada wrote 05/07/2020 at 16:28 point

Thanks. My NodeMCU projects save me $1,000+/year without even noticing the changes. Check out all of them on the website

A lot of people helped me get all the functions working so I documented how to do it on the website to pay it forward. Also helps me years later to remember what i did.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates