#159

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ก.ย. 2024
  • Movement activated alarm with optional dark/light requirement - ideal beginner's project!
    2-sided PCB just $5 for 10 pieces: www.pcbway.com
    *PCB Prototyping the easy way - see my video #129 for Hands-On details*
    Everything you see here plus a lot more is in my GitHub:
    github.com/Ral...
    This relatively simple project, ideal for a beginner, is a movement triggered alarm, as long as it is dark.
    It runs on 3 x AA batteries so the ATMega328P I'm using is put into Deep Sleep and consumes just 0.3µA, whereas the PIR consumes 16µA - quite a difference!
    It's a easy project and I'll design a PCB for it using through-hole technology making it even easier for beginners to assemble without worrying about SMD components!
    One of the benefits of a simple project like this is that it can be configured in a number of ways: instead of it having to be *dark* to trigger the alarm it can be made to be *light* instead. And the sensitivity is adjustable, anyway.
    Don't want the beeper? Just use the LED and single resistor then. You want the alarm to sound for more than 5 seconds? That's a simple one-line code change! And more changes are just as easy to implement, either in code or in hardware.
    You want to a different module to trigger the ATMega328P? Easily done.
    The video contains a structured walkthrough, circuit diagram and various verbal meanderings from me including showing you the current consumption both with and without the PIR unit.
    MiniCore
    There wasn't enough time to talk about the MiniCore this week, but I'll include that the next time we look at this project's progress. It's very useful if you want to change the bare ATMega's clock speed, BOD, LTO and so on. We'll go through it next time.
    Everything you see here plus a lot more is in my GitHub:
    github.com/Ral...
    LINKS
    Small **beeper**: 5 PCS Super Loud 5V Active Alarm Buzzer Beeper Tracker 9\*5.5mm
    www.banggood.c...
    Small *PIR module* (5 pieces you can buy singly or in threes too)
    www.banggood.c...
    ATMega328P pin out (Arduino vs Physical Pins etc)
    camo.githubuse...
    Project Case (2 pieces)
    www.banggood.c...
    If you like this video please give it a thumbs up, share it and if you're not already subscribed please consider doing so and joining me on my Arduinite journey
    My channel and blog are here:
    ------------------------------------------------------------------
    / ralphbacon
    ralphbacon.blog
    ------------------------------------------------------------------

