Projects Research & Design Hub

Refrigerator Repair Project

Written by Jeff Bachiochi

Using Espressif’s ESP32 MCU

When his refrigerator malfunctioned, Jeff embarked on an effort to figure out the problem and repair it. While waiting for replacement parts to be delivered, he employed embedded technologies to monitor and do a deeper diagnosis on the fridge’s functions, gaining interesting insights.

  • How to use embedded technologies to aid refrigerator repair

  • How to select the control points to monitor in the fridge/freezer

  • How to use isolation to keep safe around high voltage

  • How to interpret the data from the monitoring result

  • Ordering the parts (thermostat) for the repair

  • Espressif Systems ESP8266 MCU

  • PS2505 opto-couplers from Renesas Electronics

  • Four LEDs

  • Node-RED

It was just a matter of time. Our large-screen TV gave up the ghost. There are some failures that you can look for without a schematic. Some components fail with a bang, pop or bloat. You can use a visual inspection to find cracked, burnt or swelled parts, and then try replacing them. When an IC fails it’s generally a small internal failure that won’t show unless it’s been overheated and cracks or erupts—blowing off bits of plastic. If it’s a programmed part, forget it. Now we are talking board replacement. Like many today, this TV has several major PCBs. You might be able to find a YouTube video on solving a common problem. Some are bogus however, and you’re pretty much at the mercy of replacing a whole PCB—that is, unless none is available. I had to fight the urge to keep this broken TV around. I had conflicting emotions all the way to the recycling center.

The next weekend I went camping with the scouts, and came home to a cooler in the kitchen and an abundance of perishables scattered around looking like fish out of water. Beverly, my wife, was not in the best of moods. My #2 son Ryan had just complained that they just had to replace their refrigerator at his house, and there was none to be found (COVID shortage).

Apparently, all the ice in our freezer’s ice maker had melted, and water had run out the access port located on the freezer door. Yet, I heard the refrigerator’s compressor humming nicely. I thought, it must have gotten hung in a defrost cycle, because it seemed to be working at this point. Many helpful sites on the Internet gave advice and provided parts, so I splurged and spent $50 to replace the defrost thermostat.

PARTS

I’m always buying parts for projects. It’s been a while since I’ve seen lead times grow to where they are now. You’ve probably heard about auto manufacturers not being able to build cars because they couldn’t get chips. With no one buying during the pandemic, inventory was allowed to dwindle, so manufacturers stopped producing. And now, when the economy is trying to get kick-started again, everything is back-ordered. Can you say 2022?

Luckily, many appliance replacement parts are still available, and my defrost thermostat was on the way. I had just finished a column on using Maxim Integrated’s 1-wire temperature devices (“Putting 1-Wire Protocol into Action” Circuit Cellar 373, August 2021) [1]. I thought I could feed a couple of probes into the fridge and freezer sections to see what was happening with the temperature—a productive excursive while waiting for the part. After running that project for a few days, I was seeing some fairly wide temperature excursions. Did you know that many appliance manufacturers include a wiring diagram on or in the appliance? This helps a service person to make sense out of what they are seeing. I found one in my fridge. With this and some blow-up views online for picking out needed parts, I could see that the control PCB (discrete logic) was positioned right along with the temperature controls at the top of the fridge.

As shown in Figure 1, behind the panel, I was able to find the temperature controls for the freezer (10), the fridge (12) and the control PCB (6). I was surprised to find the freezer control operates a small door between the freezer and fridge via a mechanical linkage (23). The fridge control is an actual thermostat that pneumatically monitors the air temperature coming from the freezer at that door, adjusted by the freezer control in the upper rear corner of the fridge.

— ADVERTISMENT—

Advertise Here

The control PCB is basically a relay that enables power to the fridge thermostat or the defrost heater. The defrost heater is used periodically to warm the condenser coils. keeping them free of ice build-up. The defrost thermostat opens, removing power from the heater once the temperature of the condenser has sufficiently increased. Whenever the defroster is ON, the thermostat is OFF and so is the compressor—even if the thermostat should call for a lower temperature and attempt to turn on the compressor. I was a bit surprised to find that the compressor’s job was to remove heat from the freezer only. It is the door between the fridge and freezer that cools the fridge by circulating colder air from the freezer.

All the refrigerator components run on 120VAC. If I want to monitor anything, it has to be isolated to protect me and any of the electronics. I used an Espressif Systems ESP8266 microcontroller (MCU) for my temperature probe project, since the I2C bus only required two I/O bits, and the current project was now looking for more I/O than the ESP8266 has available. Because I wanted Wi-Fi capability, I substituted an Espressif ESP32 for this project. The schematic in Figure 2 shows the circuit used here to monitor two I2C temperature probes, four channels of isolation using PS2505 opto-couplers (made by Renesas Electronics and others) and four LEDs for a visual status of the isolators.

