Smart Refrigerator w/ESP8266

Wow that is some deep stuff for sure.

I am pretty sure the lens would thaw during a normal defrost cycle ( might even melt), which upon re-freezing would ultimately make things worse. A vicious cycle for sure. You would think ice would have zero humidity, since it would/should be frozen. Maybe the way to detect ice would be to detect rapid humidity level drops. Not too sure about this one. Camera seems not very plausible however at this point. But when the compressor runs non-stop except for defrost cycles, that is a pretty obvious sign of freeze up. But maybe too late by then.

Perhaps take an average of daily compressor runs times after a fresh manual defrost, then when the behaviour changes, kick into defrost mode?

I think you are thinking right in line with this TI papers. The capacitance change goes through three distinct states, dry, ice and water.

You might give some thought to seeing if laying one or two of these across your coils would generate some actionable data:

Tutorial - Using Capacitive Soil Moisture Sensors on the Raspberry Pi - SwitchDoc Labs Blog.

Nice find! This could very well do it. The link shows them to be out of stock, but I would guess Digi-Key might have them. I will probably save this for Rev.2 on down the road, after I get what I have working.

I donā€™t think I want to complicate things too much more at this point. Since I am planning on running the defrost cycle every 12-14 hours instead of the factory 24h, that may be all that is needed to keep the coils clear. Lots of testing will need to be done once installed, which is probably going to be a royal pain in the you know what! :smiley: Especially since the freezer side is darn near full!

Any ideas on power supplies? I am thinking instead of running 5v power into the fridge to power the esp8266, I should be able use the existing power thatā€™s already present, since I am already going to be tapping into it. I have looked at a few P/S on Amazon, but have found none without plenty of bad reviews.

This would also allow the esp to power on and off with the fridge, which seems ideal.

Suggestions?

It is interesting to see how stable these machines keep temperature and humidity, both in the face of different volumes of contents and door openings. Below are the charts for before and after a Costco food run. The fridge and freezer were under 20 % full before 4pm on the 8th. To about 90% full from after 4 pm on the 8th. The door opening and closings are clear from the fillup and at meal times, however the volume has very little effect. It there is some effect and seems to take about 24 hours to move the temp and humidity values back to baseline.

1 Like

I am moving all my power for my electronic gadgets to ucsb-c pd (power distribution). You might want to have a look at this technology. You can get 5, 9, 12, 18 or 20 volts from common usb-c wall warts just by selecting a different usb-c trigger adapter unit. Link below to one brand. When you finalize design, just dry your gadget out with heat gun or hair dryer and then seal up with silicon gel.

With common wall warts or usb-c battery packs (useful for isolating devices from mains for noise and other testing):

1 Like

Look at the difference in the power graph after a fresh manual defrost. What a difference from before.

Before defrosting

After defrosting

The power drop between 11am and 3pm is when the power was removed for defrosting.

2 Likes

Latest code revision:

esphome:
  name: fridge_automation
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: ""
  password: ""

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Fridge Automation"
    password: "AMi0aezQtTKx"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

time:
  - platform: sntp
    # ...
    on_time:
      # Every 12 Hours
      - seconds: 0
        minutes: /60
        #hours: 12
        then:
          - switch.toggle: defrostmode


switch:
  - platform: gpio
    name: "Compressor Relay Off"
    id: comp2def
    pin: D2       #GPIO4
  - platform: template
    name: "Defrost Mode On"
    id: defrostmode
    turn_on_action:
# 12 Hour Loop
#    - switch.turn_off: comp2def
#    - delay: 60s  #Change to 43200s (12 hours for actual operation 720 for 12 minutes
    - switch.turn_on: comp2def
    - delay: 60s   #Change to 60s (1 min) for actual operation
    - switch.turn_on: defroston
    - delay: 900s  #Change to 900s (15 min) for actual operation
    - switch.turn_off: defroston
    - delay: 600s  #Change to 600s (10 min) for actual operation
    - switch.turn_off: comp2def

  - platform: gpio
    name: "Defrost Relay"
    id: defroston
    pin: D1       # GPIO5
  - platform: template
    name: "autooff"