ความคิดเห็น • 124

  • @BaronVonBiffo
    @BaronVonBiffo 5 ปีที่แล้ว +2

    I love projects like this. Tips such as powering parts of the circuit from an I/O pin and setting pins to Input to minimise power consumption, are invaluable.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      It certainly made a huge difference (relatively speaking) to the overall current consumption, that's for sure. I thought I was inventing something new with powering the potential divider like this. Turns out it has been thought of many times before. Drat.

  • @borayurt66
    @borayurt66 5 ปีที่แล้ว +2

    Benny seems to be your silent partner. He gives you a lot of inspiration for new projects. :-) Nice one Ralph, as usual.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      Not that silent, actually, Bora, he has a voice! Especially when he sees me writing code he doesn't like, he's a hard task master. As he is a Burmese (which we didn't know when we adopted him) that means he is a mix between a Siamese and the Burmese Brown. Beautiful cat, very loving, not a mean streak in his entire body.

  • @TheEmbeddedHobbyist
    @TheEmbeddedHobbyist 5 ปีที่แล้ว +1

    you could put a door sensor, and only check for movement after it has closed. Then go into deep sleep until the next door close. then the movement sensor can be powered from I/o as well!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Yes, that's an option but remember I want this to be a self contained solution (so my neighbour can use it too) without any outside requirements. But it could be adapted for use any way you want, glad to see it got you thinking!

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 5 ปีที่แล้ว

      Hi, that's part of the fun Ralph. As I'm soon to have a lot of free time I've got to be thinking how I'm going to fill it.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You going to retire? You just _think_ that, but the truth is you'll just get a different boss (assuming you're married, which I shouldn't).

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 5 ปีที่แล้ว

      hi Ralph, you feel my pain. going from a 8hr a day boss to a 24hr one. got fed up with work, been going for 44 years now it time for some me time. got lots of things to repair and a few toys to play with.

  • @superdau
    @superdau 5 ปีที่แล้ว +2

    Thinking of those PIR sensors having a range can be a bit of a trap, because it doesn't work like that (similarily like you sometimes read about a "range" of a flashlight or laser pointer; that's just not how physics works).
    *It is about the angular size of an object* and also angular velocity of moving through the sensor's field of view. Something as small as a cat will most likely have to be much closer to get detected.
    *There is also another issue,* especially in enclosed spaces. If everything is the same temperature, which can happen in a small room there is nothing to "see". You might say that the cat is warmer than ambient, but its skin is insulated by fur (the whole point of it), so the cat's "surface" is close to ambient. I've observed that effect with an PIR sensor on my bike shed. When I get out of the house in winter (so the whole jacket is still warm on the outside), the sensor detects me from more than 5m away, but when I come back (the outside of the jacket now very close to ambient; again the whole point is insulating) I can get to less than 1m before it triggers. The same happens during warm summer nights, where it's dark but still around 25°C. The body or rather skin temperature is too close to ambient for me to be "seen" and I can again get to about 2m before it triggers.
    You should take a lokk at radar sensors, they'd get you around the second problem at least.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I've used a microwave sensor in a video (#78) and it worked OK, but in this instance Benny is only going to be at most 1m away from the sensor. I haven't tested that bit yet, I hope it works or else that PIR is going to have to be swapped out! Your empirical experiments are interesting but slightly concerning. Does that mean in winter we have less chance of detecting a burglar with our PIR operated lights because he (and his jacket) are cold (having cased the joint for the last 30 minutes) but in the summer he's warmer than ambient so would be detected as he scurried along the driveway to the house?

    • @superdau
      @superdau 5 ปีที่แล้ว +1

      @@RalphBacon
      Yes, that would fit with my observation (well, not the burglars; I've never seen them). Although I have to say that I pretty much always come home by bicylce even in winter, which means the cooling effect of moving air (and thereby getting my outside "layer", be it jacket or skin, to ambient) might be stronger than when just walking or standing.
      Physically PIR sensors are temperature change sensors, not motion sensors. The sensor essentially "integrates" all the thermal radiation coming from a certain direction (that's what the plastic dome is for; it's a lens for IR). Not (or too little) temperature change in their field of view, no detection. For a thing to be detected it has to be significantly warmer/colder than the background, or it has to take up more of the sensor's field of view.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Interesting points that I shall bear in mind. We shall see how (well) this work then in Real Life when I have constructed it.

  • @Tsnafu
    @Tsnafu 5 ปีที่แล้ว

    As an enthusiastic beginner, I found this very interesting. I built a little shed alarm recently and I think I can see ways to make improvements after watching this vid.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Glad it got you thinking about your own project, that's exactly the purpose of this channel. Thanks for posting.

  • @ShishakliAus
    @ShishakliAus 5 ปีที่แล้ว

    Love your vids Ralph. Only commenting to trigger youtubes engagement algorithm. A couple of your vids were the key to a retropie handheld build I did. I'm intending to do a "Ralph S Bacon" style video to go over the build I did. Basically only because those kind of videos are rare for retropie builds, and the ones that DO exist are hugely inspirational, so hopefully I can add to the gene pool.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      That's great that you're inspired to do a video, whether in my style or not (thanks for your kind words, most appreciated). If you do make one be sure to post a link to it here.

  • @johntoe6127
    @johntoe6127 5 ปีที่แล้ว

    Ralph, The larger PIR sensor often has a place where you can mount an LDR. It will restrict operation to night only. Then, try driving the piezo buzzer directly off of the output from the PIR. You may find this works, with no microcontroller required. Device would only consume the quiescent current of the PIR.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Hang on, John, so instead of consuming 16µA it would only consume 15.7µA? And where is the *Arduinite fun* in doing that, John! Noooo! OK, to be fair, what you say may well work but I'm pretending I did not read your suggesting at all!
      Now, although this is a project based on my Real Life requirements, I'm hoping it also inspires others to play about with Deep Sleep power saving plus a couple of other techniques. As it happens there's more that I have discovered since this video which I will share in a later video. To misquote Albert Einstein, I'm making this as simple as possible *using an AVR chip* but no simpler.
      Seriously, thanks for the heads up - I've looked at my larger PIR unit and there are three tiny solder pads marked MD, with L, blank and H in a vertical block. I don't know what MD stands for but maybe these are the connections? I know, I know, Google is my best friend!
      Thanks for posting.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      So I Googled and Big Clive has already done this: th-cam.com/video/2dxhbXHYEG0/w-d-xo.html
      the H/L pads apparently control the High Low pattern that occurs when triggered. My little PIR, for example, has to see no movement before going LOW again. When it does see movement it goes HIGH for 2 seconds, or thereabouts. By soldering the H/L it changes that to revert to LOW after seeing movement and going HIGH again if there is further (continuous) movement. Hmm, useful stuff, it's a shame they are so BIG!

  • @stevehubbard8459
    @stevehubbard8459 5 ปีที่แล้ว

    Done a similar deep-sleep ATmega328p thing for a temperature sensor using a DS18B20. It wakes itself up every 15mins and transmits the info via a 433MHz RF link to the MQTT broker attached to my home automation setup. I've had it running off 2x1.5V AA batteries since March, but I can only seem to get it down to 4.5uA when asleep. You're video has encouraged me to take another look at the consumption, and see if I can get it down further. Cheers!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      When you say 4.5µA, Steve, is that JUST the ATMega328P or does that include all the peripherals running 24x7, including the DS18B20 (which you could power in the same way I do, from an output pin of the Arduino chip). That all said. 4.5µA is pretty good (better than my 16µA including the PIR).
      How do you wake up every 15 minutes? WDT allows a max of 8 seconds, so you must be waking up, incrementing a counter and immediately going back to sleep? Or...?

    • @stevehubbard8459
      @stevehubbard8459 5 ปีที่แล้ว

      @@RalphBacon This is just the ATMega - I power the sensor and the RF transmitter from the chip (like you do). Typo in the sleep time - it's 5mins, not 15 - but I just use a loop that increments every second and applies "LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF)". Couldn't find a better way of doing it, even after trawling Nick Gammon's blog ;-) Sorry for the slow reply. I was just getting distracted by the Ashes cricket, and watching England get mauled (again).

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      The spec sheet says that in Deep Sleep (Power Down mode) but with the WDT running you can expect (with a VCC of 3V) 4.4µA typical, 8 µA max. So you are spot on. Now go and cry in your beer, I mean 67 all out, perhaps they all have a dinner planned for 6 o'clock and didn't want to be late?

    • @stevehubbard8459
      @stevehubbard8459 5 ปีที่แล้ว +1

      @@RalphBacon Thanks for that - I should learn to read spec sheets :-) Maybe I'll leave well alone, then. I'm well past crying over England (cricket, football, rugby, whatever). but a beer sounds like a good idea! Cheers!

  • @bipolarchemist
    @bipolarchemist 5 ปีที่แล้ว

    Another nice video. Keep 'em coming.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Will do, nice of you to post here, great to hear from you.

  • @wjn777
    @wjn777 3 ปีที่แล้ว

    Very interesting project, thanks for sharing

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Thank you! Cheers!

  • @gavinsmalley1513
    @gavinsmalley1513 5 ปีที่แล้ว +1

    Another great little project from the Arduino Master! This may be a silly question, but why use a ATMega328P when you're using so little IO? Would an ATTiny45 not be a better choice? Or is the sleep current of the little one too great?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Good question, Gavin. And to show I am not the Arduino Master, I initially did this with an ATTiny85 but the dratted thing did not want to play nice and there was really no way to debug it as we have no Serial output. (I could have bit-banged the output but, really?)
      So, as I had the space I decide a bare ATMega328P would have to do. This time. When I have more time I will have to see why that Tiny85 did not want to work.

    • @MarioRiesebeek
      @MarioRiesebeek 5 ปีที่แล้ว

      Ralph S Bacon with softserial you can debug an attiny.

    • @gavinsmalley1513
      @gavinsmalley1513 5 ปีที่แล้ว

      @@RalphBacon Indeed that would be an issue! For ATTiny projects I usually prototype on an Uno to get the code working and then switch over. Guess I've been lucky not to need debug after building the final circuit.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      I used SoftSerial last time, Mario, but I think I would have run out of pins, a bit fuzzy now after a Real Ale. But I shall revisit in due course. Thanks for the reminder!

  • @rafaelcabelo6616
    @rafaelcabelo6616 5 ปีที่แล้ว +1

    Your tutorials are amazing! Can you teach us Stm8s?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Glad you like the videos, Rafael. Regarding STM8s, I will add the suggestion to my list. You never know!

  • @uwezimmermann5427
    @uwezimmermann5427 5 ปีที่แล้ว +1

    if you put unused GPIO-pins as input make also sure to switch on their respective pull-upp resistors. Otherwise they will catch signals from the surroundings and toggle between 0 and 1 which consumes power.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Oh, I didn't do that, Uwe. Does the (weak) input resistor not consume current itself then, given that we have about 20 pins of which I'm actually using about 5 - so 15 pull-ups?

    • @uwezimmermann5427
      @uwezimmermann5427 5 ปีที่แล้ว +1

      @@RalphBacon no, it doesn't. SInce the pull-up only connects to the gates of the input transistors it would only draw current and hence consume power if the pin on the outside is connected to ground. Keeping the gates high makes sure that the input n-mos is turned fully on and the input p-mos is turned fully off. This avoids a situation where both transistors could be slightly conducting and thus drawing a crow-bar current from Vcc to GND. It also avoids continuous toggling between the 1 and 0 state, which also consumes power further in into the chip.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      I shall try that immediately then. Even if I don't notice any current consumption difference it seems that this is the (Best Practice) way to do it. Thanks for the technical heads up, Uwe.

    • @uwezimmermann5427
      @uwezimmermann5427 5 ปีที่แล้ว +1

      @@RalphBacon I have only tested in active state and there it makes a big difference. However, I read not in the datasheet that Atmel has included a feature to decouple the input pins in sleep mode, but the datasheet also states:
      14.2.6 Unconnected Pins. If some pins are unused, it is recommended to ensure that these pins have a defined level. Even though most of the digital inputs are disabled in the deep sleep modes as described above, floating inputs should be avoided to reduce current consumption in all other modes where the digital inputs are enabled (Reset, Active mode and Idle mode).

    • @uwezimmermann5427
      @uwezimmermann5427 5 ปีที่แล้ว

      i.imgur.com/EH9uTFh.jpg

  • @patazertyui
    @patazertyui 5 ปีที่แล้ว

    If you want to minimise the power consumption you could try to adjust your light detector in order it triggers on very low current. You could do that by maximising the potentiometer resistance to the higher possible level while the arduino analog input still can detect it. As the leaking current will be minimised I guess it could spare you a couple of uA... Just an idea.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You mean increase the value of the pot, to say 100K (or more)? I tried that and it was most twitchy. The 10K worked best even though I would have preferred a higher value. But powering it from the Arduino was a life saver!

  • @andymouse
    @andymouse 5 ปีที่แล้ว

    Very nice Ralph, a great intro to Arduino, and avoid a boiled Benny to boot!...Oh yeah, I think MiniCore is a great utility, I guess you're gonna give your thoughts on ya next vid...cant wait!...0.3uA (300 nA) is about where I'm at, but waiting for some parts for my Microcurrent Gold (Dave Jones project) I drew it into Kicad and made my own PCB mainly because my fluke is over 30 years old (I love it) and it hasn't got a uA range (fluke 79 series 2)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      The sad truth, Andy, is that I had it all videoed (including your comment, thus giving you instant fame, glory and wealth - OK I lied about most of that) but it all ended up on the cutting room floor as the video was 50 minutes long!!! But I shall use it all in the next video about this project, don't worry. Thanks so much for the heads up on this. It worked very well.
      And, of course, I used it in this project to get the Arduino to run at 8MHz using the internal clock without any faffing about whatsoever. I must read up more on the LTO, as although I enabled it I always it was always enabled anyway by default (so if you include a library that you don't use it would be optimised away).
      No µA on your Fluke? Unbelievable. But it is very old so maybe not so surprising. My bench meter (as show in this video) a UNI-T UT803 is great for things like this, even better than my new handheld Brymen BM257s.

    • @andymouse
      @andymouse 5 ปีที่แล้ว +1

      @@RalphBacon Yeah my fluke is over 30 (fluke 79 series 2) years old! but its been with me so long and all over the world I wanted to build the MicroCurrent for it, but will invest in a second meter anyway when money permits!..I too have a few things to read upon regarding the Minicore but like you, I love the no nonsense approach and I think it could be very useful to our fellow Arduinites as well, and no better person than you to give it a full evaluation... say hi to Benny!

  • @wires4auto
    @wires4auto 5 ปีที่แล้ว

    Love the videos you do when they relate to Benny! The laughter at your smd skills made me laugh😁
    Smart move with the ldr sensor power supply from a gpio 👍 I will be using that in future
    Could you not have built it using a AtTiny85? There cheap and use less power plus you taught me how to use them 😀
    Also if you made it count the number of triggers when dark. You could use it to say (cat must be in hear as I have had 5 triggers and no door open) thus turn on the buzzer and/or LED for longer. Plus I was thinking of you having the LED out side the cupboard.
    Thanks again for the great video!!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      I tried using the ATTiny85, Gordon, but the lack of built in serial (UART) and general lack of pins meant I had to abandon that for a bigger unit, which I had plenty of! I had fully intended to use the ATTiny85, maybe for my next 'tiny' project (see what I did there?)

    • @wires4auto
      @wires4auto 5 ปีที่แล้ว +1

      @@RalphBacon yes I see what you did ☺️ I would like to understand your thought process about the code you have written for the project. As this is a great project for beginners it's worth them knowing why you have done certain thing and why in that order. Thanks for listening

    • @mannhansen9337
      @mannhansen9337 5 ปีที่แล้ว

      Where can you find cheap Attiny85's ? $2-3 each is not cheap when you can buy Arduino Pro Mini with header pins for £1.44 each inclusive shipping to Norway.

  • @richardgrier4721
    @richardgrier4721 5 ปีที่แล้ว

    Apophis is my cat. He causes trouble -- and quite well understands what he has done. BTW, his linen closet habits are restricted to sleeping in the rag box. I'm fine with that.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      There's no room in my linen closet for anything, it's full of hot water tank and pipes (and Benny). Certainly not a rag box (whatever that is). I'll have to video it for the next part of this project so everyone understands how tiny it is! But I'm happy your Apophis is a cat and not an extinction level event for Earth! Good to hear from you Richard, thanks for posting.

    • @richardgrier4721
      @richardgrier4721 5 ปีที่แล้ว +1

      @@RalphBacon Yes, he was named for the Egyptian demi-god: the Destroyer (as was 99942). He has calmed down with age. But, as a young cat, he lived down to his name.

  • @oncledan282
    @oncledan282 5 ปีที่แล้ว

    Good evening, Ralph ! Great video, as usual. I see we have a frustrated viewer. Baah! 180 : 1 is not a bad ratio after all! Hahaha!
    I'm sure you'll be able to fit everything in half the space of that case's back panel. There's nothing roomy on this PCB and all components are quite simple. Just a walk on the park for a person with your experience. I would be tempted to mount the PCB on the back of the battery pack .. or at the bottom of the case, if you plan on using some spacers to fix the pack.
    Can you please show us the finished product ? I'm sure I'm not the only one curious about this. As for the Sleep Mode, and waking up every 15 minutes, I just might adapt this to my Wireless Weather Station. I might save on battery charging current and be able to use solar panels after all. I'll have to strip the board of unncecssary components like the OLED display. RTC is needed, though. We'll see about Version 2.0 later the month.
    Until then, have a great day!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      I want this to be easy to assemble for beginners, so as well a through hole components I'll space things out a bit (as I have the room). Mounting the PCB on the back of the battery pack could be done but then it all just floats about in the case, doesn't it? We'll see. Sometimes (as you well know, Daniel, with your weather-station) things only become clear when you actually try and do them!
      I'll deffo show people the finished product. But first I must design the PCB, I'd better get cracking!

  • @sortofsmarter
    @sortofsmarter 5 ปีที่แล้ว

    Hello Ralph, great video. My cat Zorro does the same thing in out linen closet all the time to my wife. It has bi-fold doors and he will be asleep for hours before he starts his, let out his I'm dying howl...somebody let me out now...lol.. I think its great you stuck to the through hole design of your own. even though its not smd. It doesn't always need to be modern and sleek. but I think bodging together 2 boards or robing parts I feel would not have been as clean of a project and not your style. Sometimes even I have to resort back to old through hole lol..seems like we cant get totally away from it...I look forward to building this for my cat/wife...

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      So it's definitely a cat thing! I'm submitting my (through hole) PCB tomorrow so if you are quick on the draw in about two weeks (when I do the next part of this video) you might be able to catch a freebie, Gene, just sayin'.

    • @nurgle11
      @nurgle11 5 ปีที่แล้ว

      Put a cat door on the linen closet is another alternative ;)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Great, Andrew, I'll just run that past the boss: Big cat flap on the airing cupboard door, love, how about-------- argghghh! I guess not then.

  • @colepdx187
    @colepdx187 5 ปีที่แล้ว +1

    I'm working on a battery powered sensing device as well. I'm wondering about monitoring the battery level. Will you have some way of indicating low battery condition? Can the micro-controller accurately read it's own battery level given the reference (AREF?) for the analog input is taken from the same batteries?
    I never imagined that I would be contemplating designing a PCB layout but with your helpful vids I think I'm going to give it a go. I'm just in the process of moving the circuit off of the solderless layout onto a strip-board. Then on to a custom PCB. wow.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +2

      Yes, you can check the battery by using the internal fixed 1V reference for AREF of 1.1V and powering it from a resistor divider to that level. So a full battery reads 1023, dropping at it depletes. I also thought of that but had no time to implement. Maybe now I might look at it before my PCB is completed.
      See: code.google.com/archive/p/tinkerit/wikis/SecretVoltmeter.wiki
      Talking of which it's great that you're thinking about doing that. Look at my rubbish, first PCB results but now my PCBs are OK and I even did that 4-layer one! Strip board is so last century!
      Great to hear from you Dirk, good luck with that PCB.

    • @TheEmbeddedHobbyist
      @TheEmbeddedHobbyist 5 ปีที่แล้ว +2

      As Ralph stated, you need a reference lower than the battery voltage you want to stop at to keep the reading actuate, also a good idea is to switch the supply voltage divider with a fet etc from a I/o pin so that you are not draining current through it all the time. just make it active then measure the voltage then disable it.

    • @andymouse
      @andymouse 5 ปีที่แล้ว +1

      @@RalphBacon Strip board is so last century!...Hhahahahha!

  • @jeff3741
    @jeff3741 5 ปีที่แล้ว

    Once you learn the best potentiometer value would it make sense to replace it with a fixed resistor?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Every (lighting) situation is going to be different though, so I wanted it to be adjustable. The final project might not have the pot as external, I might just have a small hole for a screwdriver to poke through, I'm still designing that bit!

  • @andrewtoogood1429
    @andrewtoogood1429 5 ปีที่แล้ว

    Awesome Ralph, Can see how I would use this for all sorts. You mentioned at the beginning you got less in deep sleep than the previous bare bones series. What did you have different? was it a lack of LDO?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I don't use an LDO in either sketch, Andrew. I thought it might have been because I did not set all GPIO pins to INPUT but that wasn't it either, maybe 1-2µA difference. I'm not sure at this stage. Perhaps my meter was playing up. But I do know it's good now! I really ought to test this _in-situ_ before committing to a PCB...

  • @OsoPolarClone
    @OsoPolarClone 5 ปีที่แล้ว

    Great video as always Ralph. Is there any way to add to the code for the beeper to beep a special sequence to say the batteries are getting low and it’s time to change them?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      This is an option, certainly, Bruce, and others have suggested it too. I'll use the internal 1.1V reference for AREF and voltage divide the 4.5V down to that (or just under) so I can read the voltage from another analog pin. I can drive the potential divider from another GPIO pin too, thus only using power when I read it. I can then beep a quicker beep pattern in a lighted condition (eg door opened) to alert me that the batteries are getting low (eg below 3.3V). Keep tuned!

  • @timdurham9091
    @timdurham9091 5 ปีที่แล้ว +1

    Do you have a link for the case?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes! I do now! It's in this video description and the GitHub and also here:
      Plastic case used in this project
      www.banggood.com/2pcs-75-x-54-x-27mm-DIY-Plastic-Project-Housing-Electronic-Junction-Case-Power-Supply-Box-p-1063302.html?p=FQ040729393382015118&
      These can be delivered from the UK or CN, as is your wont.
      Thanks for the reminder, Tim.

  • @mahlapropyzm9180
    @mahlapropyzm9180 5 ปีที่แล้ว +1

    Millions of years of evolution, thousands of years of technological development and still defeated by a cat!
    The future doesn't look too bright for AI...

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      AI will be brighter than me, though, Mahla, and quicker to spot Benny running in there in the first place. Give it 100 years and we will all be replaced by intelligent electronics, you'll see. But not the cat, obviously.

    • @mahlapropyzm9180
      @mahlapropyzm9180 5 ปีที่แล้ว +1

      @@RalphBacon I don't think it is a matter of intelligence, or lack thereof but rather a willingness to comply, or lack thereof (in Benny's case).

  • @Graham1904
    @Graham1904 5 ปีที่แล้ว +1

    What's wrong with buying 10? There are other projects you can use them for!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      You an never have too many components, that's for sure, including project boxes, Graham.

  • @newburypi
    @newburypi 5 ปีที่แล้ว

    Great video. Two thoughts: 1. Attiny85 could do it in a smaller package. 2. How about feeding VCC (via resistive divider) to the controller to monitor battery level, and you could have a "distinctive beep" when the PIR is triggered in the presence of light (you're putting towels away). This would give you a low battery alert.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Two replies then, Dale.
      1. I tried (and failed) with the ATTiny85 as I was winging it with the LDR/pot combo but there was no way to see what I was doing with a Serial monitor. And demoing that would have been difficult. Pity. But it's not a disaster.
      2. Monitoring the battery is a distinct possibility if I use the fixed internal 1.1V reference. Yes, you're the second person to mention that, I shall experiment tomorrow (I find after a beer my eyes' focus is even worse than usual).

    • @newburypi
      @newburypi 5 ปีที่แล้ว +1

      @@RalphBacon Good point on #1. Maybe I'll look into the Digispark to see if it would provide better debug capabilities. Many thanks for the response, by the by.

  • @flemmingchristiansen2462
    @flemmingchristiansen2462 5 ปีที่แล้ว +2

    Great project, what's that finger at 27:00? - lol

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Ha ha! that's was my alternative pointing finger! Trust you to notice, Flemming!

  • @adaml52
    @adaml52 5 ปีที่แล้ว

    Good video Ralph,
    Will the PIR detector actually pick up Benny the cat ?
    The ambeint temperature of the airing cupboard may mask Benny.
    ATB Adam

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Hmm, I must admit to not having thought about that aspect. I'm now hoping it is movement that will trigger it regardless of the ambient temperature. We shall find out! Good point to raise there, Adam, thanks for posting.

  • @MrBobWareham
    @MrBobWareham 5 ปีที่แล้ว

    Hi Ralph nice project, yes you have to look after the cat so how about instead of IR you use RCWL-0516 = 3ma Radar board all the best Bob

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      A couple of you have suggested this, Bob, and I did a video on it too. But I did find the µWave detector could detect stuff through walls unless carefully shielded which would make it a bit tricky to use (it would pick up people on the other side of the closed door, for example). Let's hope the PIR works, we shall find out...

  • @javierpallalorden
    @javierpallalorden 5 ปีที่แล้ว

    Would be nice to have your PCB! Thanks for the excellent video.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      I'm right in the middle of designing it using KiCad, which is most unfriendly when it comes to schematic design. I thought I had comes to terms with the foibles of KiCAD but only the PCB side it seems. I'll report back in due course, Javier.

    • @henrikjensen3278
      @henrikjensen3278 5 ปีที่แล้ว

      I have done a couple of schematics in KiCad now and the schematic software is fairly easy to use (I used Eagle before). Of course doing schematic also includes designing your own components (without 3D model). I do dislike selecting a body/physical part for all my components, but the trick is to select it first time you use a part and the just copy that part (Copy is very easy and fast in KiCad).

    • @andymouse
      @andymouse 5 ปีที่แล้ว

      @@RalphBacon Oh, I find the schematic side ok if you remember the "special" power signs to stop it moaning about such and such pin not powered, and treat any symbols as "boxes with pins"...but the library system still hates me!

  • @danp762
    @danp762 5 ปีที่แล้ว +1

    I've ordered from PCPWay twice. Both times it was 15 pieces, 2 sided, 2 oz copper, and 5 x 2.5 inch. $77 shipped to the Midwest, USA. First time, it took 3 days to make and got to me in 8 days. Second time, it was shipped in about 25 hours. DHL said it will be here Monday. That would be 5 days to get to me, from the time I ordered until a knock at the door.
    Seems pretty good? But, I didn't really shop around. I know there is a lot of variables. But, I think the solder mask color makes a difference in production time? First order was white and the second green.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Yes, Dan, green means they can complete the board in 24 hours; for any other colour it adds _at least_ 1 day to the production time, I don't know why, perhaps they batch them up. Pretty good delivery times there, what would we do without such PCB fabrication houses? Thanks for posting.

    • @danp762
      @danp762 5 ปีที่แล้ว +1

      @@RalphBacon You earned the money from your sponsor for sure. Pay the bills.

  • @paulowen9628
    @paulowen9628 5 ปีที่แล้ว

    Like your videos, Ralph. Where do you get your project cases from?
    Regards, PaulO

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I've put a link in the video description and my GitHub mow, Paul, I omitted to do so originally, apologies.

    • @paulowen9628
      @paulowen9628 5 ปีที่แล้ว +1

      Thanks, Ralph

  • @borayurt66
    @borayurt66 5 ปีที่แล้ว

    I may have missed this, but do you have a video that explains how to do the fuse settings for using the internal oscillator? I believe the "regular" bootloader in Uno's and Nano's set the fuses for external 16 Mhz crystal only. You should be using some other bootloader or some other means of ISP other than USB-Serial conversion. Most of us over here are still using the good old Arduino IDE (well, at least I am, but I like to refer to myself as "most of us") and unless some other barebone Atmega328 settings are loaded into the IDE as board definitions, all it knows is the regular "Arduino / Genuino UNO" or Nano settings, both using external 16 Mhz oscillators.
    Edit: I just watched the ending... Sorry for the impatient commenting :-)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      I'll be reiterating how to make the Arduino chip (and the LGT 'clone') run at different speeds in a near future video, Bora. It's easy enough to do, especially with a cheap bit of hardware to stop the spaghetti of Dupont wires! But only easy once you know of course, like all things in life. Stay tuned!

    • @DavidUnderhill
      @DavidUnderhill 5 ปีที่แล้ว +1

      use the AVRDUDESS program with any of the supported ICSP Programmers, it has a bit selector section to change any of fuse bits including the OSC ones. Installing alternative 328P support board defs is easy also.

  • @WatchesTrainsAndRockets
    @WatchesTrainsAndRockets 4 ปีที่แล้ว

    Would it make sense to add external logic such that the ATMega is not awakened unless the light sensor is sensing no light and the PIR is triggered? Basically,
    +--------------------+----------------------------+----------------------------------------+
    | In the dark? | Sensing Motion? | Wake UP microcontroller |
    +--------------------+-----------------------------+----------------------------------------+
    | N | N | N |
    +--------------------+-----------------------------+----------------------------------------+
    | N | Y | N |
    +--------------------+-----------------------------+----------------------------------------+
    | Y | N | N |
    +--------------------+-----------------------------+----------------------------------------+
    | N | Y | Y |
    +--------------------+-----------------------------+----------------------------------------+

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      This is a Catch-22 problem, Michael.
      Assume the µC us asleep. Where is the logic coming from for "In the dark"? The µC has to wake up to work that out. Or we build that bit in hardware (typical light/dark Schmitt trigger) that then lets the PIR power up - but that takes up to 1 minute to stabilise. So maybe we then power up the entire unit only when dark? I wonder what the standby current would be for that bit?
      So whilst your logic is flawless, getting that to actually work in the Real World stumps me. Perhaps you have an idea on how we might achieve this? It's great this got you (and now me) thinking about this though, thanks for posting.

  • @henrikjensen3278
    @henrikjensen3278 5 ปีที่แล้ว

    I am a bit suspicious about your current measurement, it looks like you have the serial interface connected at the same time.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Suspicious in what way, Henrik? The Serial interface is connected but data and ground lines only (I've knobbled a USB cable specifically for this purpose, stops the COM port from the FTDI unit disappearing). I can confirm that it is 0.3µA when in Deep Sleep (and nothing connected except my multimeter), as per the Data Sheet spec, which says 0.2µA min and 2µA max.

    • @henrikjensen3278
      @henrikjensen3278 5 ปีที่แล้ว

      There are a couple of possible errors:
      1) Input may load the output.
      2) High voltage may supply the circuit through the protection diodes (This can go both ways) and when we are down in a few uA the forward voltage of protection diodes are fairly low.
      3) Signals that are between GND and VCC will increase the current draw.
      It may be that none of it happened in your case.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Thanks for planting the seed of doubt, Henrik! This means I shall have to recheck my readings tomorrow, even though I am certain I did all this (more than) once. Sigh. I can't get anything past you guys.

    • @henrikjensen3278
      @henrikjensen3278 5 ปีที่แล้ว

      I love helping ;)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I couldn't wait, so through my beer-induced fuzziness I just repeated the testing with and without the Serial device. Today, the meter reports that without the FTDI attached, in Deep Sleep the Arduino uses just 0.1µA which I will assume is my meter being a little optimistic. It rises to 16.1µA with the PIR attached, rising again to 200µA when the PIR is active (but not beeping/flashing). I've changed the design a bit (details in another video) for the interrupt.
      When I attach the Serial converter, current drops to 15.9µA when sleeping with the PIR attached. When detached it consumes MINUS 0.1µA so the TX/RX lines must be supplying 1-2µA current to something. I've not set those pins as INPUT as I didn't know whether it would upset the data flow - perhaps I need to do that.
      But all this notwithstanding, I can confirm a Deep Sleep standby current for the ATMega328P in the order of the 0.3µA I reported on. Today. It might be different tomorrow.
      Happy?

  • @GnuReligion
    @GnuReligion 5 ปีที่แล้ว

    The "Scat Cat" project.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      I like it, Steven, I might use that name for my Part 2 of this project! I'll claim it as my idea, of course. Nope, too late now, you can't have it back.

    • @GnuReligion
      @GnuReligion 5 ปีที่แล้ว

      @@RalphBacon Oh, I am *full* of ... ideas. (Puts hamburger down.) You could use a passive buzzer and digitize something horribly terrifying to a cat, like a bark or hiss for playback. Even vary the tone and intensity. Gadget Reboot recently posted this, playing with a tone library: th-cam.com/video/9OtRh3_pn68/w-d-xo.html -- actually, I'll write this for you if you have a passive buzzer, or small squeaker.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Truth be told I was going to use a piezo buzzer and use the Arduino 'tone' commands but I just ran out of time. And they are not very loud unless mounted (glued flat) on a backplate (the case) then they can be quite piercing. But that synth library looked interesting and it's not that I'm short of pins or anything...