I chose four points of interest to monitor, all off the power relay directing power to the thermostat and the defrost heater thermostat, plus the defrost heater control switch and the thermostat control switch. This would show when power was enabled to the heater or thermostat, and when a control was calling for a defrost heater cycle or a compressor cycle.

In past columns, I’ve shown how I use a Raspberry Pi running an MQTT server to collect data from various projects. It was easy to add an additional Node-RED function to collect temperature and status data from the ESP32. Figure 3 shows typical data I received from this current project while the fridge was wreaking havoc with my food.

Figure 1 When looking for a replacement part online, you must identify the part number. You search through sections of the appliance diagrams that are presented in an “exploded view,” as if a bomb has gone off in the center of the appliance and a photo was taken while all the bits are moving away from the center of the explosion. This also gives you a feel for where everything is placed within the appliance.
Figure 1
When looking for a replacement part online, you must identify the part number. You search through sections of the appliance diagrams that are presented in an “exploded view,” as if a bomb has gone off in the center of the appliance and a photo was taken while all the bits are moving away from the center of the explosion. This also gives you a feel for where everything is placed within the appliance.
Figure 2 Opto-couplers use light to physically separate the input from the output. In this case, AC is being isolated from the MCU. Since the AC voltage is bipolar, twice per cycle the voltage falls to zero when it reverses polarity. The opto-couplers’ LEDs take turns emitting light, depending on the polarity. While the voltage is below the LEDs’ forward voltage rating, each zero-crossing, they remain OFF. The opto-transistor’s output is therefore pulsing at 120Hz, while the AC is ON.
Figure 2
Opto-couplers use light to physically separate the input from the output. In this case, AC is being isolated from the MCU. Since the AC voltage is bipolar, twice per cycle the voltage falls to zero when it reverses polarity. The opto-couplers’ LEDs take turns emitting light, depending on the polarity. While the voltage is below the LEDs’ forward voltage rating, each zero-crossing, they remain OFF. The opto-transistor’s output is therefore pulsing at 120Hz, while the AC is ON.
Figure 3 In a previous project, I used Node-RED to display temperatures from all the 1-wire temperature probes. Now, in this current project, using two of those probes, one in the fridge and one in the freezer, I was able to see the daily temperature fluctuations of my refrigerator (Y-axis: °F, X-axis: Time of day—24 hours).
Figure 3
In a previous project, I used Node-RED to display temperatures from all the 1-wire temperature probes. Now, in this current project, using two of those probes, one in the fridge and one in the freezer, I was able to see the daily temperature fluctuations of my refrigerator (Y-axis: °F, X-axis: Time of day—24 hours).
ISOLATION

Because working with 120VAC is dangerous, we want to keep that circuitry away from our low-voltage circuitry. An LED provides a good detector for one-half on the AC waveform. Two opposing LEDs will capture both half cycles. You can get both single and opposing LEDs in an IC, which uses a photo transistor as a detector. The physical gap between the LEDs and photo transistor in a single IC package gives 5,000V of isolation. With LED connections on one side of the IC and output connections on the other, it’s easy to keep circuit wiring separated. However, it’s a good idea to mount the circuitry to an insulating enclosure to prevent any shorting of the high-voltage wiring, and to put a physical warning label somewhere on the PCB to keep the user aware of the danger. Always remove all power before working on the circuit. I have the opto devices on the same PCB as my MCU. If I were to do this again, I would create a separate isolation PCB to make it safer.

To use an opto-coupler with AC, a series resistor is required to drop most of the voltage because the LEDs drop only a few volts. To keep the resistor’s wattage low, I used a 10kΩ resistor, which will run the LEDs at 10mA. Little current gain was necessary, since the coupler’s output is an input to the MCU. Whenever power is applied to the LEDs, the output transistor turns on. With its emitter grounded and its collector tied high with a pull-up, when the photo transistor turns on, its collector pulls down to a logic low.

Since the LEDs actually are off during zero crossings, the output switches at a 120Hz rate when power is applied. Figure 4 is an oscilloscope screen shot of the opto-coupler output with an AC input. From an MCU’s point of view, the opto-coupler goes high every time the AC signal goes through zero, so it’s not continuously low while the power is on. We need to do some filtering in software to get rid of these pulses.