binary_sensor:
  - platform: gpio
    pin: D3
    name: "Fridge Door"
    device_class: door

  - platform: gpio
    pin:
      number: D7
      mode: INPUT_PULLUP
      inverted: False
    name: "Freezer Door"
    device_class: door

# Individual sensors
sensor:
  - platform: dht
    pin: D5
    model: DHT22
    temperature:
      name: "Fridge Temperature"
#      unit_of_measurement: "Ā°F"
    humidity:
      name: "Fridge Humidity"
    update_interval: 30s

  - platform: dht
    pin: D6
    model: DHT22
    temperature:
      name: "Freezer Temperature"
    humidity:
      name: "Freezer Humidity"
    update_interval: 30s
# Measure the wifi signal strength    
  - platform: wifi_signal
    name: "WiFi Signal"
    update_interval: 60s

Reading your power consumptions I get the feeling that you should not invest in IoT but in new energy saving fridges.

Whereā€™s the fun in that? :smiley:

I just bought a new fridge for the kitchen back in January. At right around $2K they donā€™t come cheap, and this was one of the least expensive ones I could find with medium features. So the old kitchen fridge is the now in the garage, replacing an even older and less efficient one. Oddly enough, the new fridge is not THAT much more efficient. I donā€™t think it will take much software tweaking to get this one nearly, if not as efficient as the new one.

Refrigerator cooling technology has not really changed in the past 25-30 years. Compressors, heating elements, coils, etc are all pretty much exactly the same as they were in the 1980s. but what has changed is that now it is mostly under computer control and monitoring. That is where the better efficiency may come into play.

1 Like

Well the fun is that you will prevent migration wars and other nasty things because your neighboring countries in the south become uninhabitable and your coastlines are flooded. :wink:

There is definitely an improvement in newer fridges. It mostly comes from better insulation. I have an A+++ fridge here (a European efficiency class) that really has a much lower consumption than older models.

On the other hand I am quite sure that you are not measuring effective power but apparent power. Depending on the cos phi of your fridge it may deviate substantially from the real consumption. Especially older models may be missing a capacitor to compensate the cos phi of the compressor towards 1.

1 Like

Please take the climate change and political rhetoric to another thread. This is not the place for it nor is it welcome. When you contribute to the subject at hand, that is greatly appreciated.

I am quite sure you are correct. Can this capacitor be added to an older fridge compressor, or does the compressor have to be designed for it?

As you could see from the latest graphs I posted, a simple full manual defrosting increased efficiency by nearly 50% and has stabilized even more since I posted it. I am hopeful this project will keep it from needing manually defrosted ever again and continue to NOT run constantly.

The fitting of reed switches into a refrigerator door has proven to be much more difficult than ever imagined. Especially ones with none removable door storage compartments. Without physically climbing into it and fitting the switches from the inside, I am not sure how to do it. The thought has occurred to me to just use the existing door light switches, but that is also very complicated on its own merit and I donā€™t think they would be nearly as accurate (ie the light can be off and the door still not be completely closed therefore giving a false closed reading).

Has anyone added reed switches to their fridge doors? I would love to know how you did it, or even just some better ideas than what I have come up with so far.

Also, I was wanting to put this thing under complete computer control eventually. However, I have discovered there is much more to it than just replacing the defroster timer. There are also thermistors and a defrost thermostat that would probably need to be bypassed as well. They would continue to run the show, in a manner of speaking, otherwise. When manually putting the defrost timer into defrost mode when the compressor is not running, for instance, it does NOT go into defrost mode until that compressor resting period is over. So I am pretty sure there is yet another timer of some sort, doing something else entirely.

I have tried finding schematics for this unit, but so far I have come up empty. The model number is TFX25JRYD WW (More for my own reference).

Bold words for a newbie in this forum. Thanks for lecturing me. Message received.

1 Like

I think @lexridge reply is to point and I support his statements.

