Ok, you got me. I am considering a Pi. A very enticing video, Ralph. Thank you.
@RalphBacon6 жыл бұрын
Shhh! Don't tell anyone else. Benny knows but he can't speak except in cat++. The Pi makes you think in very different ways to an Arduino. Definitely worth experimenting. Good to hear from you, Michael.
@boblewis55585 жыл бұрын
Great vid as usual Ralph. Total sympathy with your shorting pins problem ... been there done that, got the badge, tee shirt and signed certificate!! However, if needing to do a lot of pin connecting with unshrouded probe ends, there is a quite simple trick that can be used: A piece of (ideally) silicone rubber sleeving over the end of the probe. PVC or heatshrink can also work but is a little less flexible (no pun) since the idea is to overlap the end of the probe by a couple of mm but also be able to slide the sleeving back to expose the very tip if needed. With the overlap present, header pins to be probed can fit inside the sleeving and make contact. Pulling back the sleeving to reveal the very tip of the probe means a bit of extra protection when probing around a board or chip pins. One other thing that can be done is to pull back the sleeving enough to provide a lip against which the tested pin can rest while the probe is contacting it. You know how tricky it can be keeping firm contact in a tight space whilst trying to read a meter etc. The same tip works on the end of scope probes and if you lose the sleeving, well no real issue, cut another piece. But those tiny fiddly scope probe ends are a nightmare to keep safe. There are probe shrouds around similar to scope probe ends but they all suffer the same problems ... they slip on and off easily OK, but as a consequence and just like scope probe tip shrouds, get lost far too easily also. They also add bulk to the probe tip that makes it more difficult to get into tight spaces. The sleeving adds little bulk but lots of protection. One other tip is to use cable piercing probe ends (the long needle type ends) with even finer sleeving on them - ideal for probing modern fine pitch connections, boards and chips. Try it and hopefully never inadvertently short two adjacent pins again. Let.me know what you think. Remember: old age and skullduggery beats youth and vigour any day of the week! 😂😂
@RalphBacon5 жыл бұрын
Thanks for the sympathy Bob, it still hurts when I think about it! Great idea about the heat shrink, I must try that on my long pointy probes. You may see the results in a future video. I'll pretend it was my idea and take all the credit!!! (Just kidding). Thanks for the suggestion.
@jeaimehp3 жыл бұрын
I felt your pain when you let the magic smoke out shorting the 3.3v to the 5v pins. You instantly gained a subscriber and my condolences on your loss 🤓
@RalphBacon3 жыл бұрын
It wasn't user error it was bad design! Well, that's my story... Thanks for the sub 👍
@arsebiscuitsandwine6 жыл бұрын
This is a really nice implementation. I thought of something similar using an esp8266 to issue remote power commands (reset, but also hard power via relays) but this seems way more efficient.
@RalphBacon6 жыл бұрын
Well now, funny you should mention the ESP8266, because if you were to use that then you could send email / Node-Red messages etc, etc that things were not well in the Raspberry Pi camp, as well as rebooting it. And given that the ESP8266 is a 3.3v device there would be no need for the diode either. I'm glad you're thinking along these lines, as lots of thoughts like this occurred to me as I was implementing my solution (which for demo purposes was fine but in the Real World a more sophisticated solution _might_ be required).
@DafyddRoche6 жыл бұрын
Ralf, another well thought through video. You might want to look at the Greenpak devices from Dialog Semiconductor. (I do work for them, but not in that group). It's a "mini" FPGA that could be used to monitor the battery supply and toggle the PEN pin. They are simple one-time-programmable - one programmed, it behaves like a hard gated device.
@RalphBacon6 жыл бұрын
I'll have a look, Dafydd, but remember we're monitoring the battery pack voltage so that we can shut down cleanly (ish) when it gets a bit low. So Linux will issue the shutdown command, and once down should ideally bring the PEN pin low to conserve what remaining power is there. Once power is restored we should release the PEN and the Pi will reboot. BUT - if the Pi is not running how does the PEN get brought high again? Or kept low? Hence the ATTiny85 for additional logic. We shall see. Thanks for the nudge, I'll have a look at the Greenpak devices right now!
@DafyddRoche6 жыл бұрын
Cheers Ralph. All makes sense. I hope I wasn't coming accross too "sales-ish". They are cool products, with an awesome GUI. Worth a play, even if you only want to buy 5! ;)
@RalphBacon6 жыл бұрын
If you ever think of changing career to a second-hand car salesman, don't bother, that was nowhere near hard sales enough! But I had a look at the Greenpak devices (in fact I'm still reading), all very interesting. Everything these days needs to be configurable and programmable. Quite amazing. But a minimum order quantity of 100 (even at 50c a piece) is not quite what I had in mind. Perhaps these are available on eBay in (much) smaller quantities. I shall look there too!
@stompreaper6 жыл бұрын
Are you planning on implementing lock-up detection to auto-reboot as well? i.e. have the ATTiny85 behave more like a watchdog timer using gpio 21 to feed it and use cron or some similar systemctl service to toggle the pin every 10 seconds or so?
@RalphBacon6 жыл бұрын
Well, funnily enough, it did occur to me, Stephen. On mainframes (and probably smaller ones too) there is often a "Heartbeat" detection, and on web-style microservices a "Health Monitor", which we could easily detect in a similar manner, although we would have to check that the value does actually go high then low and then high again (or something more sophisticated), _ad infinitum_ but I'd need a bit of code to produce the true CPU lock up on the Pi for testing. Any ideas?
@stompreaper6 жыл бұрын
Ralph S Bacon Two thoughts occur 1) a small bit of C code to allocate up most/all available memory and force the system to bog down, 2) fill up the hard drive as Linux systems tend to fall over when you run out of disk space and /var/* becomes unusable
@RalphBacon6 жыл бұрын
I shall try this at my earliest opportunity, Stephen, in the next few days. Thanks very much for the suggestions.
@Mr.Leeroy6 жыл бұрын
There are at least two versions of Micronucleus bootloader for Digispark boards that make use of USB for self-programming and for HID emulation. The difference between this versions is 5 sec boot delay that allows the board to be reprogrammed before starting the sketch. One of those versions comes w/o this delay, so you have to pull one of the pins low (usually PB0) before plugging it in USB port and releasing the pulldown to start programming process. If you do not have Micronucleus bootloader yet, you won't be able to use USB port.
@RalphBacon6 жыл бұрын
Got it loaded this evening, Leeroy using my Arduino as ISP and very quick to do it. Now I can program (upload sketches) via the USB port on the board. I didn't notice any delay but I was so excited at getting it working I wasn't paying that much attention! Details on my blog ralphbacon.blog
@Hasitier6 жыл бұрын
You can use those digispark modules with built in usb to work as a HID, so you could simulate a keyboard or a mouse. But this just works with the digispark bootloader on the Attiny, so using a bare one would not work for this out of the box. Brian Lough made a twitch livestream a few days ago about that topic.
@Hasitier6 жыл бұрын
Also reading the battery voltage or capacity might be useful to prevent the sudden power loss at all and instead shutdown the pi by regular shutdown command. Your sd Card would not be the first dying while loosing power during a write on it.
@RalphBacon6 жыл бұрын
I hope to read the voltage on the battery pack either via I2C on the Pi or directly using the ATTiny85. We shall see. I don't run my Pi from an SD card, I have a tiny USB stick which may be more resilient, I don't know?
@gavinsmalley15136 жыл бұрын
The ATTiny85 has no hardware UART so there are no TX/RX pins to connect to. The USB can be used for many purposes though, not least as a keyboard/mouse/joystick emulator. I believe there is a "bit-banged" software serial available over it too. You can install the Digispark boards to the Arduino IDE using the extra boards URL field in the preferences (in the same way as the ESP8266) and then you have all the examples showing the uses of the USB port. I've never had to install drivers to use them - they've always plugged and played for me, but may be different in Windows. That said, Brian Lough did a stream last Monday in which he used one in Windows 10 with no drivers so maybe they're not needed anymore there either? The Digispark boards have a specific boot loader which makes them behave differently to a plain ATTiny85 - uploading is only available at power on not at all times. In normal running the USB port behaves as whatever kind of device it has been told to emulate (or does nothing if no emulation library is active in the sketch). Programming is a bit different to most other boards. In the tools menu in the Arduino IDE when you choose the board set the "Programmer" to "Micronucleus" (instead of AVRISP) and leave your board unplugged. Don't choose a COM port. Press the upload button in the IDE and when compiling is complete you can attach the board when it says to do so in the console log at the foot of the IDE screen. I've used quite a few of these for quite a few projects and never had a problem - just have to get used to the fact that they're a specific board type of their own and not just a plain ATTiny.
@RalphBacon6 жыл бұрын
Thanks for the update, Gavin. The bad news (for me) is that I did all this (and way back in video #66) and it all worked like a dream. For a while. It could be that the ATTiny85 devices I'm trying to use do not have the correct bootloader (or any) on them. Hmm, didn't think of that, I just assumed and you know what that means! I might just give this one last chance. Start from scratch. (Re-)load the bootloader first. Then reinstall the drivers (again). If it doesn't work then I'm giving up. Try and try again then give up - no use being a damn fool about it, as WC Fields said! Nice to hear from you Gavin, thanks for posting.
@RalphBacon6 жыл бұрын
If you read my latest (as we speak) blog entry you will see that your and others' nudge helped me finally get this working. Thanks! ralphbacon.blog
@electron-19795 жыл бұрын
You can put a jumper over the 5V pins.
@RalphBacon5 жыл бұрын
A jumper between pin 2 and 4 (both 5V)? Good idea, I think I will do that to protect myself from my own stupidity!
@IanSlothieRolfe6 жыл бұрын
An lternative to using your diode to make a pull-down is to configure the ATTiny pin as an input, when you want to pull it down digitalWite it to LOW and switch it to being a output. When you want to let it pull itself high, just set the pinmode back to input.
@RalphBacon6 жыл бұрын
That could indeed be a good idea, Ian. Just one tiny (very tiny) query: is a pin configured as an input not going to present 5v on it anyway (albeit at a super low current)? I realise I should know the answer (or just try it out) but I've just got home from a _very_ long work day so I'm hoping you (or someone else) will know the definitive answer! [/End Cop Out ]
@IanSlothieRolfe6 жыл бұрын
On a ATMEGA if Pinmode in INPUT then the input floats and presents a load to the connected device of man megaohms, if Pinmode in INPUT_PULLUP it will have a 20K-50K pullup to Vcc. I would imagine the ATTiny is the same. If you look at the datasheet the pullups on inputs are controlled by the state of the output register for the input pin but Arduino hides this in the implementation of the pinmode function, which probably improves the compatibility with other microcontrollers.
@RalphBacon6 жыл бұрын
Thanks for this, Ian. I'm going to have to just try this out, aren't I? Well, first double check the floating input pin voltage on my scope etc but it seems worth doing. Of course, the single diode does remove all risk, so both approaches are feasible. Thanks for answering my query.
@Ed196016 жыл бұрын
Interesting stuff. May do that. Yes being dependent on outside service will sometimes leave you stranded. Sorry abt yr pi. I didn't have much trouble with the digistump, but I recall you had to replug it at a certain moment to be recognized
@RalphBacon6 жыл бұрын
Yes, you had to plug in the device when the compiler prompted you to, but I couldn't get that to work ("The last USB item you plugged in was not recognised") so I've given up. The Internet is full of such (and similar) reports. So much easier to program it using a Raspberry Pi! Thank you for your commiseration regarding my Pi. It still brings back painful thoughts. 😔
@Roamor16 жыл бұрын
Thanks, great video once again. Also thanks for the soothing birds in the background. :-)
@RalphBacon6 жыл бұрын
Ah yes, those birds. Again. I never notice them (the machine version of them) whilst recording because they are ever present. Very soothing, as you say. Thanks for posting, Niels.
@daveholden39356 жыл бұрын
Apologies if this is covered elsewhere or you've indicated this as a future plan , if the power fails (also on earlier Pi modules) when writing to the card , there is a risk of corrupting the uSD card (impossible to re-format etc). - been there, done it (two cards) £16 poorer - so in my opinion, monitoring the the 5V supply , and for the sake of the LiPo, its voltage should also be measured and the Pi gracefully shutdown. Like the green-screen physical presentation !
@RalphBacon6 жыл бұрын
Absolutely, Dave, the SD card can become corrupted if it's being written to as the power dies. I did briefly mention that we might want to monitor the battery voltage using one of the analog pins on the ATTiny85 but perhaps the Pi should monitor it instead and shut itself down at the appropriate voltage. Apropos the SD card corruption, is there not some wiz utility to recover from such failure? I mean, what do the manufacturers do? Glad you like the (not quite perfect) green screen presentation, got to move with the times, hey?
@daveholden39356 жыл бұрын
If you are lucky a corrupted uSD can simply be formatted - but as I experienced with the Pi (and also during my working life) a uSD card can have its Boot record/index ? system totally 're-arranged'. It is then totally unrecoverable, dead, deceased, no more etc. My view now is that it might be better to monitor the battery and shut the Pi down when a threshold is reached (say, 3.5V), rather than run the risk of the 5V rail 'going over the cliff' - when it will be too late. More room for manoeuvre, especially if you know the performance of the UPS HAT. As the Pi's GPIO pins are digital, additional hardware would be needed - so perhaps using the ATTiny/UNO would be a more appropriate way forward..
@daveholden39356 жыл бұрын
Have just spotted that the HAT may have I2C battery status indication capability so my thoughts about using the ATTiny may not be relevant. I await your HAT video with great interest. Cheers Dave
@JohannSwart_JWS6 жыл бұрын
Just stumbled across your videos. Yep, like them - useful and interesting. If I may, waffling on until 50% of the video before getting on with it, not so great. Maybe its not the same on the others. We'll see. I know you're putting a lot of time and work into them - all the more reason to get it right. All the best. PS: I did subscribe...
@RalphBacon6 жыл бұрын
Thanks for, Johann, your constructive comments, your post and, of course, the sub, all received equally well. I am continually endeavouring to reduce the time of my videos (which would make we waffle less and do more). Imagine there still being a 15-minute restriction on KZbin, what would I do then? Perhaps I should pretend there is that limit and see what happens...
@backyardelmer94416 жыл бұрын
Useful and informative! Thank you. Your foreshadowing sounds like it will address the one question I had, so I'll mention something related to your power series in general. The amazon dash button saves power by being completely off. The button connects power, gpio latches it, and then releases it. Not as general a solution as the ones you've done, but useful enough for a video?
@RalphBacon6 жыл бұрын
I've certainly used a self-latching relay before; maybe there is scope to latch-up using GPIO pins too, in the manner you suggest. The issue all solutions face is that they must not attempt to reboot unless the voltage is at least 5.0 volts - otherwise, it just gets to a point where it keeps rebooting (I mention this in the video but we didn't test for this). I'll take this on-board along with other suggestion in the next part of this video. Thanks for posting.
@ste765395 жыл бұрын
You know in terminal you can autocomplete by starting to type the command/file/directory/whatever and then pressing tab? Provided whatever you're command is, is unique for that location of course in the case of filenames and directories.
@RalphBacon5 жыл бұрын
Ah yes, good reminder. Just like Windows then.
@ste765395 жыл бұрын
Well not quite, Linux is better!
@stb686 жыл бұрын
Could you have turned an NPN transistor on/off from the ATTiny to switch PEN to ground? Or would the higher voltage on the base compared to the collector mean that wouldn't work? In which case would a PNP work?
@RalphBacon6 жыл бұрын
So the Arduino turns an NPN transistor on (via a suitable base resistor), and the transistor's collector then grounds the PEN? I would expect it to work (without trying it) but effectively that is what the Arduino is doing anyway. If you're going to add a transistor you might as well add the diode instead (which has been proven to work). Do you think there is an advantage to using a transistor? Let me know! An interesting question, for sure, thanks for posting.
@stb686 жыл бұрын
I don't think that the transistor is a better solution, I was just wondering if the idea I'd had would have worked, albeit not as gracefully.I've been thinking about something vaguely similar (based on super caps, like Andreas Spiess) to let me power down the pi gracefully but, if the mains came back on before the pi has fully lost power then it wouldn't restart without some similar intervention.
@ChrisDuckles6 жыл бұрын
Why not run the ATtiny85 at 3.3v for extra safety re the Pi's 3.3v gpio,s? Also a software serial is another debugging solution. Regard and thanks for your interesting videos.
@RalphBacon6 жыл бұрын
Both excellent points you make here, Chris. I wish I could make videos an hour long to cover all aspects! Thanks for posting, appreciated.
@tabmaryland23336 жыл бұрын
Sorry for your loss. Perhaps Benny can bat the late-pi around the workshop floor.
@RalphBacon6 жыл бұрын
Thank you. I am still feeling the loss. Of £35 anyway. Benny is not interested in dead things, only ones that are alive. And my Pi is most definitely not. 😔
@nabarnes6 жыл бұрын
I've been looking for a solution similar to this for a while.... I want to put a Pi in our caravan to act as an MQTT node so I can monitor battery voltages and temperatures within the 'van, but also let me control heating etc. back at home. I need a UPS that will power the Pi long enough to do a clean shutdown when the caravan power disconnects (i.e. when we're towing it) and then powers it back up when we have 12v back. Is there a simple solution, or do I have to buy an expensive and complicated UPS HAT?
@RalphBacon6 жыл бұрын
The UPS (LiPo thingy) from video #120 would even do what you want, Nicholas, but I'd suggest holding out for the video that will look at that Geekworm Power Pack I'm hoping to get from Banggood. Just FYI, monitoring when the power is removed is easy; it's just a digital input. Monitoring when the battery pack is going to die is more difficult but certainly not impossible; we can interrogate the supporting chip(s) via I2C, monitor the LiPo battery voltage (which dips as the battery is about to die) or just time it (2 hours and we'll call it enough and shut down). Stay tuned, could be an interesting video!
@javierpallalorden6 жыл бұрын
Excellent video, you could make your own UPS for the Raspberry PI with a nice small DIY board ($5) you can buy on Aliexpress, search for DD04CVSB_5V. Installing the digistump drivers for the ATTiny85 is not really hard to do and then you can just program it via the USB port.
@grindel806 жыл бұрын
This Board Has 12v output?!
@javierpallalorden6 жыл бұрын
Hi Frank, yes and it is also available in 5V output
@grindel806 жыл бұрын
@@javierpallalorden is it some kind of combination between a tp4056 and a Boost Converter? (it seems it Has no overvoltage protection?)
@javierpallalorden6 жыл бұрын
Frank, no undervoltage protection, it drains your battery if you do not use a protection circuit.
@grindel806 жыл бұрын
@@javierpallalorden, so its a cheaper and safer solution to go with tp4056 and Boost Converter?
@jimb0326 жыл бұрын
Programming the attiny through the usb- it has to have a special bootloader and it can work.
@RalphBacon6 жыл бұрын
Ah yes, I've just replied to Gavin's post and I'm thinking it could well be the bootloader that I assumed was loaded and might not be. I'll give it a try, so thanks for the confirmation, James.
@RalphBacon6 жыл бұрын
As per my reply to Gavin, if you read my latest (as we speak) blog entry you will see that your and others' nudge helped me finally get this working. Thanks! ralphbacon.blog
@adarshkeshri98884 жыл бұрын
How can I do this to a Raspberry Pi 4? There is no PEN or RUN pin on the board...atleast not where I can find them. please help
@RalphBacon4 жыл бұрын
The RUN and GLOBAL_EN (which is the same as EN) pads are right by the raspberry symbol above the power-in USB-C socket (the middle pad is GND, I believe). Always double check before connecting anything!
@adarshkeshri98884 жыл бұрын
@@RalphBacon okay. Thank you very much.
@adarshkeshri98884 жыл бұрын
The rc.local has been deprecated. Should I use crontab? And there's something else.....it seems that my GPIO pins are unable to respond but I have a few peripherals(Fan and restart button) connected to it that works fine. Can you advice me on what I am doing wrong?
@RalphBacon4 жыл бұрын
Deprecated it might be, Adarsh, but that doesn't mean you can't use it for an existing project. I don't know what you mean by "my GPIO pins are unable to respond" - do you mean on the Arduino side or RasPi side? If the former, you can easily put some debug messages in there to see what's happening.
@adarshkeshri98884 жыл бұрын
@@RalphBacon Yes you're right. Turns out that the there was some software issue on my Pi and therefore I was unable to get a response. I was able to troubleshoot them and now everything works like a charm. I decided to use crontab to run my script. Yesterday, I upgraded the setup to read the analog voltage from the Pi and reboot it if the voltage is too low. Thank you very much for your tutorial. It helped me a lot
@kmtb20116 жыл бұрын
i got a fan connected to my pi when i shut down fan keeps running, can i use that PEN/RUN instead of having a reset switch can i use a toggle switch to permanently cut power off?
@RalphBacon6 жыл бұрын
Indeed. If your fan is running from the +5v or +3v3 then once your Pi has shut down you can bring the PEN to ground and it will shut off the power control circuitry - thus stopping the fan. I know the Pi 3B+ has the PEN pad, depends on what version you have.
@kmtb20116 жыл бұрын
@@RalphBacon thankyou for your reply. I do have a pi 3b+ running retropie. Might do few test before implementing it on my board
@grindel806 жыл бұрын
Where you got this litte helper PCB with the Pin raspberry pinout?
@grindel806 жыл бұрын
i found it: www.aliexpress.com/item/GPIO-Reference-Board-for-Raspberry-Pi-2-Model-B-B-Raspberry-Pi-3-Model-B/32811197469.html?spm=2114.search0104.3.45.69cb64285ZNhpB&ws_ab_test=searchweb0_0,searchweb201602_5_10320_10065_10068_10843_10547_10059_10884_10548_10887_10696_100031_10319_10084_10083_10103_10618_10304_10307_10820_10821_10302,searchweb201603_2,ppcSwitch_0&algo_expid=8ce0a99d-c43f-4cbf-8a96-644c902d000f-6&algo_pvid=8ce0a99d-c43f-4cbf-8a96-644c902d000f&priceBeautifyAB=0
@RalphBacon6 жыл бұрын
The eBay seller I got this from has currently nothing in his shop, Frank. Perhaps he's ceased trading. But there are others, mostly from China, such as this one: www.ebay.co.uk/itm/GPIO-Ref-Double-side-Board-Compatible-w-Raspberry-Pi-Type-3-B-2-Model-CF/272263475608 Make sure you get the reference/cheat board for your version of the Pi! The one above is for the 3B+.
@RalphBacon6 жыл бұрын
The one you link to here is similar, Frank, but is not double-sided so you only get the GPIO pins, not the functions (eg RX, TX etc) on the other side.
@garymetheringham49906 жыл бұрын
re the pi you sadly lost, do you still have it? i was wondering if i could take it and with my very limited skills try and do an autopsy on it not very hopfull but would like to try
@RalphBacon6 жыл бұрын
Possibly, Gary, let me think about this. I haven't actually had time to test the board out (ie does even the µC still work?) at all. I don't still have your email, so send me one and I'll reply.
@garymetheringham49906 жыл бұрын
@@RalphBacon i will send yo a message on hangouts rather than post an email address
@christiansrensen38106 жыл бұрын
Hmm so the blue wire is the bomb wire... 30 sec and the 555 starts doing its thing..got it..😂
@RalphBacon6 жыл бұрын
Years ago, everything was controlled by a 555 (somewhere). Including my fridge door alarm, now controlled by a Nano, so much more configurable.