Figure 5 is a flowchart of how this is accomplished. Since there isn’t much happening other than reading two temperatures once a minute, we can just continually monitor the four AC inputs. Let’s look at one input: AC1. As long as AC1 is OFF, the MCU will see the input as high (logic 1 = OFF state). If AC1=0 (ON), then AC1_State = 1 (ON), and the AC1_count is cleared. If AC1=1 (OFF) and AC1_State is already OFF, then we don’t need to do anything. However, if AC1_State is ON, we need to make sure this isn’t just a zero crossing. We use a counter to keep track of how many times (in a row) we see an OFF. The zero-crossing pulse is about 100µs. I did a 100× loop consisting of just a digitalRead() command, and it took approximately 132µs. That’s about 75 samples in 100ms. Although my sampling loop has other commands and is nowhere near this fast, you can see we must make sure to count enough samples to get past that 100ms before declaring that the AC is OFF. Conversely, as soon as we see an ON, we can consider it ON.

Figure 4 If our application reflected the actual state of the opto-couplers’ output, it would believe the power is not ON continuously, since the input is pulsing at 120Hz. We must fool the application by counting the number of times we see the input is OFF before we consider it really OFF! This is like debouncing a switch input that is usually noisy.
Figure 4
If our application reflected the actual state of the opto-couplers’ output, it would believe the power is not ON continuously, since the input is pulsing at 120Hz. We must fool the application by counting the number of times we see the input is OFF before we consider it really OFF! This is like debouncing a switch input that is usually noisy.
Figure 5 To keep the micro from thinking AC is continually toggling ON and OFF, once the opto-device sees the first ON (logic low), we count the number of times we see an OFF (logic high) to determine that it is actually OFF, and not just the 120Hz zero-crossings.
Figure 5
To keep the micro from thinking AC is continually toggling ON and OFF, once the opto-device sees the first ON (logic low), we count the number of times we see an OFF (logic high) to determine that it is actually OFF, and not just the 120Hz zero-crossings.
DATA INTERPRETATION

When I wrote about the 1-wire bus, any temperature probes found on the bus were read, and their reported temperature was sent to my Raspberry Pi (Pi) using MQTT. MQTT is a client/server publish/subscribe messaging transport protocol. This allows data to be collected by the Pi running an MQTT server application. This is often used for machine-to-machine (M2M) and Internet of Things (IoT) communications. If you have a home control system, it may use or at least offer this as a potential interface.

— ADVERTISMENT—

Advertise Here

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways via a browser-based editor. I like to use the Node-RED application on my Pi to display data gathered by the MQTT server. This way, I get to see what is happening from any browser on my home network. For the 1-wire project, I just graphed the temperature probes. Now I have four other sources that are either ON of OFF. It’s easy to “publish” their states to the Pi’s MQTT server, along with the temperature readings.

Four additional charts were added to Node-RED’s flow of data from the fridge MCU, which included the AC status of power to the thermostat and defrost heater, and the defrost heater request and compressor request. Now, in addition to the questionable temperature fluctuations I was seeing, the added operational status showed that while the request for the compressor was enabled (it’s running), the temperature of the freezer (and the fridge) was going down. This made sense, because the purpose of the compressor is to push a hydrofluorocarbon (HFC) through its closed-loop system. Refrigeration occurs, thanks to the change in temperature of HFC when it goes between its liquid and gaseous states.

Let’s look at the refrigeration cycle beginning with the compressor. The compressor increases the pressure of the HFC, and in doing so, HFC changes from gas to liquid and heats up. The liquid HFC passes through the condenser coils outside the refrigerator, where its heat is transferred into the room. Because this high-pressure liquid gives off heat and is allowed to expand, it turns gaseous and cools down as it enters the evaporator coils in the freezer. The cold gas draws heat from the freezer and again enters the compressor, completing its heat transfer cycle.

When the falling freezer temperature reaches the thermostat’s set point, it opens up, turning off the compressor. There is some hysteresis in the thermostat, such that the temperature must rise about 5°F before the compressor would again be turned ON. You can see from the excursions (Figure 3) that this hysteresis varies from 5°F to about 40°F. At a few points in the graph in Figure 3, the freezer temperature actually approaches the thawing temperature (32°F).

The defrost heater periodically warms the evaporator, which relieves a homeowner from having to remove ice build-up manually. You may remember Mom defrosting the freezer periodically, since older fridges had to be defrosted manually. Ice build-up decreases the evaporator’s ability to draw off heat. While this process is taking place, the compressor is disabled, even if the thermostat is calling for it to cool down the freezer. So, the actual temperature of the freezer could reach thawing temperatures! However, the duration of this process is generally 15 minutes or so—shorter than it would take frozen foods to thaw, due to their mass. This process could take place once or twice a day, and usually depends on the accumulated run time of the compressor. So, periodic rises of the freezer temperature are normal, but the erratic switching points of the thermostat are not. Let’s replace this thermostat.

