You could also detect multiple switches based on resistor voltage drops. Of course it would take different value resistors ins series with each switch to give the voltages and that is connected to one MC input and then the sketch would have to be written so that it compares the voltages to determine which switches are depressed. Some car keys are decoded this way.
Ah yes, the resistor ladder, suggested by many, disliked by yours truly. After all, in this circuit we have digital inputs going spare so why not use them!
And was it? See another comment above where a viewer lost the contents of their freezer just last week for the exact reason I demonstrated. I said it was a Real World problem!
@@RalphBacon hopefully yes 🙏🏽 😁 Maybe another method could be via measuring the temperature continously/periodically. If the temperature starts falling (slowly, not fast, caused from opening manually) , an alarm should be given out
Sounds far too complicated for me! A simple "is the door open" alarm worked for years in my last place; this one will be battery powered so a bit more to it but basically a simple alarm. You'll be suggesting I send myself an email about the door state soon! Oh, someone did that.
To implement multiple switches to a single input, just create a multi-tapped voltage dropper (say 5 10k in series) and use an analog input to the Arduino off the bottom of the first resistor. Each switch then shorts out one, two ... of the other resistors. This is the standard technique. Quite well known.
Yes, quite well known but frankly quite despised by me, as I used one once and the hysteresis and drift on the analog reading was pretty wide. Not my preferred approach when we have digital inputs going spare, but that's just my approach, Pete. Perhaps I should do a quick video on resistor ladders? Hey, come back, I was just kidding!
Before installing your tilt sensor in the bin, try putting it in the freezer for several hours and then try it to ensure it works. You may run into an issue with the ball bearing getting frozen in place. I assume these sensors will be used year round so the freezer will simulate winter conditions
They'll be used 24x7x365, you are correct. But they will also be protected by a watertight box with foam inside, which should protect them from the worst. But, as it takes but a jiffy to try out the freezer test, I will do that; thanks for the suggestion!
Quite timely. We lost everything in our freezer less than a week ago because something sat a little too close to the edge of the shelf, and the door pockets hit it (like your fridge). It’s out in the garage, and didn’t notice it for a couple of days, after all the food spoiled.
The first fridge-freezer I showed is also sitting out in the utility room which we don't check every day. Hmm. Maybe I need to reinstate the original fridge alarm on that one! See, another Real World problem. Sorry to hear about your lost food, it also happened to us twice before we moved.
You could use a reed switch and magnet, as used in door and window alarms. Make simple enclosures for them out of styrene sheet, or 3D print if you can. Both parts could be made quite small and unobtrusive.
I used a reed switch in the previous fridge alarm (for the fridge in the utility room, which I showed first) but it was tricky to get the distance "just right". The switch must not close unless the door is totally, 100% closed, not "nearly just 1mm open"! This way I can adjust the position without too much trouble.
Just a thought and a simple solution, the two doors become one with a small flat join plate ! just the one switch then required, yes I know there then no longer independent but when I've been shopping and loading the fridge/freezer both doors are open and when I'm getting anything from either then there only open for a brief moment anyway :)
If the boss notices _anything_ different about the fridge/freezer it will fail the "wife test". Anyway, getting a bottle of Bud from the fridge should not involve opening the freezer door, surely?
Hi there, a couple of suggestions. How about using magnetic reed switches like those used in domestic alarms systems? For battery powered systems especially, try using as low a micro clock as will do the job, it saves power and there's nothing to be gained by clocking faster than needed.
Yes, magnetic reed switches would work, and require no physical contact at all. But I'm not sure I can get the accuracy I need (ie the door must be closed when the switch activates). In this case I'm not sure the clock speed is going to matter as the device is switched off for 99% of its life (whenever the door is closed). But I will certainly use an internal clock if available rather than a crystal one, as I don't care about accuracy but I do care about current consumption.
Replace the diodes with a couple of different medium value resistors. Then connect the common side of both switches through a third resistor to your ground return. Connect the high side of the third resistor to an analog input on the CPU. Set the resistor values such that your power up circuit still works. Also set the values of the first two resistors such that when switch 1 is activates ~1mA flows through the third resistor and if switch 2 is activated ~2mA flows through the third resistor. Then measure the voltage across the third resistor to determine which switch is activated. SW1 inactive SW2 inactive = 0V volts SW1 active SW2 inactive = V where V is in the millivolt range SW1 inactive SW2 active = 2V Both active = 2V +V = 3V Only takes one input and is dead simple to build
Some "outside the box" thinking there Craig, very creative. However (you knew that was coming, right?) you've changed a digital input to an analog one and saved one input pin. I don't like resistor ladders or analog inputs if I can avoid them; but that's my personal preference based on what I've built over the years; YMMV as they say! Thanks for the suggestion, I suspect many others will read your comment too, thus spreading the knowledge far and wide 👍
A simple (but musical) buzzer would suffice as it sits in our kitchen. But the fridge I showed first is in the utility room and would not be heard so... I need to think about that one.
@@RalphBacon Just in case you're interested, I followed this guy's Rpi3 tutorial and got my project working. I'm able to send an email alert to myself. Had to watch several of his videos and some videos from corey shafer as well. th-cam.com/video/ASXy92ZauwE/w-d-xo.html
I have a PCB playlist? Really? I will have to do what you say then, I had totally forgotten (blame the 5 months of not doing videos, the house move, my age...).
@@stealthblade1 Agreed, but those furniture-switches have a huge hysteresis too, so in any case it is a question of adjustment. The hysteresis could be adjusted with the huge opening triggering quite late and therefore have a late closing as well.
The furniture switch can be cleverly mounted so that it only goes off when the door is really closed. And opens when the cupboard door has just opened. Now, I did do this with a reed switch (from a burglar alarm door contact) and high power external magnet on the previous fridge alarm (Nano-based, which I might reinstate now, on the "other" fridge I showed first).
Good video. Thought you were going to wire them to one input and use resistors to check for different voltage levels. How are you running the switch wire from the freezer to your microcontroller? How do you get the wire out of the freezer cavity?
If you don't need to know if both switches are on at the same time you only need to check one switch. If the one you check isn't on then the other one is as the MCU has power :) So you can save a diode and pin. Not that there is much point I guess, going to be loads of pins not used anyway. If you want to check for both at once and don't mind using analogue you could also check if the voltage is 0.7 or 0 volts to save a diode. Just thought I would add an option to the resistor divider alternative posts :P PS. Isn't it going to be annoying if the alarm is on all the time the door is open? Nice upgrade might be if the you only sound the alarm if if doors is near to closed for more than say a second. You might need 4 switches :D
Alarm will not sound all the time! That would not only be annoying, it would immediately have the alarm ripped out and never to be reinstalled by the senior design technician (yes, my wife). The alarm (see videos #40 & #41, yes, it's been that long) will chirp as we open a door (different chirp depending on which door), give us warning beep(s) as the time goes by, then finally really go for it when it is obvious the door must be left open! Different alarm rates depending on whether it is the fridge or freezer that is open. The only downside is that Benny (our cat, RIP) and Dougle (our Yorkie) got to recognise the fridge door open chirp and came running to ensure they didn't miss a tasty treat. 😄
@@RalphBacon I guess the small beeps cover the problem of being 1/2 way out the room or back sitting at the table when the alarm goes off. Edit: Only beeping when the doors is left nearly closed would be better for the Cat/Dog though and save the need for the touch switch.
Great as always Ralph! Uh...call me crazy, but for the fridge ,why not just take out the bottom glass shelf, flip it over and draw a nice thick Shapie line across it with a little arrow pointing towards the back of the fridge to let the 'user' know the edge of the door bin? No need for an alarm. But then again, what good would that be? It prevents your creative juices from flowing to make another Arduino solution! Great job! Gord
I have often thought of your non-fun, non-Arduino solution, Gord and I might do _both_ as a belt and braces approach. Actually, why did the manufacturer not do that. Oh, because it makes the fridge storage look tiny, understood!
Hi Ralph, thanks again - nice video. An idea for you - how to drive a bicolour LED with just one I/O line in the simplest (and safest) way possible. Will be interesting, and useful for a lot of folks. Regards!
Depends on the LED; does it have a common anode/cathode (3 leads) or is it just two LEDs in one package (with 4 leads). Former will require one resistor protected input to sink/source power respectively; and the latter, well, we would common the anodes and do the same. I realise that beginners would not know this so I might drop it into a future video. Just to make it more interesting we can use different resistors (across the diodes) to give different operating currents for each LED!
Common cathode 3 lead seems to be the most "common". I already know how to do this - there's a few caveats though. Just thought it might make an interesting video.
I love your real world problems of too many bottles of beer in the fridge:-), my fridge doesn't have too many beers in it as I tend to drink them as soon as they are bought:-) so the door closes okay :-) I also have the pico and the 1602A display waiting for your video on that ;-)
I have less beer in the fridge now as I have one in a glass right next to me... hang on... half a one in a glass right next to me. Yes, that 1602 and the PICO works fine using MicroPython but C++ still locks up the USB. Working on it!
It probably could power it for one "chirp" of radio waves, but what about when it's left up - we'd have no power to keep sending the "chirp" every 15 minutes, say.
Ralph, given how little power your fridge monitor needs is there any chance you could trickle charge the battery from a tiny solar panel ? (Assuming the design meets your Mrs approval of course 😀)
You already know the answer, Chris. Firstly, the Mrs would *not approve* of any such nonsense. And, secondly, there is *no sun* in our kitchen. However, I do have a solar panel design for something else in mind in the future, so keep tuned!
Wait I thought the whole point of this was to measure two buttons with one input? And then you use a pin each to measure each button (2 pins, 2 "inputs")? Am I missing something here?
No, you're not missing something but remember that each pin must be driven by the same +5v input (well, must be connected to the Gate of the P-Channel MOSFET, so a common connection). And I want to differentiate between switches, ie not wired in parallel. So it's not the same as having two independent switches connected to two independent input pins. Well, after my circuit it is!
Got 9 and a bit minutes in. . . 2 Points: 1: Rubbish American Lager? Get some Belgian BEER. Now that's worth drinking! (And I'm from the UK). 2: You have a cat (from your TH-cam 'header'). No fridge/freezer is cat proof. They have a Faraday/Tesla/Force field that stops all switches working. But seriously, considering for home use. Keep up the good work! :-)
The American lager is fine for lunchtimes (so I don't doze off in the afternoon). We no longer have a cat. 😥 Benny passed away 10 months ago and Dougle (our Yorkie) has yet to jump 4 feet into the air and open a fridge door!
Hi Ralph, The biggest problem for us Arduinite's at the moment is getting chips, the 328p-AU is either ridiculously priced or out of stock or both ! at least thats what I'm finding....cheers.
That's a shame. Luckily for me I have a decent stock of both lqfp and Dip although I'll be using 3 of those in my bin lid project. I'll make a note to try and source more over the next few weeks - thanks for the heads up.
having thought a bit, i suspect that the internal temperature of the fridge could be used effectively to tell if the door is open! direction and rate of change, either stand alone or with motor/temp switch input.
Glad you're thinking about this Real World problem, Jonathan, but how would it detect the door closing (quickly enough) and thus switching off the end-of-the-world alarm?
Maybe by mounting the temperature sensor in the back (so the temperature won't change as fast)? Or just that the temperature has to be too warm for a long enough time (minutes?) before sounding the alarm.
@@RalphBacon cos we is clever! we use the both rate of change and absolute temperature, we see the temperature is dropping and reset - leave for a couple of minuets and re test.
of course there are many solutions but most are mundane. This is why we love Ralph, for his teaching and elegant solutions, so we can apply them to our own projects not just duplicating his.
I'm not sure my solution is particularly elegant but it will work! And meet the design and aesthetic approval of *the boss* , which is paramount. She lets me do whatever I want in my workshop, but the house is a different matter all together!
Use 2 switches in series. Both NC switches. Who cares if it's the fridge or the freezer. If either one opens that would be the trigger. Then write the code so that the alarm does not go off until the door is left open for some time period you set.
I could do that, Toney, for sure. But as we _can_ detect more than one switch I thought I'd demonstrate a simple way of doing that and then I'd also know whether the fridge or freezer door has been left open.
@@RalphBacon You could also use a temperature sensor. That would inform you if the door was left open or if the fridge/freezer developed another problem.
A temperature sensor is too slow for what I want, really. And the "alarm" will get more urgent the longer the door is left open. I might be stocking up on beer so it might beep once or twice - but after 5 minutes it's probably a door-left-open situation (too much beer in the fridge) so all hell will break loose!
Yes, that's an option as long as the distance between the door and the frame can be accurately measured. The door "nearly closed" is not good enough, if you see what I mean.
Unfortunately not for some time. We still have Dougle (our Yorkie) to look after and we just have no desire for a Benny replacement. He was unique. One of a kind. Never to be repeated. Or replaced. 😥
I think we should set up a design committee to plan the design approach first. Then a sub-committee to ratify the design decisions but only after some R&D and cost-benefit analysis. Anyone got a Quantum Computer handy?
This rings bells that I might have put a further (Schottky) diode in series with the pin(s) in another circuit. I will have to check this. Excellent point, Jens.
I was thinking putting one in series with the input pins so current can only flow OUT of the μC not back into it, thus shorting the gate of the MOSFET to GND and switching it on. I'm sure I've done this before. Anyway, I will have to check that all is OK before finalising my design (which is 100% in my head right now). Keep tuned!
@@RalphBacon My solution would be to connect one end the switch to VBAT+ ant the other through a resistor to ground. From the point called "A" where the switch and resistor are connected insert a diode (Anode) connect the Cathode to the gate of an NFET (Source to ground, Drain to the existing FET gate). And insert a resistor from A to an input port of the MCU. The purpose of the diodes is to make a OR gate. Now we only need to pull down the Gate of the new FET, this can be done connecting a resistor to ground, or perhaps connecting it to an output port of the MCU, in that way the MCU is in control of switching off power.
Unfortunately the switch itself can cause the door to not close properly. And the light will always go off _before_ the door has properly closed (if it does close properly at all).
I was watching the intro and it got me thinking of a funny problem I am having with some JLCPCB boards, I am using "ESP32 thing" boards and I made a PCB just to connect the ESP with logic level converters and some terminals, nothing more, not any component, it has only traces for connections. My ESP32s do not connect to WiFi if I plug them in the PCB, just the PCB, with or without the logic level converters is somehow making my ESP32 boards unable to connect to WiFi. I have checked visually, checked voltages, continuity, I have enough power supply current, the problem occurs with the 3 ESP boards I have. So I don`t know what can cuase this. I designed the PCB using Kicad and have done ERC. I wired the same circuit in a protoboard and the ESP connects to WiFi, but as soon I use the PCB the ESP can't connect. SO do you think something in the PCB manufacturing can cause this? I really have tried to find my own mistakes but the PCB is so simple I cannot find what went wrong.
Hmm. So annoying when this sort of thing happens. So you have ZERO components on the (dual sided) PCB - just the ESP32? No pullups/pulldowns, caps or anything? 1. Have you got a ground plane under the antenna area of the ESP32 that is zapping all the RF frequencies? 2. Does the ESP32 boot normally otherwise, just will not connect to your home Wi-Fi? The serial output on a reset shows a normal boot? 3. Which pins do the logic level converters connect to? If you can post a decent picture somewhere of the PCB (front and back) it might help us investigate further.
@@RalphBacon thanks for the help!!! It only has a 10uF cap connected to reset because it is the only way I have found to successfully upload code to these boards, but besides that there is no other component, the problem occurs with and without this cap I have tested two PCBs and the two present this issue. 1. Yes it has ground under the antenna, but the ESP is not directly sitting on the PCB, it is lifted like 8 or 10mm since it's sitting on a female header. I was thinking of grinding that section of the PCB with a Dremel to see what happens 2. It reboots normally most of the time, but I have found the ESP gets hot on one of the boards while it is connected to the PCB, one board outputs garbage to the serial port sometimes, but I have one that has zero problems again I have not found any shorts or soldering problems. 3. The logic converters are wired to 5,15,16,17,19,22,23 at first I thought it was some problem with 5 and 15 cause I read those pins output PWM signals at boot (I have no scope to see that :/) but I have this problems with and without using 5 and 15. Also with and without using the logic level converters Note: here is 1:44 am so I cannot take those pictures right now but tomorrow I'll do it and upload them to a Drive folder Thanks again!!
@@RalphBacon drive.google.com/drive/folders/1BgIe6l5SQ4hib_POGQub8vhCrKpTUBWC?usp=sharing I uploaded some pictures, and pdfs, thanks for taking the time mate!
OK, I've downloaded the files to my PC for a good look later, as this morning I have urgent (yes, even _more_ urgent) business to deal with. I'll get back to you soon.
Have you considered using a Latch circuit instead of putting the micro to sleep, it use less power. Look at this video from Electronoobs th-cam.com/video/Er8fSoeaZD0/w-d-xo.html where he demonstrates it. If you look at the last comment, it's from me where I have a link to button circuit I built using his latch circuit. My version 2 of it (short, long or mutliple press) uses an Attiny85 and an ESP or a HC12 433mhz transceiver. I measured the current with an Power Profiler 2 and it was nano amps when idle.
So, the latch circuit he describes there is pretty much identical to my auto on/off/kill circuit from various of my videos (eg #172, #173). As I demoed this first I claim bragging rights!!!
Good grief no. You obviously missed the previous videos on fridge alarms, Ian. A nice chirp as the door opens, a reminder beep after 30 seconds, two reminder beeps after 60 seconds.... finally full blown annoying BEEP BEEP after X minutes (where X is yet to be decided by chief design architect, aka my wife). If the door shuts in time, we use an interrupt to give a reverse chirp that the door closed OK. It's amazing how quickly you get to listen for the confirmation-of-door-closed noise!
could you remove the fridge doors' bottom shelf so you can put what you like on the bottom shelf including the milk (which will stay just a little bit cooler as it will no longer be wedged up against the door in the door shelf). If not then you really need an AI house bot called Marvin to do it all.
If you're ever stuck for a micro switch just dig up an old computer mouse from the junk stash (We all have them). They have three or four nice quality microswitches in them that are very easy to push down albeit with no lever. Great video but terrible fridge. What a stupid design.
Thanks for the tip! Those mice microswitches are pretty easy to press too. Regarding the design of the fridge, I could not agree more, but we inherited it. Maybe, one day, we'll replace it with a better one!
Er... at which point? Ah ha! The force on the microswitch can be measured in Newtons or grams if that is what you are referring to? I prefer grams, I can understand that!
I was living the story and enjoying it....then my common sense and stingy streak kicked in and spoilt my beautiful trans like state.....why add 2 diodes when you could add just one resistor...say another 100K in line with second switch....result would be the same ...both independently signalling hi or low states ...I am sure there is something I am missing...just can't see it
I wanted to (a) keep this simple and (b) avoid analog resistor ladders just because I don't like them 😁 Two 100K resistors instead of two diodes will also work but it can all get a bit edgy - diodes simply conduct or block so I find it a safer design decision. But that's me, squandering the family inheritance on diodes 🤣
@@RalphBaconDiodes have voltage drop though. In some cases it may be high enough to bring high logic level below detection threshold. Or at least that drop in pull-up voltage will lower noise immunity on the input, especially with a bit high value of the pull-up, like 100K.
You could also detect multiple switches based on resistor voltage drops. Of course it would take different value resistors ins series with each switch to give the voltages and that is connected to one MC input and then the sketch would have to be written so that it compares the voltages to determine which switches are depressed. Some car keys are decoded this way.
Ah yes, the resistor ladder, suggested by many, disliked by yours truly. After all, in this circuit we have digital inputs going spare so why not use them!
Keep the beer cold at all costs - finally an Arduino project for me
Agreed. Warm beer is a crime against all breweries everywhere.
a resistor for each switch but different values and read via Analog Input
Resistor ladder. Yes, suggested a few times here but with so many digital pins going spare there is no need IMHO.
Excellent video, how could I have missed it for so long? I hope you publish some new videos Ralph, you channel is one of the best on TH-cam
Thanks, will do!
The first thing I checked if my fridge is completely closed 😂😂
Nice video! 👌🏽
And was it? See another comment above where a viewer lost the contents of their freezer just last week for the exact reason I demonstrated. I said it was a Real World problem!
@@RalphBacon hopefully yes 🙏🏽 😁
Maybe another method could be via measuring the temperature continously/periodically. If the temperature starts falling (slowly, not fast, caused from opening manually) , an alarm should be given out
Sounds far too complicated for me! A simple "is the door open" alarm worked for years in my last place; this one will be battery powered so a bit more to it but basically a simple alarm. You'll be suggesting I send myself an email about the door state soon! Oh, someone did that.
To implement multiple switches to a single input, just create a multi-tapped voltage dropper (say 5 10k in series) and use an analog input to the Arduino off the bottom of the first resistor. Each switch then shorts out one, two ... of the other resistors.
This is the standard technique. Quite well known.
Yes, quite well known but frankly quite despised by me, as I used one once and the hysteresis and drift on the analog reading was pretty wide.
Not my preferred approach when we have digital inputs going spare, but that's just my approach, Pete.
Perhaps I should do a quick video on resistor ladders? Hey, come back, I was just kidding!
Before installing your tilt sensor in the bin, try putting it in the freezer for several hours and then try it to ensure it works. You may run into an issue with the ball bearing getting frozen in place. I assume these sensors will be used year round so the freezer will simulate winter conditions
They'll be used 24x7x365, you are correct. But they will also be protected by a watertight box with foam inside, which should protect them from the worst. But, as it takes but a jiffy to try out the freezer test, I will do that; thanks for the suggestion!
Quite timely. We lost everything in our freezer less than a week ago because something sat a little too close to the edge of the shelf, and the door pockets hit it (like your fridge). It’s out in the garage, and didn’t notice it for a couple of days, after all the food spoiled.
The first fridge-freezer I showed is also sitting out in the utility room which we don't check every day. Hmm. Maybe I need to reinstate the original fridge alarm on that one! See, another Real World problem. Sorry to hear about your lost food, it also happened to us twice before we moved.
You could use a reed switch and magnet, as used in door and window alarms. Make simple enclosures for them out of styrene sheet, or 3D print if you can. Both parts could be made quite small and unobtrusive.
I used a reed switch in the previous fridge alarm (for the fridge in the utility room, which I showed first) but it was tricky to get the distance "just right". The switch must not close unless the door is totally, 100% closed, not "nearly just 1mm open"!
This way I can adjust the position without too much trouble.
Just a thought and a simple solution, the two doors become one with a small flat join plate ! just the one switch then required, yes I know there then no longer independent but when I've been shopping and loading the fridge/freezer both doors are open and when I'm getting anything from either then there only open for a brief moment anyway :)
If the boss notices _anything_ different about the fridge/freezer it will fail the "wife test". Anyway, getting a bottle of Bud from the fridge should not involve opening the freezer door, surely?
Hi there, a couple of suggestions. How about using magnetic reed switches like those used in domestic alarms systems? For battery powered systems especially, try using as low a micro clock as will do the job, it saves power and there's nothing to be gained by clocking faster than needed.
Yes, magnetic reed switches would work, and require no physical contact at all. But I'm not sure I can get the accuracy I need (ie the door must be closed when the switch activates).
In this case I'm not sure the clock speed is going to matter as the device is switched off for 99% of its life (whenever the door is closed). But I will certainly use an internal clock if available rather than a crystal one, as I don't care about accuracy but I do care about current consumption.
Thank you for supplying us with the recommended dose of weekly Bacon. -I'd love to get some more tho ;)
Awesome video as always, Sir
Crispy, sizzling Bacon always served fresh!
Nice switch differentiation.
Glad you think so!
Replace the diodes with a couple of different medium value resistors. Then connect the common side of both switches through a third resistor to your ground return. Connect the high side of the third resistor to an analog input on the CPU. Set the resistor values such that your power up circuit still works. Also set the values of the first two resistors such that when switch 1 is activates ~1mA flows through the third resistor and if switch 2 is activated ~2mA flows through the third resistor. Then measure the voltage across the third resistor to determine which switch is activated.
SW1 inactive SW2 inactive = 0V volts
SW1 active SW2 inactive = V where V is in the millivolt range
SW1 inactive SW2 active = 2V
Both active = 2V +V = 3V
Only takes one input and is dead simple to build
Some "outside the box" thinking there Craig, very creative. However (you knew that was coming, right?) you've changed a digital input to an analog one and saved one input pin. I don't like resistor ladders or analog inputs if I can avoid them; but that's my personal preference based on what I've built over the years; YMMV as they say!
Thanks for the suggestion, I suspect many others will read your comment too, thus spreading the knowledge far and wide 👍
Nice. How would the alarm be sent? A buzzer? It's possible to send an email using python. What happened your finger?
A simple (but musical) buzzer would suffice as it sits in our kitchen. But the fridge I showed first is in the utility room and would not be heard so... I need to think about that one.
@@RalphBacon Just in case you're interested, I followed this guy's Rpi3 tutorial and got my project working. I'm able to send an email alert to myself. Had to watch several of his videos and some videos from corey shafer as well. th-cam.com/video/ASXy92ZauwE/w-d-xo.html
"What do you mean, a week?" lol. When you mention your sponsor, you might want to mention that you have the PCB playlist. I had to look it up.
I have a PCB playlist? Really? I will have to do what you say then, I had totally forgotten (blame the 5 months of not doing videos, the house move, my age...).
Hello Ralph, have a look at reed-switches, thiey work with a magnet nearing it, so practically no force involved.
The problem with reed switches is the high hysteresis - for this problem you need the smallest hysteresis possible to detect a minimal opening.
@@stealthblade1 Agreed, but those furniture-switches have a huge hysteresis too, so in any case it is a question of adjustment. The hysteresis could be adjusted with the huge opening triggering quite late and therefore have a late closing as well.
The furniture switch can be cleverly mounted so that it only goes off when the door is really closed. And opens when the cupboard door has just opened. Now, I did do this with a reed switch (from a burglar alarm door contact) and high power external magnet on the previous fridge alarm (Nano-based, which I might reinstate now, on the "other" fridge I showed first).
Good video. Thought you were going to wire them to one input and use resistors to check for different voltage levels. How are you running the switch wire from the freezer to your microcontroller? How do you get the wire out of the freezer cavity?
i think its on the outside.
Yes, the wires are from the white switch which is screwed (currently Blu-tacked) to the inside of the cupboard but outside of the fridge/freezer unit.
If you don't need to know if both switches are on at the same time you only need to check one switch. If the one you check isn't on then the other one is as the MCU has power :) So you can save a diode and pin. Not that there is much point I guess, going to be loads of pins not used anyway.
If you want to check for both at once and don't mind using analogue you could also check if the voltage is 0.7 or 0 volts to save a diode.
Just thought I would add an option to the resistor divider alternative posts :P
PS.
Isn't it going to be annoying if the alarm is on all the time the door is open? Nice upgrade might be if the you only sound the alarm if if doors is near to closed for more than say a second. You might need 4 switches :D
Alarm will not sound all the time! That would not only be annoying, it would immediately have the alarm ripped out and never to be reinstalled by the senior design technician (yes, my wife).
The alarm (see videos #40 & #41, yes, it's been that long) will chirp as we open a door (different chirp depending on which door), give us warning beep(s) as the time goes by, then finally really go for it when it is obvious the door must be left open! Different alarm rates depending on whether it is the fridge or freezer that is open.
The only downside is that Benny (our cat, RIP) and Dougle (our Yorkie) got to recognise the fridge door open chirp and came running to ensure they didn't miss a tasty treat. 😄
@@RalphBacon I guess the small beeps cover the problem of being 1/2 way out the room or back sitting at the table when the alarm goes off.
Edit:
Only beeping when the doors is left nearly closed would be better for the Cat/Dog though and save the need for the touch switch.
I'm not sure I'll be implementing the touch switch this time; they still knew when I was opening the door, must be telepathy.
Great as always Ralph! Uh...call me crazy, but for the fridge ,why not just take out the bottom glass shelf, flip it over and draw a nice thick Shapie line across it with a little arrow pointing towards the back of the fridge to let the 'user' know the edge of the door bin? No need for an alarm.
But then again, what good would that be? It prevents your creative juices from flowing to make another Arduino solution!
Great job! Gord
your missing the point,he is teaching.
I have often thought of your non-fun, non-Arduino solution, Gord and I might do _both_ as a belt and braces approach.
Actually, why did the manufacturer not do that. Oh, because it makes the fridge storage look tiny, understood!
@@TheUnofficialMaker I'm kidding. I'm a huge fan of Ralph's work😎
Linux for ever.No blue screens.luv your vids,they are very educational.
Glad you like my videos! I'm sure Linux is very good but I'm a windows man!
Hi Ralph, thanks again - nice video. An idea for you - how to drive a bicolour LED with just one I/O line in the simplest (and safest) way possible. Will be interesting, and useful for a lot of folks. Regards!
Depends on the LED; does it have a common anode/cathode (3 leads) or is it just two LEDs in one package (with 4 leads). Former will require one resistor protected input to sink/source power respectively; and the latter, well, we would common the anodes and do the same. I realise that beginners would not know this so I might drop it into a future video.
Just to make it more interesting we can use different resistors (across the diodes) to give different operating currents for each LED!
Common cathode 3 lead seems to be the most "common". I already know how to do this - there's a few caveats though. Just thought it might make an interesting video.
Thanks yet again for an excellent and inspiring video.
If it inspires you, or gets you thinking, then my work here is done!
I love your real world problems of too many bottles of beer in the fridge:-), my fridge doesn't have too many beers in it as I tend to drink them as soon as they are bought:-) so the door closes okay :-) I also have the pico and the 1602A display waiting for your video on that ;-)
I have less beer in the fridge now as I have one in a glass right next to me... hang on... half a one in a glass right next to me. Yes, that 1602 and the PICO works fine using MicroPython but C++ still locks up the USB. Working on it!
Proper energy harvesting you use the opening of the bin lid to power the device. 😎
It probably could power it for one "chirp" of radio waves, but what about when it's left up - we'd have no power to keep sending the "chirp" every 15 minutes, say.
Ralph, given how little power your fridge monitor needs is there any chance you could trickle charge the battery from a tiny solar panel ? (Assuming the design meets your Mrs approval of course 😀)
You already know the answer, Chris. Firstly, the Mrs would *not approve* of any such nonsense. And, secondly, there is *no sun* in our kitchen.
However, I do have a solar panel design for something else in mind in the future, so keep tuned!
Wait I thought the whole point of this was to measure two buttons with one input? And then you use a pin each to measure each button (2 pins, 2 "inputs")? Am I missing something here?
No, you're not missing something but remember that each pin must be driven by the same +5v input (well, must be connected to the Gate of the P-Channel MOSFET, so a common connection). And I want to differentiate between switches, ie not wired in parallel.
So it's not the same as having two independent switches connected to two independent input pins.
Well, after my circuit it is!
Got 9 and a bit minutes in. . .
2 Points:
1: Rubbish American Lager? Get some Belgian BEER. Now that's worth drinking! (And I'm from the UK).
2: You have a cat (from your TH-cam 'header'). No fridge/freezer is cat proof. They have a Faraday/Tesla/Force field that stops all switches working.
But seriously, considering for home use.
Keep up the good work! :-)
The American lager is fine for lunchtimes (so I don't doze off in the afternoon). We no longer have a cat. 😥 Benny passed away 10 months ago and Dougle (our Yorkie) has yet to jump 4 feet into the air and open a fridge door!
Hi Ralph, The biggest problem for us Arduinite's at the moment is getting chips, the 328p-AU is either ridiculously priced or out of stock or both ! at least thats what I'm finding....cheers.
That's a shame. Luckily for me I have a decent stock of both lqfp and Dip although I'll be using 3 of those in my bin lid project. I'll make a note to try and source more over the next few weeks - thanks for the heads up.
@@RalphBacon Would be interesting to see how you get on.
Well hello! maybe for a neat installation, remember the seals on a fridge and freezer are magnetic !, go hall effect or reed ? just a thought!
having thought a bit, i suspect that the internal temperature of the fridge could be used effectively to tell if the door is open! direction and rate of change, either stand alone or with motor/temp switch input.
Glad you're thinking about this Real World problem, Jonathan, but how would it detect the door closing (quickly enough) and thus switching off the end-of-the-world alarm?
Maybe by mounting the temperature sensor in the back (so the temperature won't change as fast)? Or just that the temperature has to be too warm for a long enough time (minutes?) before sounding the alarm.
@@RalphBacon cos we is clever! we use the both rate of change and absolute temperature, we see the temperature is dropping and reset - leave for a couple of minuets and re test.
You is clever, maybe, but I is simple - which is how I want this alarm to be! 🤣
Would a NAND Gate work here, also the fridge alarm can easily and discretely be done with a reed switch.
of course there are many solutions but most are mundane. This is why we love Ralph, for his teaching and elegant solutions, so we can apply them to our own projects not just duplicating his.
I'm not sure my solution is particularly elegant but it will work! And meet the design and aesthetic approval of *the boss* , which is paramount. She lets me do whatever I want in my workshop, but the house is a different matter all together!
Use 2 switches in series. Both NC switches. Who cares if it's the fridge or the freezer. If either one opens that would be the trigger. Then write the code so that the alarm does not go off until the door is left open for some time period you set.
I could do that, Toney, for sure. But as we _can_ detect more than one switch I thought I'd demonstrate a simple way of doing that and then I'd also know whether the fridge or freezer door has been left open.
@@RalphBacon You could also use a temperature sensor. That would inform you if the door was left open or if the fridge/freezer developed another problem.
A temperature sensor is too slow for what I want, really. And the "alarm" will get more urgent the longer the door is left open. I might be stocking up on beer so it might beep once or twice - but after 5 minutes it's probably a door-left-open situation (too much beer in the fridge) so all hell will break loose!
Budweiser! I'll give you the benefit of the doubt and assume you use it in a wasp trap. :D
I normally drink Real Ale (for Real Men, obviously) but for lunch I often share a Bud with my wife. At least I don't fall asleep after one!
Hello Ralph, use magnetic switch eg: alarm switch
Yes, that's an option as long as the distance between the door and the frame can be accurately measured. The door "nearly closed" is not good enough, if you see what I mean.
@@RalphBacon I guess the only logical choice, a micro switch with low compression lever.
there's also neodium magnet
Exactly so!
Very informative video Sir
Glad you like it! Nice to see you here again.
Awesome!! Could I invite you to test a £39.99 desk lamp? Very suitable for home office & night working.
I've already got all the lamps I need, thank you Carol, but nice of you to think of me.
When will Benny II make his debut?
Unfortunately not for some time. We still have Dougle (our Yorkie) to look after and we just have no desire for a Benny replacement. He was unique. One of a kind. Never to be repeated. Or replaced. 😥
That fridge problem clearly needs AI and blockchain to solve this… 😉 Great video as always. Thank you for making these videos!
I think we should set up a design committee to plan the design approach first. Then a sub-committee to ratify the design decisions but only after some R&D and cost-benefit analysis. Anyone got a Quantum Computer handy?
Wouldn't your microntroler pull down the inputs when power off. This will turn on the mcu again?
This rings bells that I might have put a further (Schottky) diode in series with the pin(s) in another circuit. I will have to check this. Excellent point, Jens.
@@RalphBacon I don't think diodes will do the trick, and especially not schottky, they have a high quiescent current.
I was thinking putting one in series with the input pins so current can only flow OUT of the μC not back into it, thus shorting the gate of the MOSFET to GND and switching it on. I'm sure I've done this before. Anyway, I will have to check that all is OK before finalising my design (which is 100% in my head right now). Keep tuned!
@@RalphBacon My solution would be to connect one end the switch to VBAT+ ant the other through a resistor to ground. From the point called "A" where the switch and resistor are connected insert a diode (Anode) connect the Cathode to the gate of an NFET (Source to ground, Drain to the existing FET gate). And insert a resistor from A to an input port of the MCU. The purpose of the diodes is to make a OR gate. Now we only need to pull down the Gate of the new FET, this can be done connecting a resistor to ground, or perhaps connecting it to an output port of the MCU, in that way the MCU is in control of switching off power.
Your fridge already has a switch for the light. Can't you hack into that?
Unfortunately the switch itself can cause the door to not close properly. And the light will always go off _before_ the door has properly closed (if it does close properly at all).
I was watching the intro and it got me thinking of a funny problem I am having with some JLCPCB boards, I am using "ESP32 thing" boards and I made a PCB just to connect the ESP with logic level converters and some terminals, nothing more, not any component, it has only traces for connections. My ESP32s do not connect to WiFi if I plug them in the PCB, just the PCB, with or without the logic level converters is somehow making my ESP32 boards unable to connect to WiFi. I have checked visually, checked voltages, continuity, I have enough power supply current, the problem occurs with the 3 ESP boards I have. So I don`t know what can cuase this. I designed the PCB using Kicad and have done ERC.
I wired the same circuit in a protoboard and the ESP connects to WiFi, but as soon I use the PCB the ESP can't connect. SO do you think something in the PCB manufacturing can cause this? I really have tried to find my own mistakes but the PCB is so simple I cannot find what went wrong.
Hmm. So annoying when this sort of thing happens. So you have ZERO components on the (dual sided) PCB - just the ESP32? No pullups/pulldowns, caps or anything?
1. Have you got a ground plane under the antenna area of the ESP32 that is zapping all the RF frequencies?
2. Does the ESP32 boot normally otherwise, just will not connect to your home Wi-Fi? The serial output on a reset shows a normal boot?
3. Which pins do the logic level converters connect to?
If you can post a decent picture somewhere of the PCB (front and back) it might help us investigate further.
@@RalphBacon thanks for the help!!!
It only has a 10uF cap connected to reset because it is the only way I have found to successfully upload code to these boards, but besides that there is no other component, the problem occurs with and without this cap I have tested two PCBs and the two present this issue.
1. Yes it has ground under the antenna, but the ESP is not directly sitting on the PCB, it is lifted like 8 or 10mm since it's sitting on a female header. I was thinking of grinding that section of the PCB with a Dremel to see what happens
2. It reboots normally most of the time, but I have found the ESP gets hot on one of the boards while it is connected to the PCB, one board outputs garbage to the serial port sometimes, but I have one that has zero problems again I have not found any shorts or soldering problems.
3. The logic converters are wired to 5,15,16,17,19,22,23 at first I thought it was some problem with 5 and 15 cause I read those pins output PWM signals at boot (I have no scope to see that :/) but I have this problems with and without using 5 and 15. Also with and without using the logic level converters
Note: here is 1:44 am so I cannot take those pictures right now but tomorrow I'll do it and upload them to a Drive folder
Thanks again!!
@@RalphBacon drive.google.com/drive/folders/1BgIe6l5SQ4hib_POGQub8vhCrKpTUBWC?usp=sharing I uploaded some pictures, and pdfs, thanks for taking the time mate!
I've requested access to that drive.
OK, I've downloaded the files to my PC for a good look later, as this morning I have urgent (yes, even _more_ urgent) business to deal with. I'll get back to you soon.
Good
My pleasure!
Have you considered using a Latch circuit instead of putting the micro to sleep, it use less power. Look at this video from Electronoobs th-cam.com/video/Er8fSoeaZD0/w-d-xo.html where he demonstrates it. If you look at the last comment, it's from me where I have a link to button circuit I built using his latch circuit. My version 2 of it (short, long or mutliple press) uses an Attiny85 and an ESP or a HC12 433mhz transceiver. I measured the current with an Power Profiler 2 and it was nano amps when idle.
I will look at that with a beer in just a moment, JC. Thanks for the link.
So, the latch circuit he describes there is pretty much identical to my auto on/off/kill circuit from various of my videos (eg #172, #173). As I demoed this first I claim bragging rights!!!
So you're not going to just wire the switches in parallel and power an annoying buzzer then? :D
Good grief no. You obviously missed the previous videos on fridge alarms, Ian. A nice chirp as the door opens, a reminder beep after 30 seconds, two reminder beeps after 60 seconds.... finally full blown annoying BEEP BEEP after X minutes (where X is yet to be decided by chief design architect, aka my wife). If the door shuts in time, we use an interrupt to give a reverse chirp that the door closed OK. It's amazing how quickly you get to listen for the confirmation-of-door-closed noise!
😂might need a coupla screws for the switch……which I’m sure you done….😊
Already done!
could you remove the fridge doors' bottom shelf so you can put what you like on the bottom shelf including the milk (which will stay just a little bit cooler as it will no longer be wedged up against the door in the door shelf). If not then you really need an AI house bot called Marvin to do it all.
Order #3254: one house bot (Marvin). Send asap. 😁
If you're ever stuck for a micro switch just dig up an old computer mouse from the junk stash (We all have them). They have three or four nice quality microswitches in them that are very easy to push down albeit with no lever.
Great video but terrible fridge. What a stupid design.
Thanks for the tip! Those mice microswitches are pretty easy to press too. Regarding the design of the fridge, I could not agree more, but we inherited it. Maybe, one day, we'll replace it with a better one!
By the way ,the finger looks a bit sore.
It was _very_ sore when it happened! Healed now, but I do have a scar!
Don't you mean Newtons Ralph?
Er... at which point? Ah ha! The force on the microswitch can be measured in Newtons or grams if that is what you are referring to? I prefer grams, I can understand that!
@@RalphBacon Ahh, but the gram refers to mass. Just messing ;-)
I was living the story and enjoying it....then my common sense and stingy streak kicked in and spoilt my beautiful trans like state.....why add 2 diodes when you could add just one resistor...say another 100K in line with second switch....result would be the same ...both independently signalling hi or low states ...I am sure there is something I am missing...just can't see it
if the microprocessor has adc (analog to digital) , checked ADC in Atmega328p, it has.
checked attiny13, it also has adc.
@@jyvben1520 ADC has nothing to do with it.
That's pretty much how it's usually done, the whole role of pull-up resistors is isolation of switches from the supply.
I wanted to (a) keep this simple and (b) avoid analog resistor ladders just because I don't like them 😁
Two 100K resistors instead of two diodes will also work but it can all get a bit edgy - diodes simply conduct or block so I find it a safer design decision. But that's me, squandering the family inheritance on diodes 🤣
@@RalphBaconDiodes have voltage drop though. In some cases it may be high enough to bring high logic level below detection threshold. Or at least that drop in pull-up voltage will lower noise immunity on the input, especially with a bit high value of the pull-up, like 100K.
Ugly microswitches are nothing that cannot be fixed with a 3d printer.
If only I had one, Andy! But I am trying to learn Fusion360 in preparation for one...
I was first :-)
have a mirror, highfive yourself !
Glad to see you are keen, Ole!