I Built a Fortune Telling Robot with a Raspberry Pi!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey robot makers hope you're having a good day so far so do you want to learn how to make a fortunetelling robot using a Raspberry Pi and a thermal printer then this is the show for you SL sty straight in my name is Kevin come with me to we build robots bring them to life with code and have a whole load of fun along the way okay let's get over to our slides and we can see what this is all about so yes I've made a fortune telling robot this is part of an exhibit I'm building for open source in San Francisco later this year in June uh and it's based at you might recognize on the movie Big so let's have a look a bit more detail about this so I'm calling this voltara so it's a fortune telling robot it's based on like I said Zar not volar from the movie Big with Tom Hanks it's one of his first movies that he did uh I remember this a long time ago I think it's one of the first movies I saw as a teenager in movie theater uh and this project is Raspberry Pi 4 power so I've got a whole bunch of Raspberry Pi 4S kind of laying around uh and I thought this would be quite a good use to run the python code that makes all the magic happen in this and we're also going to use a feature of Unix a fun game uh utility on Unix it's called fortunes based on fortune cookies and they're kind of Fortune Cookie esque messages they're so much fun and of course we're going to use the thermal printer to print out the message so what people will get is a little um thermal print out like this they can press the the button the arcade button on the front of the machine got these nice arcade style buttons from Pimon from the store uh and they're very very simple to get working we'll have a look at those as well in a second or two they'll press the button on the front it'll print out a message and they can take that away it also has like the web address of kev's robots on there too and they can learn about it so it's not quite finished yet as a project you can see that the actual model isn't in there and there's going to be a bit of animatronics in there you move ahead and there'll be some lighting and so on uh well that's kind of what we're going for I've got a bit of a horse throat today I'm afraid so yes this is for an interactive exhibit for open source 2024 so I'm really excited to go across to San Francisco I think we're in the Cow Palace this year uh and this is something that people can sort of see they can touch they can hear it perhaps we could have some sound effects in there as well uh can't quite taste it I mean you everything's taste of all I guess but uh yeah that's not quite the uh the sense we're going for there and it's something fun something I can show people they can interact with it so I'm not just kind of sat there with a big sign behind me doing nothing so thought it'd be quite fun as an Interactive exhibit and it's small enough for me to be able to ship this across to the UK so actually from the UK to the US so if I just go over to my desk here this is the kind of size of it it's not massive it's h it's quite small as you can see um so it's probably about uh I say 40 cm tall something like that so that's kind of what it looks like at the moment so it was like I said inspired by ZTA now I was actually um out having a family day out I think it was your birthday wasn't it Alex we went out to Mother Shipton's cave which is a really unusual exhibit in the UK it's the oldest tourist attraction open since 1630 which is ridiculous uh and it they have a petrifying well it's very unusual so water from a spring um goes over these rocks and it has minerals in there and they have all kinds of things hanging down like little teddy bears and as the water passes through them over a Ser of about 3 to four months they turn to Stone so it's a really really magical kind of spooky place there uh and they had in the little shop that they have where you can buy these teddy bears if you want I think we've got a few of them um they had this Ulta machine so that's kind of a life-sized version it's not exactly screen accurate this one here but um it was still quite a bit of fun there so it was fun to see that given that I knew I was building this so yeah that's that's something that we uh we we found uh just serendipitously so yes today show is sponsored by PCB way so I want to give a great shout out to PCB way and I want to show you uh one of the projects I've worked on recently uh which is excuse me this uh remote control so this is a PW remote control and I designed this in Fusion 360 so you can see on screen here we have if I go over to here maybe go to this view here you can see it bit better so design essentially it has eight button so there's four on each side and then there is the PW in the middle um and there is also a power connector there to the bottom so I can plug in uh a nice Pimon gallion battery to power this I think they're about 3.7 volt something like that but it's a goes through the little regulator at the top as long as it's less than 5 Vols we're golden so yes I designed this um circuit you can see here in Fusion 360 essentially they've taken over Eagle what used to be eagle and now it's all part of fusion 360 um excuse me you then designed a board layout so I designed a 3D um kind of pro file for this infusion 360 and then you can drag on the components from your electronic diagram and what you end up with then is the the sort of 3D model so you can see there that's what the uh the actual board looks like if you were to see the little traces and everything so I simply exported this file as a a gerber file and I went over to PCB Way's website which I've got if I just click over to to here we can see pcb's website and we just click on the uh the PCB instant quote and I uploaded some of the um the the files the Gerber files that they call them there so simply I I think I picked the single panel I think I went for five pieces you type in the dimensions of the actual board if this was sort of a rectangle um I think this only has two layers like a top and a bottom layer so it's actually quite straightforward I went for this simple uh F4 and I think I left a lot of those defaults and I actually went for the the yellow board Bo and I think the silk screen I just went for white and there is a solder mask on there as well which I think is the uh is that the actual yellow color perhaps on there so yeah very very configurable very easy to uh to get exactly what you want and you can choose what kind of finish you want on there as well once you've made all those choices you can upload the the gerbal file which we' exported from Fusion 360 uh we can just we can even have like uh Flex rigid rigid Flex as it called which is those like um a bit like the PCB um I can't quite grab one's hand but the uh I've seen people use these as like um a magnetic um flipper thing so it can like vibrate very fast or something I can't remember what they actually use that for now but it was like quite a cool little thing anyway you can basically have uh non rigid uh pcbs they can even assemble them for you they can do um SMB stencils so if you want you if you're making loads of these you can actually get the the aluminium stencil so you can put your own solder paste on and get it exactly in the right places so you can manufacture these with a pick and place machine yourself or you can have them do the entire fabrication if you want as well and when I got mine sent over to me there's one of them there like I said I got a pack of five it was actually less than two weeks from me shipping this off um clicking the uh all the buttons on here and getting this sent back to me as a package and it's very nicely uh rounded off very nicely finished um basically you could sell these right away so I'm very impressed with that as a as a a whole system um from start to finish so definitely check them out they're great sponsor of the show they've sponsored quite a few of the shows in the past as well so thank you once again PCB way okay next so the 3D design of uh this model i' made excuse me just going have a drink of water I've used Fusion 360 I did try using um freead and I'm kind I'm still learning how to do things in freead it's not quite as polished as Fusion 360 and I'm more familiar with that so I basically did all this infusion 360 so there's the overall design it's kind of like an arcade machine but like a desktop size one and um big enough for essentially like a Barbie doll to go in there even though it's not going to be a Barbie doll it's going to be a custom 3D printed model and uh it has an arcade button so on the original thing they had a button that they pressed to uh they get like little things that he moved um a penny shooter into the mouth excuse me a second sorry about that and um yeah it essentially we're having like an arcade button to activate this on top of the the the three the um the button the arcade button is a thermal printer so I bought this quite a while ago I think it was from Ada fruit I'm certainly using all the a fruit libraries to bring this to life with python but these are great um uh pieces of electronics very cheap I think it's under $40 is what I paid for it and you can buy all these um refillable paper spools for them they're essentially just receipt um spools and the paper contains the ink so what happens is the thermal printer heats up the paper there's no ink required just the paper itself and uh these stay around for a couple of years so it doesn't fade that much over time and I've got a few other bits and pieces on this to basically screw the whole thing together the actual um model the head has a tiny little mouth so we're going to get it to do the the Volta the the Zar head movement which is like the the chin stays still and the head sort of goes back so again and the eyes light up red so this I think is a corpse bride model that I bought um specifically for this project and scaled it down so it fits perfectly into this model and we're also going to have some uh sort of Furnishings curtains and things behind it too so here's a cutaway of the uh the model you can see there the the the thermal printer sort of goes into the uh to the front panel there as does the arcade button and I was really careful to measure these and on the second print absolutely dialed in really perfect they fit in just right um so they they they basically just push into the uh to the front there and friction holes been place it's such a nice fit there I've got these corner pieces as well which allow the M2 screws to hold everything together and that adds a bit of extra stability I could have gone with just the pieces um with some sort of 3D printed extra bits there but I wanted these to print um flat with the front side um sort of facing outwards so yeah I thought this was a nice way to add a bit of extra strength in there have these sort of co uh Corner columns and it also ties the bottom pieces and the top pieces together too so I've also got these screws and they're slightly offset so the idea is the screws can go in an angle and they don't sort of clash together um so it's a very simple design decision there just to make sure that you got the extra strength of the the screws I bought a little pack of these I'm not sure I put them now but um they're essentially just M2 screws with a nice hex nut um to screw them in there so the arcade button very very simple they just have these two um connectors on them there if I sort of show this to the the camera there you can see there's just two little terminals there it doesn't matter which one is to ground and which one is to the signal as long as one of them goes to ground we can then just pick that up in one of the gpio pins on the Raspberry Pi so very very simple I'll show you the code for that it couldn't be easier to get working the thermal printer actually uses uart it uses a receive and transmit so all we need to do there is just um use the uart on the Raspberry p I'll show you the wiring with that in a second uh but you do need to power this separately from the Raspberry Pi so I bought a 5vt 2 amp power supply separate for this uh and I bought these nice little um Barrel jack connectors so I think these are is it 2. 5 mm um Barrel jack connectors and you can see there there's a bunch of connectors so the the middle one is the one that's uh if I show you that on the left hand side there and the two that on the right are the sort of outside Shield so as long as the the 5 Vols goes to the middle on this particular wiring and power supply that I've got then we golden everything works fine there and then the Raspberry Pi just connects to that like I said through two U connectors um they also on the back of the 3D prin it comes with all the wires you need you can get some of these which are USB uh so you simply would just plug that into the the front but these ones are called TTL cuz it's five three to 5 volts uh but it plugs directly into the gpio it's fine on there so Raspberry Pi 4 is uh on the bottom of the uh the machine there uh I've designed the the holes the mounting holes on the back there I've Got U holes for the the USB power in the HDMI 1 and two and also the audio jack I've also replaced this with the rasby pi 5 um the audio jack would still be like the hole would still be there but there wouldn't actually be any audio jack there but this was just in case I wanted to provide some external speakers and have some sound effects be very easy to do that too I could also have a speaker inside there but I've not placed any kind of grill or anything for the sort of sound to escape from in there so the rasby pi 4 essentially runs the the python script it means it's very versatile we can do all kinds of clever stuff with this um we could even have some like large language models if we wanted to doing the fortunes locally on the device with all llama but I thought for this particular one I'll just use Fortune which is this Unix um game facility Library routine whatever we'll have a play with that in a second it's very very versatile so Fortune will send the message to the thermal printer in our python code and we can sort of top and tail that with a sort of header and footer as well and maybe change the font size and and underline and all that kind of good stuff as well on the printer so I'm also going to animate the um the figure inside like I said headle move and I've got these RGB LED strips as well so I might put these sort of inside um maybe at the top and bottom or maybe at the sides um not quite decided on that yet and also the the arcade button just connects to the Raspberry Pi 4 as well that then screws into the base I've also got four extra holes underneath just so that when I when I screw the raspberry pie in it's not sort of wobbling on the case the screws at the Four Corners as well just so it's nice and stable Okay so we we decided to use resin as the glass because we could custom make this to the exact perfect size and we wanted that top section to sort of be a slightly different color maybe like a yellow color um but we can do that by just separating out or maybe just painting a bit of yellow on the inside of it um but these come out pretty well on that camera on that picture there they look quite warped um they're not that bad actually in real life um the light passes through them they're very transparent and they look just like glass um we painted the the entire frame um we've gone through a couple of challenges actually with the painting so the top section we're quite pleased with that's gold colored that looks really nice the bottom section we went for like kind of a distressed blue and red um scheme um but it ended up looking just like it very badly painted so we've actually printed out the entire base again and repainted this sort of a black and distress blue and it looks so much better we'll have a look on the the screen in a minute uh in more detail so this resin was a really great idea it basically cured overnight and we have a sort of mirror perfect flat finish on there there's just on one of them a very slight uh ripple effect but it's h it looks great and the light will basically Bounce Around inside this and also give an extra effect it's much better than just having nothing there at all or having some kind of acetate this makes it look um a lot more real so very very simple we we had a silicone mat to pour the resin on and the frames were sort of held down so that there was nowhere for the uh the resin to escape it did escape on a few of them but it's very easy to sort of trim that off uh once we'd uh we' let that cure so very easy to to use this um Jenny helped to do the pain in and pour the resin on that one as well so you can just see that little yeah shout out to Evan and Caitlyn for giving us some advice on how to uh to do that through their videos not directly of course cool so the top section so this is basically just like a little hat that goes on top it just finishes the model it will also help keep The Light Within and bounce around with within the uh the arcade machine also keeps any debris from sort of going into the the uh the model as well so it just gives it a nice Finishing Touch I think too so um if you like what I do you want me to make more of these kinds of videos then please give this video a like uh drop a comment let me know if this is a fun project if this is something you'd be interested in and also tell me how many raspber pies that you have in your draw that you're not currently using I'm always interested to know uh what people have in their draw if you've not already subscribed please subscribe to the channel it means an awful lot to me uh this time of year we do tend to takee a bit of a dip in subscribers as people get outside and do more more things rather than watching videos so uh please don't be one of those people that doesn't subscribe please if you haven't already subscribed please give that a go okay and I do go live every single Sunday last Sunday I was really ill so I couldn't uh go live but um I've solded on just for you guys today so you can hear my throat's a little bit worse for where but uh hopefully we'll get through the show so I do go live every single Sunday 7 o'clock British summer time okay so yes painting the uh the model so we use these acrylic based paints uh you can see there that silicone mat we use that um just to sort of paint on CU it it's just a nice clean surface to to paint on that's our little uh breakfast B area there with a funky wallpaper it's got like this UFO effect on there little people being beamed up um so yeah we we chose the black and this metallic blue to sort of distress uh on as well this is the effect that we used on ball when I painted ball we sprayed ball black and then we rubbed on a gold colored of distress so you can put it on and then sort of wipe it around and wipe it off and you get this nice kind of aged looked to it so yeah just very simple acrylic paint because it's 3D printed plastic and this was a um a piece you can see that on the the holes on there it didn't have the audio jack this was the first back piece that I printed um and it didn't have that so didn't quite fit right so we use this one as a test piece to try out four different ones so we tried a few we tried the metallic blue which is the top left we tried metallic silver which is the top right and the metallic gold which is the bottom right now you can't see too badly on this picture but the top left is essentially what we went for there on the other side of this was basically the blue color with some black distress on it didn't quite look as good you can see in fact the previous paint job on the top right there of the screen so there's the blue silicon mat that we use for these you can see that gold color has a really nice sort of solid finish to this um so Jenny helped with um with painting those and doing a much better paint job than I did there so wiring this up so it's quite a simple uh wiring exercise I use fritzing to do this little wiring diagram because uh they had all the models in there so that was nice and simple to do so the arcade button is on gp23 the pin next to that is actually a ground pin so uh it's only the pin 23 that we need to look at from a software point of view is it being pushed or not and then the RX and TX on the Raspberry Pi Z zero uh is on those sort of second and well third and fourth pin depending if you count it zero or one but yeah the left hand side where the SD card is on the right hand side there that's um the uart pins so this is the hard hardwired uart connection on the rosby pi um and you actually have to go into the console I can show you this in a minute if I remember I'll actually just make a note of that just to to make sure I uh don't forget uh that so that's the Raspberry Pi yeah so you actually have to switch off the serial console on the raspby pi and enable the hardware serial connection and then it appears as device serial zero in your device tree I'll show you that and the the code in a minute I've just made a note of that uh so the thermal printer connector that youart uh it comes with these little header connectors already there so you can actually plug that header connection directly into the raspber pi which is pretty neat um and it requires like I said 5 Vols 2 amps for the Tho printer you can't actually run that from the Raspberry Pi it'll basically just make it reboot because it'll pull too much power from the power supply and it would damage this chip if you tried to do that through the pins directly and I brought a whole bunch of these um little Barrel jack connectors um so these I think the 2.5 mm um Barrel Jacks and they basically just have a bunch of connectors on the other end there so simply sold that in and they come with these little hex nuts just grab one of those there so you got this little hex nut and you can basically just screw that through so as long as the uh the 3D printed piece you push this on and then thread the the hex nut on to the end that will basically hold it in place nice and secure the best connection honestly when things just work right really really pleased with this they're an interesting kind of shape because they they're a circle with the the Edge chopped off um so I modeled that in the 3D model and honestly it just pushed in first time connected up no problem so I solded the wires on pushed it through put the hexnut on locked into place lovely okay code so obviously this is python so I'm going to show you the code that I made just to make this thing sort of work um I've used the the serial connection um which is a standard python thing if you have a raspber pi I think you just install Pi serial to get that uh and I've also made my own Library that's called volara I'll show you the code for that um and I've borrowed the Ada fruit um thermal printer Library they no longer support thermal printers I don't think they sell them anymore but um you can still use their code it works fine in Python so what what we need to do to set the up and we have to pass it the the device connection so /dev Sero Z once we've done the the raspber pie stuff I'll show you in a minute to configure that the board rate this is important if you're if you want in chuse this as like a general printer I'll show you some of the the challenges with that um but that 19200 is quite a fast speed you can have some issues with sending too much data at once uh and basically the pr the image won't print out properly if you're trying to print like some kind of graphic out and then there's like a timeout value as well I think that's in like milliseconds you can then actually change how fast the printer connects this uh set time 3500 and uh 2100 these are some values for printing out um like like images to sort of slow down the reason that there there are challenges with this is the thermal printer is pretty dumb it has a memory buffer and if you put too much data in that buff it'll just overrun and you'll basically get loads of garbage in the file and then the rest of the image will just print out so you can to get the beginning garbage and then the end so by changing these printer times you're actually sort of saying to the um the thermal printer can say back stop slow down only send me a bit of data at a time so you're managing how quickly that buffer fills up that's kind of what that's for printer. feed will actually do Line Feed so it spits out more paper the button. wait for press is a really cool um button function I think that's we'll have a look where that comes from in a second I'll show you the code for that but essentially the the the arcade button the code will stop until you press that and then it will just run the next piece of code in there which will feed two lines it will set the underline value on so on our little print out there if I just show you this this is what will actually come out so you can see that that top piece there if I try and get that so it doesn't white out um that's double height so the the size is a medium I think on there it's got an underline value there so that the whole thing is underlined um it's also centered on the page which is pretty neat it then prints out that volar fortune teller does two lines after that we then switch off the underline set the size back to small set the justification to the left hand side we print two more lines and then we say your wish is granted now this is the area of the code where we'll actually put in the fortune cookie so it won't just say your wish is granted on the final version of this and then it will do a um a couple of lines and then it'll just say KES robots.com volara so couldn't be simple of the code uh mainly because the Ada fruit thermal printer Library does a lot of that heavy lifting for us so um well let's have a bit of a play with the The Fortunes in Unix shall we so I'm just going to grab um my uh let's go full screen on this and me just flick back it does this weird thing on there there we go let's go back to here right so I'll I'll make this a bit larger so we can actually see what's going on I think there's a zoom in function there actually I didn't need to grab the window to zoom in I could have just uh let it zoom in itself okay so hopefully that's that's visible so to install fortunes on um on the Raspberry Pi we simply um we can install this through the APT so we do pseudo apt install fortunes and we can also do fortunes D mod and this is actually the the data files that have all the fortunes in them is it Fortune mod I think it might be on there yeah we've already got them all installed on there so and then the other thing we need to do to get the thermal printer working I'll just show you that so if we do pseudo raspy - config this is the rasby P Configuration utility uh we go to the interface options and we've got this serial Port so we need to make sure that we uh don't make the shell accessible over serial and that we do enable the hardware um in there as well so going to click that going to click finish and what that means is if I do LS Dev this is the device uh folder and if I do serial zero that now exists as a path and anything that we send to that will print out of our printer so um I'll actually show you that if I go over to let's see if I do this one here so you can see in the top left window there if I type uh echo in fact let's go full screen just for a second Echo uh hello live streamers and then I pipe that into /de serial0 uh before I press return it's going to go back here so watch this here I press return and it spat out a little line there so if I now um I'll have to just juggle this of a second just by can you see what that says on that uh piece of paper there let me tear it off put it onto the camera let's see if I can get that so you can see it it says hello live streamers it might be easy to show you on this full camera here there we go so it's very very EAS to actually print things out now let's go back to um let's go back over here and let's let's now do some fortunes if I just typ in Fortune um it doesn't know where the fortune data files are so there's a whole bunch of these that got installed when we installed fortunes if I go um uh list and then shared games I think it's shared games wonder why it's not is it shared games fortunes there we go so all these files here are the fortunes themselves so they're actually like a data file that's got loads of different saying quotes in there so I think there's one in there that's called humor so if we do fortune and then we pass it that path so share games fortunes and then computer well let's try a different one actually that one didn't work let's try is it Linux did I type Linux correctly then there we go so we've got a fortune it says uh I did this because Linux gives me a word gives me what let's try a different one um what is the state of Linux unic code implementation will you will Linux be prepared for First Contact we have full cling on Console support just in case so some of the jokes are not very good let's try that computers one again if I just let it all to there we go computers when Dexter is on the internet how can we can hell be far behind so some of these are funny some of them are not I think there's a humor one actually uh let's try [Music] humor humorists time is illusion lunchtime dou so that's a hitch is guide one um what else we got that now you can do like long on short ones there is like an obscene or non-obscene options on here as well I think it's like- o or something like that um is it D E I can't remember they or it might be the files themselves um but yeah there's a whole bunch of these if we just go and do that list again let's see what else we've got um so got food let's try a food one so let's go back there food TR eating telling food is that five six days later you're hungry again let's try another one National Association of theater concessionaires report that that in 1986 60% of all candy sold in movie theaters were sold to Russia so that's the fortune thing that's what we're going to actually use I'm just eating some ice there that's what actually going to use in our code to generate these kind of fortune cookies and there's a whole bunch of them there's even libraries of these on the internet that you can download U that are not included in this fortunes but honestly you could you could run this and never see the same twice in your entire life um it's pretty cool so let's go over to visual studio code and what we're going to look at next is how to get that arcade button working so I might have just dropped one then um so I've got an arcade button here this is a nice black one and it just has these two connectors on there they're connected up to ground and to gpio 23 so if we from if we import from gpio0 and import the button function we can then simply say button equals button and then provide that gpio number and that's it there's a button. wait for press so if I run this code uh it's not going to do anything until I press the button oh I'm actually running the code I think on another screen so if I just go and quit that there we go let's just try that again so what I will do I'll I'll try and get everything on screen at the same time so if I run that code again so it's waiting for me to press the button if I press the button and then Zoom back into to that thing there you can see that it says uh when I get back to the right screen sorry you can see that it says button press if I just run that again there we go and I press the button I'm pressing the button now it says button pressed so very very simple code it kind of halts any code beneath that once the button's been pressed it kind of releases it and then you can do whatever you need to do next right next up we're goingon to have a look at printer test so this is going to print out some uh tests of our printer and what it can do so I'm using the Adafruit thermal printer Library so I did have to do pip install Adafruit unor thermal to get this Library installed onto my machine um I'm then setting up a printer object that's called um oops sorry printer equals 8ot thermal the path to the serial um console out which is what the thermal printer is connected to excuse me the the the board rate now this board rate here has to match the board rate that the the Ser the um terminal device is set to and you can actually set this with the set TTY stty and then I think you just provide the path to it so like Dev serial zero and then you provide the the value the the value that that you want that to be I think that's correct um let me just see if I just do man uh in fact if I do that will it tell me what it needs to be so if I do stty serial Z Dev serial zero no probably just need to read the manual page if you ever stuck in Unix and you want to know what the uh the the options are there's a couple of ways you can do this you can have a look at the manual for it so if I do man stty this is sort of full manual for that command so I can just uh scroll down there and see what I need it to be and they'll give you an example if I just keep scrolling down on here of how to type in the commands um if there's a lot of commands it might take a while to start scroll down so I'm just doing page down now uh let's a see um is it not got an example on there that would really be helpful if it did because I'm sort of viewing this in like a a very small thing it's not that easy to see what's going on the alternative to man is if you actually type in the command and then do das dasel that usually provides the help that you need as well so this might actually provide the example that I was looking for there but essentially stty is the command that you need to do to set the the board rate for that terminal device from the console and it should it should remain there once you've set that you don't need to do each time you reboot the machine for example okay so there you go uh-h f that's all I was missing there so if I did- F uh let's just type it in so if I just do stty DF and then Dev serial0 and then 19200 that's Now set to be 19200 so the board rate is now matched to the serial printer itself in our code um the next thing is the uh this printing we don't actually need that set times because we're not printing out any images in our in our final code but on this particular particular piece of code this thermal to printer test one we're going to print out the Ada fruit logo because they provide that as a little graphic in the uh the graphics folder so if we open up that have a look what that looks like they've got a height and a width and they've also this data so if you were to sort of squint your eyes and look at this this is actually the sort of Little Flower um is it like a pentagonal shape that is their logo um so that's what's going to be printed when we do the uh the print test it's going to feed two lines after printing that bit map it's going to sleep wake up and then set the defaults whatever they were so if we've changed around any of the the font sizes and so on it can change that back there so if I now press print on here and I jump over to the overhead thing there can you see the little uh Little Flower thing that's printed out there there is this nice button on the the front of the 3D printer 3D the thermal printer if I just press that number of times I can get that to to squirt out some extra pages but I can also just tear off okay let's go back over to the full screen there you can see uh what that looks like so it's actually pretty pretty neat isn't it you can see the quite a lot of resolution for what is quite a a simple device so that's the the printer test um and then let's have a look at our code so I made this code a little bit uh a bit more involved but not too much more involved so we've got this while loop so while there's no keyboard in interrupt we're not going to press anything we wait for the button to be pressed on the front of our um arcade machine we feed five lines out we set the underline on so it has that underline because we want to print out this uh this message with the underline um we then want to um set the size to be medium um set the justification to Center print out the volara fortune teller uh the slash n/n is new line You'll see that in uh if you're using like um Arduino C++ that kind of thing but it's a quite usual convention for doing new lines uh these forward slashes are called Escape codes and thanks for subscribing their Joy um Escape codes if I just uh switch that off so it just doesn't uh disrupt us again Escape codes are special characters they usually have the Escape character which is like a really low value in ASI the American Standard code for information interchange which is like a standard for displaying characters and um there's only essentially 255 characters within that code code um so Escape characters are a way of sending special signals to things like this thermal printer so the way that we're setting the the the medium or the small the underline the non underline there's even an inverted where it makes the prints out black with a white text on it they're all special uh Escape codes and new lines are essentially just another escape code on there um so there we go um Line Feed off set the size to standard justification to left uh feed two lines print your wishes Grant feed two more lines do the underscores like a another ruler and then we can do um the actual message itself feed four more lines and then we just reset the printer to its default values again we could do that default thing so if I now press run and I run this code U on the right screen there so now it's waiting for me to press the button now I've actually not got any code in here to stop multiple prints from happening so if I hold that button for too long uh and the code goes around the loop again it will print out the same thing again and again so let's go to our um printer I think this is probably the best view of it and if I press the uh the button as soon as I press it we get the thing being printed out there if I tear that and show you that piece of paper there you can see there it says voltera fortune teller your wish is granted and then the uh KES robots.com which is kind of going off the page a little bit so maybe we need to play around with the uh the font sizes on that one to make that one uh a bit more U easily to view cool so let's get back to over here so we've had a play with the The Fortunes so some of the challenges we've had with this project so far so there's always challenges and some of the things um I like to I like to share these things just so that uh I can I can look back and figure out how I did something last time but also if you're having the same kind of problems um you can you can have a look at this and see what the the answer is too so the thermal printer has I've had lots of fail prints with this particularly if I'm doing Graphics printing so you can actually print if I go back to that uh terminal there let me just end that program uh in fact let's go back to there I'm using visual studio code I'm actually connected via SSH which is pretty cool so this is actually running on the Mac so if I just do control C to come out of this um I can actually print out a graphic like a proper um PNG file something like that just seeing if I've actually got any of them to hand actually um I did have some there we go voltera speaks so voltera speaks is actually um if I find that I think was in utilities it's it's a a PNG file so that's what it says I want to put this at the end of the uh the print out so you can actually do a line printer if you can do LP is it fit to can't remember the exact thing on here fit to something or the size is it this may or may not work uh they don't think we we provide the path of the file um it's been a while since I've doing this so what I'm going to do I'm just going to type in history and that will show me all my Unix history commands if I can actually type in history correctly uh and then we can find that STI that for now so I'm just looking for an LP command on here because that means I've I've done this previously and it work there we go a there we go so that's all I need to type so this line printer lp- out- Z I think that's - always output fit to print which is the option we want it to fit this JPEG to the printer size and we're passing it the PNG file so if I do that um no file or directory that's because it's got it's inside that folder so in fact I think it's got a different name hasn't it volara speaks if I put that into speech marks that might make it work uh no it's because there's a typo it says volara there we go right so it's printing that out and I want you to see what this looks like on here you see it's just like loads of garbage and there is actually some bits of I go full screen on this one again look what's happened there so we've got all kinds of weird characters and you can see that there's part of the the image is in there and this is a buffer overrun and this is because the line printer isn't waiting for the printer to catch up it's just sending the entire file all at once um so we can change this by changing the line printer speed and also um the terminal speed so we can actually slow down how much data is being sent there so we could try um using that command that we we tried before which was the um the wrong window there um which was the um stty and we can slow down we could do 9600 instead of 19200 which is much faster speed so if we slow it down it'll take longer for that buffer to fill up and hopefully it will printed and used up some of that buffer so we don't get that kind of image so if you're if you've got one of these thermal printers your follow is um in instructions and you get this kind of thing happening it's to do with that buffer overrun and the only real way to to deal with that is slowing down the board rate is is my findings so the print speed as well it's quite slow when it's printing images and this is because um text is like really small so it's just like a single bite uh per character if you're sending Graphics data that's like a lot of data um so it actually takes longer for the the buffer and the processor on the little 3D printer to chew through that so they're not massively fast if you're printing out graphics on this um it'll take a little while that's why things like that ADA fruit logo are really small because it it's quick to print um and it's like not taking as much of the page up the other thing is the power so if you've not got two amps um or more going to this thermal printer you might find that it Grays out or that it kind of reboots in the middle of printing something out because it's heating up the paper and it takes quite a lot of power to make that little thermal uh printer work I'm quite curious I bought um I'm not sure if I've got it to hand actually I bought a little thermal printer um which is kind of a handheld battery powered Bluetooth one um and that just requires like a couple of AA batteries or even have a lipo battery built in so I'm quite impressed that they managed to get that much power out of their little pocket um thermal printer that uses the exact same um pieces of I think these ones are the other ones I got for that but these are all the standard standard size so they they sort of length of these is identical and they're very cheap to buy so you can buy absolutely tons of these because they're basically used all over the world for receipts um painting So we had quite a difficulty getting the painting just right on our model because um we we wanted to get a particular look which is like an aged old if you think about the movie Big this was like an old arcade machine that was on a pier somewhere we wanted to get that kind of same kind of look to it so that isn't easy to do off the bat so so we we basically tried putting some color on and then distressing with black that basically looked a lot messy didn't really look like a distress it just looked black badly painted so we tried the other way around we painted it black and then used the the color to highlight it and that look far better and that's what we did for boo which is the steampunk robot if you've not seen that definitely check that out on the channel as well okay so we do have some merch on the channels if you want to get yourself one of these hats we've got them in a number of different colors there's the red one that seem to be very controversial to people in the US I can't imagine why um um so that's why I'm wearing a black one now instead sorry for the vocal fry that's just a just today's Vibe I'm afraid and we've also got some mugs as well on there some hoodies and whatnot so definitely check out the merch store if you want to help support the show um now there was a a question in the uh or a comment in there um from Peter and and it's quite a useful one actually so I'm just going to go back over to the uh uh to the Raspberry Pi um you can actually install this as a printer um so is it preferences actually preferences printer settings you can add this as a printer and you can share this on your network which is pretty cool so you can see there's my HP printers but look at this ZJ 58 so I went to add new printer ZJ 58 and you connect the serial zero or TTY s0 which is the same thing essentially um and you can set some settings in there so if I wait for that to load up and this is the these are the settings that I've gone with so I've got the boorder rate is 19200 the Pari is default the bit rates are default but the flow control is xon X off in software you got a few different choices in there that's the one I've gone with that's also part of the how it sends and receives data and it's all done in software uh Peter just mentioned that about the um the flow control and how printers especially these old serial printers uh control the flow of that but um the cool thing is you can actually have this uh as a printer that you can do things that can do a test print page there that's now going to print out if I go back to that view there it's printed some garbage because it's tried to print a bit of an image you can see the image over uh overrun there bu overflow sorry so we can fix that by reducing the board rate down a little bit and just seeing if that works okay we need to do that both in the printer settings and also on the the terminal using the stt command we looked at before so thanks Peter for just highlighting that that's quite a good uh talking point there okay if you want to join our Discord server we have a Discord server head over to KES robots.com Discord and you'll be able to find all the cool things on there uh there's a really growing community of people helping each other out and another thing I wanted to mention about um K robots.com if I go back over to here K robots.com is now ad free so I've taken off the Google ads so um you're not going to get any of those disrupting your your use of the website you don't have to have any ad blockers or anything um it was generating a bit of Revenue to pay for itself cuz um I do have things like the um privacy policy terms and conditions disclaimer they're provided by a company called terally and you do have to pay for that as a service and the whole website is also um as well as being hosted behind me on my little raspberry pies just uh just behind my head that you can just see them flickering away we use cloud flare to provide some denial of service protection on top of that and to get some stats and whatnot uh that's not free either so so the ads were actually helping pay for that but they were actually getting in the way and uh I decided I'll just suck that up instead so you get a better experience when you're trying to find things on here um another cool thing we've just added very recently I've not got an easy link to this yet um if I go down to let's see I go to one of these projects no not that one sorry that's a YouTube video that's not what I wanted to show uh let's try what am I trying to show you here I'm trying to show you the link to uh the stem resources which is something new that we've added in here uh let's try going to one of these projects no that's not I'm fiddling about here and I'm not getting where I need to go to if I can't find it I'll I'll give up and I'll come back uh so essentially if we go to k robots.com stem uh there's a new area which is the stem Center and we've got things like connectors um so if you want to learn about um connectors and all the different types of connectors for plugging in um I don't know why I jump to that particular one there but uh yeah there we go that's better so connectors Dupont connectors Grove connectors GST do you know what GST stands for if you click through there you'll you'll find out i' got Molex I just need to add in some quick demo QT connectors in there and I think the article then pretty much uh complete there's a whole bunch in there about i squ c SPI and uart as well so uart is what we're using today to do the thermal printer connection so it's got a bit of information about that as well so that's a new area the stem Center that we've added to the site as well start building that out too yeah K robots.com is now completely adree so want to to mention that too you going to follow me on social media you can do this a number of different ways if you go uh to threads I'm on at Kevin M at red.net I'm on Tik Tok at Kevin Maier 6 I'm on Instagram at Kevin Mia we had a video blow up actually Alex this week on uh um Instagram I think it's had over 20,000 views so far which is crazy uh for one of my videos and um I can't remember which one that one that was now but it was it was one that didn't seem to me to be worthy of 20,000 views but Instagram sha its light on it and has picked it up um I'm also on the X kevmac on Macedon kevm madon doso on Blue Sky kevmar B.O as well so if you're on any of those platforms definitely uh follow me on there say hi let me see what kind of projects you're working on I'm always interested to see what people are building particularly if it's robot related or even raspber pie related and if you want to support the show you can do this in a number of different ways so just want to give a shout out to Ford who just uh dropped some dollars there saying good show this week thank you very much for that I do appreciate that so he a he did a Super Chat uh which sort of pops up on the screen um so thank you so much for doing that I'm just going to make sure we've got all those switched on again now as well and um yes we have YouTube membership program as well so if I scroll back up there I can also just pop up that on screen so that's uh thanks forward for sending that through really appreciate your comment there if you want to join the YouTube membership program you can do that simply by clicking the join button so once you've subscribed that gets replac by a join button you can press that and for the price of a coffee per month you can help support the show and help pay for things like that website which I now pay for myself cool um oops let me just jump back there and yes our supporters I want to give a shout out to people who have joined all those different programs I've just talked about there so I got a coffee this week from Tom thank you Tom for that I think he particularly appreciated one of the videos that we uh shared this week um last week I think it was we've got um um John Johnny there as well he bought coffee and we've got a number of members as well so on they buy me coffee side we've got shmy we've got Kevin we've got Lee Alvaro Marie Jeff we've got Dean Cy Marlene Tom and Steve and on the YouTube membership side we've had um Al Alondo if I pronounce that right Al Alo I can't pronounce that now alalo um calvaro he joined very recently as well we've got Paul Johnny Dale from hybrid robotics got Wayne we have Steven we have Jonathan we have arrad 39 Vince John Paul got aliser Cassie hope things are going okay Cassie and you're recovering nicely there as well we' got tinkering rocks JDM Johnny bites we have handsome cheer lights Michael and of course we have Tom as well our longest follower so yes that's everybody I wanted to um give a shout out to and I think that's the uh everything I wanted to cover off in the main show today I managed to make it through with my voice not being uh too badly blown out today the uh the Water definitely helps there as well is just ice water cool so this is the point in the video where you hopefully get a recommendation over here for a video um from our Channel and check that out that's as good as subscribing cuz uh obious the Youtube algorithm know that you like my content and you're binging it which is good um but this is the point in the video if you're watching on replay I'll say thank you so much for watching and I shall see you next time
Info
Channel: Kevin McAleer
Views: 1,721
Rating: undefined out of 5
Keywords: Adafruit, Big movie, Python, Raspberry Pi 4, Raspberry Pi 5, Raspberry pi, Raspberry pi projects, Thermal printer, Zoltar, adafruit projects, innovative tech, new raspberry pi projects, printer coding, python project, raspberry hacks, raspberry innovations, raspberry pi 5, raspberry pi project, raspberry pi projects, raspberry pi python, rpi 4, rpi 5, thermal printer, thermal printer python
Id: dWFgN_A_I1w
Channel Id: undefined
Length: 53min 44sec (3224 seconds)
Published: Mon May 06 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.