1 Like

You might have a look at these two vibration sensors, it would take a little software but I think a bayesian output from one of these would give you are good confidence of door change of state. Then for alarming on a door open and left open, you could monitor temperature and/or humidity change after the door event.

https://www.amazon.com/gp/product/B00M1PN7PW/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1

https://www.amazon.com/gp/product/B07Q9J5C4G/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1

1 Like

Thank you for the hint on these vibration sensors and for you kind support on this project.

This morning while checking the logs, I noticed the unit went offline this morning ~2am. Upon a closer look, I think the ESP8266 has bit the dust. So I pulled it from the board (it is socketed) and tried to power it up on its own. Nothing. No serial output whatsoever. Pondering what could have caused this. Maybe just a flakey board?

I have ordered some different larger solder boards which should be here tomorrow. I will have to start over of course, but rev 2 should be much better designed, hopefully. Guess I am on hold for a few days. Ugh!

Just had a thought. If I simply flash a new ESP8266, itā€™s going to show up as an entirely new device. Do I need to delete the failed deviceā€™s Integration from Home Assistant first? Donā€™t really care about losing the collected data at this point. I have read too that I may not be able to easily delete it, as itā€™s forever in the database (which if true is kinda dumb). Any ideas @dproffer?

Iā€™ve moved mostly to ESP32-S2 for my personal creations. The ESP8266 seems to have more stability issues, there are multiple revs and designs of all of the ESP boards. Do a google search on your specific board and processor rev and you will hopefully get some real world comparison. Make sure you are protecting the GPIO with isolation and or reverse power spike protection. You are trying to control a pretty noisy and high current devices in a fridge. I never heard what kind of power supply you settled on for your device, however again, a fridge is a pretty large and spikey AC power consumer, having a good power supply for your ESP is a good move. I do not use the direct tasmota or esphome sensor integration with Home Assistant but rather interface via MQTT sensors for most of my stuff. I find keeping a division between sensor processing and HA better, either via a separate mcu processing the data and sending to MQTT or a docker task doing the same. Giving sensors a unique identifier is something I started to do a couple versions of HA ago. I still do not have all of my sensors and others with unique identifiers, but this seems to be becoming more of a ā€˜requirementā€™ in the latest versions of HA.I use MAC addresses often for my sensors, however that does cause problems when you replace ESPā€™s or other sensors. You can fake the unique sensor id to the old MAC, however that is a management pain over time. I have yet a good solutions for this, in two years of HA history, unfortunately I have a number of shifts in data streams between replaced sensor and no good way to track these changes. I just have manual log of changes I make to my HA enviro, and have consult this when doing data analysis.

I would guess something probably shorted due to my poor and hurried soldering attempts, on such a small board too. This was always just a prototype anyway just to get the firmware doing what itā€™s suppose to do. You make a good point on the high voltage spikes. I am not sure if my relays are opto-isolated or not. I need to check that and replace them if not. They have not yet been connected to any high voltage so far, so that is not the issue at this point, but could certainly arise if not isolated.

I have only been using HA for about 5 mos now. I was and still am using Mozilla IoT (project since renamed but I never updated to it) and have been slowly migrating things over from it so I may eventually retire it and reallocate it. Both HA and MIoT RPi4s have independent zigbee adapters so that has made the migration a bit easier. Each system does have their own strengths and weaknesses. Sadly, removing devices from the DB is a weakness both systems have in common.

My ESP temp/humidity sensors throughout the house, garage and outdoors are all using MQTT. I added a mosquitto broker to my DD-WRT EA8000 router to get all this working. Not sure at all how I would integrate the fridge controller into MQTT. All still kinda new to me. More research would be required on my behalf for sure.

Looks like if I delete the fridge controller from the config/.storage folder might just get rid of it. I will take a snapshot before trying it.

Thanks again for all the good info.

Edit: I got it removed from HA. I had to remove the entry from config/.storage/core.config_entries and then delete the file esphome.id#. That seemed to work well.