ORDERING PARTS

Many parts websites offer suggestions on what you might want to change out, based on the symptoms of the appliance. The suggestion to replace the defrost thermostat (fixed temperature snap switch) seemed reasonable at the time, but it didn’t fix the problem. If I’d had the data I have now, I would have known that the defrost thermostat was not malfunctioning. Each defrost cycle was consistently short. Interestingly enough, no website suggested replacing the thermostat for any symptoms! One of the biggest hurdles with this issue was that the refrigerator has to be shut down to investigate any component. The time to remove, test, and reinstall any component meant that everything in the freezer and fridge would begin to warm up. I didn’t want to have to turn the refrigerator OFF until I found the errant part, which could have taken who knows how long.

Receiving a replacement mechanically adjustable thermostat was quick—less than a week, even with standard shipping. Replacing it required the removal of a few plastic covers and carefully unwinding and feeding the pressurized copper tube from the front to the back of the refrigerator compartment. Total time: around 30 minutes. This is a fairly low-tech device (2006), which probably has been replaced by solid-state sensors in today’s newer refrigerators.

With the new thermostat installed, I saw an immediate change in the compressor cycling, as shown in Figure 6. I no longer saw wide temperature swings. Note that at night, when no one was opening the doors, the compressor did not run at all!

Figure 6 After replacing the thermostat, the temperature regulation of both the freezer and refrigerator compartments significantly improved. The freezer now cycles between -15 and -20°F, except for the ~15-minute defrost cycle, which raises the temperature quickly before allowing the compressor to bring the freezer back to the normal temperature of around 15°F (Y-axis: °F, X-axis: Time of day—24 hours).
Figure 6
After replacing the thermostat, the temperature regulation of both the freezer and refrigerator compartments significantly improved. The freezer now cycles between -15 and -20°F, except for the ~15-minute defrost cycle, which raises the temperature quickly before allowing the compressor to bring the freezer back to the normal temperature of around 15°F (Y-axis: °F, X-axis: Time of day—24 hours).
AFTERTHOUGHTS

While replacing the thermostat, I noticed a bit of black dust underneath it. There are no serviceable parts in the thermostat, but that’s no reason not to look further! Upon carefully unbending a few metal tabs that hold all the pieces together, the individual components were free to collapse in a pile of bits and pieces (Figure 7). The mechanics of the thermostat are responsible for opening and closing relay contacts. These contacts are in series with the compressor and control its operation. In a normal day, the compressor is turned ON and OFF about once an hour. That’s 365 × 24 = 8,760 times a year. Typical relays have a life 50,000-100,000 cycles. That would be 8-16 years for this thermostat. Given that the fridge is now 15 years old, I guess this could have been expected.

Figure 7 I couldn’t help but pull apart the “failing” thermostat. Take a look at the switch contacts on the right. You can clearly see that they are blackened and pitted. My guess is they were continuously being semi-tack welded, which then required a greater force by the mechanics to open up the contacts.
Figure 7
I couldn’t help but pull apart the “failing” thermostat. Take a look at the switch contacts on the right. You can clearly see that they are blackened and pitted. My guess is they were continuously being semi-tack welded, which then required a greater force by the mechanics to open up the contacts.

I lucked out this time. I understand the panic of finding an appliance has failed. When it’s something like a refrigerator, there is usually lots of pressure to get it replaced immediately. This, in turn, puts less of a need to have replacement parts available, which either drives up the price of those parts or makes it a non-profitable business. “Ye Olde Fixit Shoppes” are becoming few and far between. I believe this skill is much like plumbers and electricians, and will be in short supply in the near future. It seems to be a requirement today for everyone to go to college. I hope the smart ones out there, with skillful hands, will take a different path. I see a need for more skilled tradesmen. Too much to fix, so little time. 

RESOURCES

Reference:
[1] “Putting 1-Wire Protocol into Action” (Circuit Cellar 373, August 2021)

Espressif Systems | www.espressif.com
Node-RED | www.nodered.org
Renesas Electronics | www.renesas.com

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • DECEMBER 2021 #377 – Get a PDF of the issue

— ADVERTISMENT—

Advertise Here

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the May 2020 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article
Website | + posts

Jeff Bachiochi (pronounced BAH-key-AH-key) has been writing for Circuit Cellar since 1988. His background includes product design and manufacturing. You can reach him at: jeff.bachiochi@imaginethatnow.com or at: www.imaginethatnow.com.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2022 KCK Media Corp.

Refrigerator Repair Project

by Jeff Bachiochi time to read: 13 min