Episode: 4278 Title: HPR4278: Pi powered Christmas Tree Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr4278/hpr4278.mp3 Transcribed: 2025-10-25 22:25:00 --- This is Hacker Public Radio Episode 4278 for Wednesday, the 25th of December 2024. Today's show is entitled, Pie Powered Christmas Tree. It is hosted by Kevvie, and is about 15 minutes long. It carries a clean flag. The summary is. Kevvie talks about setting up a lead Christmas tree from the Pie Hut. Oh, oh, oh, Merry Christmas. This is Kevvie from the Tuxtam podcast, and you are listening to another episode of HPR. Now, for this special edition, I thought, I'm going to continue the series I've been doing with the Raspberry Pi, but make it a very festive edition. So I'm going to review, well, that's much review, but go over and discuss the 3D RGB Christmas tree. I picked this up from the Pie Hut for the grand total price of 18 UK pounds. And when it first comes, it arrives in like one plastic flat sheet with this circuit board. The battery already attached, so there's absolutely no soldering required for this. This is not a soldering task. You simply are going to need a set of wire cutters to snip off the three parts of the three. Now, we've got to be careful when we're putting it together, because it does need a firm push, because they are pushed to fit the three bits in total, and I can imagine it being quite easy to actually damage the pins. So just, that's the first bit I would be recommended, recommended for you to be careful on. Now, this is compatible as far as I'm away with all Raspberry Pi's, and I have mine attached to our Pie 02W, which the other 12 months of the year is usually used as an internet radio. I do plan to cover this in a future show, however, I want to actually properly finish off the radio and put it into our retro radio case, and then covers a whole project, which I've not actually done yet. So once you have the pieces together, then the three fits onto the Pie, with the soldered ends of the GPIOs facing outwards, and the instructions do give a warning about fitting this incorrectly, will result in voltage being applied to pins that they aren't expecting, so you can actually damage it. So the tree itself is about 100mm tall, that includes the GPIO pins, and at the widest part of the base is 85mm. Now, this certainly is not going to replace your regular Christmas tree, unless you are seriously downsizing. So there are four sides, so if you can imagine if you look down on top of it, it looks like a plus or a cross, and so you go forwards, and with each side has got three LEDs on each side, so you've got along with a top LED, which is inside a star shape. So that makes a grand total of 25 of these. So now obviously, to do with the Raspberry Pi, you are going to need a wee bit of a setup, so it's not simply plug and play. Now it wouldn't be boring for a Pi project, I mean, who could imagine that. So as I said already, I use mine with a Pi 02W, and if you're starting from scratch, then I'd recommend using the Pi Imager, as that's going to allow you to set the username, password, automatic logon, Wi-Fi, and also enable SSH. Now call it something, give it a client name as well, call it something like tree, so that it's easy to find on your network, and this will actually mean that you're never going to need the connector to a monitor. Now I think it's important to name it, especially if you're like me, where you've got loads and loads of things attached to your router. You want it to be something that's obvious, and I certainly would not recommend leaving it with a default Raspberry Pi, because if you do that, chances are you've got more than one, so it might be a bit of a paste just figuring out exactly which is which. Now if this is going to be a single use case, then I certainly would recommend downloading Raspberry Pi OS Lite, as it really does not require very much to get this running. So the first thing we need to do, once we have the tree attached and the Pi booted up is SSH into it, and we want to download GPIO 0. So if you have Raspberry Pi Lite, you only need to do this. If you have the full Raspberry Pi OS, then you don't, you can skip this step. So to do that, it's just sudo apt install, Python 3 hyphen GPIO 0. So you can go to the show notes for these, I'll include all these things in. So the next thing we need to do is get the code that will let the Pi talk to the tree. At this point, we need to really consider whether or not this is actually going to be just your Christmas tree or our Christmas tree and at Christmas decoration, sorry, and that's it, or is it going to be our Raspberry Pi doing various other things, and also having the wee decorative tree on top of it? Now if it's going to be the latter, then we maybe want to put this into a new directory, so it keeps everything tidy, because if you've got loads of things, you don't really want a bunch of extra files. So if you're going to use this for multiple things, I would suggest in the home directory do MKDIR, and then call it something of its tree. So make there space tree, and then CD into it to change it to the directory. So next, we're wanting to get the code. Now what I've done here is rather than give a big long URL, I've just used tiny URL here. The code is WGate, HTTPS, colon, forward slash, forward slash, tiny URL.com, forward slash 3, R, R, E, Z, J, V, 9, and then a space, and then hyphen, capital O, and then space, and then 3.py. And this is the default setup, and the pie hut, they have put together quite a solid manual, which talks about things like changing the colour, the brightness, etc., and I'm not going to read out the link, but instead head to the show notes and I'll link it there. But however, if you're like me and you're not a coder and you want to rebuild the easier life, then several users online have actually tweaked the code and written that own stuff and they've released it on GitHub. And I'd highly recommend you go and check these out. But the one that I settled for in the end was a user called Renzina, R-E-N-D-Z-I-N-A, and I went for the Christmas tree sparkle sequence. So to get this, and again, I've used the tiny URLs, so to get this, just type in WGate HTTPS, colon forward slash forward slash tinyurl.com, forward slash 5, E, 8, CXRB5, and then space, and then you want hyphen, capital L, and then space, now it's capital X, M-A-S, capital T, R-E-E, underscore capital S, P-A-R-K-L-E, dot pi, P-Y. Now, the test of the sequence is actually really easy. It's quite simply just Python, and then that last, the Python file, I just said, XMUS, underscore, XMUS, tree, underscore, sparkle, dot P-Y. Now, what we're not going to need to do now is let's try that, hopefully that should light up and start twinkling in a way that's suitable for yourself. But we're going to need to set this up so that it comes on every time we switch on, because you really don't want to be SSH into your pie, just purely to set, to switch this on. So we'll do this just with a crime job. So to do this, you go pseudo space, crime tab, space hyphen E, okay, and you want to add the following. So, first up, I would recommend that we actually have something that's going to switch it off every night. So if you want this on 24-7, you can leave out this command, but first of all, decide when you want to switch it off. So let's just say you want to switch it off on half 10 every night, okay? So the command you would put in, and Krone is first of all you put in the time, now it's the opposite way around, normally say, so minutes first, then hours, so 30, space 22, so that's half 10. And then space, asterisk, space asterisk, space asterisk, because we want this every night. And then space, now if you want to shut down, forward slash S, bin, forward slash, shut down, or one word. And then space, hyphen H, space no. So that's going to shut it down for us every night at half past 10. But we want this to come back on every time it gets power back up though. So we're going to add another line, and this is, we're just going to put the at symbol like you would have in an email, so at reboot, space, python, space, now this is going to differ for you. So I'm just going to assume that you've got your user as pie, but change it. And that we've created that tree directly in our home folder. So then you would go, so the whole thing is going to read at reboot, space, python, space, forward slash home, forward slash pie, forward slash tree, forward slash, exmas tree underscore sparkle dot pie with the capitals at the X T and S. Okay, so we want to exit and save. And if you're using nano, which is the default one, it's just control X, and then Y, and then return. And that's you. And actually that's it, nice and easy. To make sure it works, let's do that then, let's reboot. And just to do that, if you're still an SSH into the pie, all you type in is reboot and press return. And of course your SSH session will close, it'll kick you out, it'll say closed by device, the three should switch off, and then we'll reboot and should switch on. And there we go. We have a nice wee festive project on this Christmas day. One thing I would like to point out actually is that when you can shut it down, but because the pie still plugged in, it's still producing power, so it'll stop twinkling, but the lights will remain on. So if you want to actually switch this off, once the sequence has gone on, you will need to switch it off at the plug. So you may think, what's the point of that? Well, the good thing is you really don't want to be just yanking the plug out and risking damaging the pie or corrupting something. So this way at least it's a proper shut down procedure. Of course, as I said, if you absolutely don't intend to switch it off at all throughout the festive period, then fine, don't include that and just leave it on. But you do really want to put in that reboot sequence because if you've got an electricity blip or anything like that or something trips and you lose power briefly, then you really don't want to have to be SSHing into it the whole time. And the other good thing is this does shut down the pie properly, which is never a bad thing. Right then. So I've had mine for a point and I get it now. I got it actually in November. It's been pretty much up and running all the December. I absolutely love it. And the other thing about it is that it's actually a wee bit of a talking point. Everybody's come into the house, it's actually commented on how much they like it. I would highly recommend it. One thing I would suggest though is that isn't made clear from the documentation, this is one thing actually. I just forgot is that that tree dot pie, don't bother editing that. Create a new file and it's got to be in the same directory as that tree dot pie. But I made the mistake of editing it and I couldn't figure out why it wasn't doing exactly what I was wanting it to, but it's not really written like that. Of course, the problem is I'm not a coder, but I had kind of read through and I tried a few things and it just wasn't working the way I was wanting. And then I realized, okay, so the recommended way is to have another file in the same one and it actually calls the sequence. So I was like, okay, right now I'm starting to understand that a wee bit more. So it isn't made clear on the initial or my initial reading of the manual. So the manual pages. Yeah, so that's something that it's just worth highlighting because it took me, I was fiddling about with what half an hour before I actually got that sorted. So it just saves you 30 minutes. Right, so I hope you all had a lovely Christmas day if you say a little bit Christmas. If not, I just hope you're having an excellent time in general. So until next time, this is Kaby signing off for our rather festive edition of Hacker Public Radio. Listen in tomorrow for another great show. You have been listening to Hacker Public Radio at HackerPublicRadio.org. Today's show was contributed by a HPR listener like yourself. If you ever thought of recording podcasts, you click on our contribute link to find out how easy it really is. Hosting for HPR has been kindly provided by an onsthost.com, the internet archive and rsync.net. On this advice status, today's show is released under Creative Commons, Attribution 4.0 International License.