 Welcome to the show, it's me JP and it's time once again for JP's product pick of the week. Here we are. Are you ready? I'm ready. Let's pop that little thing on there and get ready to head on over to the product page for this week's product pick if you want to get a huge discount on a tremendous little gizmo. So what I'm going to do is send you there, head over to, I can't be wrong if I point that way. Head over to that QR code right there or this URL it's Adafruit.com slash product slash 4648 and that is going to take you right here to this very product page where if I refresh right now you're going to see that we have this on sale for 50% off which is tremendous. So what I'm going to do right now in fact, let's jump back here so if you have a chance to go go there and you can watch the video from inside the product page that way you'll know what's going on and you'll be surrounded by product. So buy some right that's what keeps the lights on here at Adafruit Industries we appreciate it but I'm jumping the gun. What is this thing anyway? Well what I'm going to do is I'm going to start off and have Lady Ada explain it to us in her new new new video then I'm going to grab one out of my cabinet of mysteries and wonders back there you can see that right there and then I'm going to do a little demo and talk about it so please take it away Lady Ada. The PCF 8591 it's a quad ADC and a DAC is a very interesting chip not exactly sure what this was designed for probably like a car radio though because every time I'm like what is this for it's always like a radio you know playback system for cars or something but you get four analog inputs 8 bit and one analog output which is unusual usually don't get both and it's all controlled over I squared C it's a really simple chip we've got Python and Arduino code and this would be really handy I think you know the demo here with a feather but I think it should be really great for use with again single board computers like a Raspberry Pi or a Jetson or a Coral or any of these other Linux boards that have I squared C and you just want to add some like potentiometers or like analog simple analog sensors and you don't want to get like a more expensive ADC and maybe you want a DAC for some reason you want to like control a gauge or a bias voltage it's only 8 bits but really that's good enough for many projects like volume control or contrast control or whatever so here I've got you know three potentiometers and as I twist them you can see they range from zero all the way to the end to 255 so the three inputs and of course there's one more input I don't have connected and it comes in a STEM a QT format so you can just plug it in you can plug it into that quick pie hat we showed earlier and works from three to five volts so it's a great way to just add you know very simple ADC inputs to your I squared T capable board all right well I I want to check it out hang on one second let me go grab one out of the cabinet you write back all right well that was risky but here I am I'm back I made it thanks Lars so what we've got this week it is the PCF 8591 and it is an 8 bit ADC and 8 bit DAC on a board with STEM a QT so what's this good for why do we want this well a lot of the times when you're doing microcontroller projects or particularly single board computer projects you'd like some simple input from a fader or a knob so a slide potentiometer or a rotary potentiometer so we call them angular potentiometer or other things like touch interfaces some of those soft pots things like that and you don't always get that many analog inputs on a microcontroller sometimes it's limited to you two or three if it's a smaller board with fewer the pins broken out and one thing you've probably noticed if you've done any work on Raspberry Pi projects is yet you generally have zero analog inputs there's a lot of GPIO for digital inputs and outputs but you don't have any analog so here's what you do you plug this in so this board here has the STEM a QT breakout on it so it's the spark fun quick compatible I squared C little itty bitty connector that we can use to plug that in to your Raspberry Pi now you can either do that with a sort of breakout cable or what I'm going to show you here and switch to my down shooter and what you'll see is that I have a cyber deck see the front there it's a cyber deck I've got a cyber deck plugged into the GPIO pins of this Raspberry Pi 400 so this Raspberry Pi has its normal breakouts there I can't move it too well without probably breaking everything but those breakouts are a little hard to get to so we have this new cyber deck product and actually I'll show you a product page for that minute that gives us the ability to plug in any of the normal Pi hats or bonnets at a jaunty 30 degree angle it can really only be described as jaunty I promise you I've tried other things and it doesn't work you can't say it this also gives us a couple of STEM a QT breakouts and STEM a breakouts which are the three pin larger JST pH so that we can plug in things like neopixel strips or other three wire devices and what I've done here is I've plugged this over I squared C into our PCF 8591 now what I have running into this board are four potentiometers so I'm using the ground voltage and then four separate analog input pins and then I've made a little demo here so what you'll see this this should be still running let's see my plotter is running yes it is okay so you can see here what I've set up on screen is this Raspberry Pi is running a little Python program that uses the circuit Python library for this board so it's dead simple I'll show you the code in a second and it reads all four of the analog inputs it's essentially reading 0 to 255 so these are 8-bit ADCs they're not super high resolution but for a lot of the things I want to use them for such as synthesizers and MIDI that's great that's enough resolution that's actually double the resolution that MIDI CC usually uses and you can see here I've got it controlling the hue of these neopixels or RGB LEDs on this very cool unicorn hat HD from Pimeroni that I've got plugged in you can see here it's got a cute little diffuser on there those are the raw pixels and I've decided to use all of these knobs because why not they're here so what I'm doing is tracking the first knob here I'm calling it knob zero for the X position and you can see on my angle this up a little you can see on Mu here I'm using the plotter right inside of Mu this is running on the Raspberry Pi and now I can control the vertical pixel line here with this second knob third one we saw that's changing the hue just sweeping through all of the hue angles and then last one is brightness so you'll find I can get that pretty zorching bright there or drop it drop it down way way low or all the way off and as I do this you'll see this is spitting out these values here some of them I've sort of flipped and normalized into ranges like negative one to positive one or zero to 255 whatever makes sense for in this case zero to 15 which is the number of rows that I have and columns so let's take a look how does this work I'm gonna switch back over now to Adam this is the code that's running on the Raspberry Pi 400 it's not running on a micro controller because I'm not using a micro controller let's take a look let me jump jump down there so we can still see that because I think that's lovely looking and what I'm doing in Adam here you can see I'm importing the time library so that we can do delays if we need to board which gives us the GPIO pin layout and I squared C and all that good stuff that's on the Raspberry Pi and then the Unicorn Hat HD library from Pimeroni I set up the the Pimeroni board to light up set its rotation because you can change what what's considered sort of up and down and left and right and then I'm importing this PCF 8591 library giving it the name PCF make it easy to work with and it is being set up as a analog in on I squared C there's the board getting set up this is I squared C being set up and then I have these four inputs that I get to use right off of the ADC so you can see here I'm using the analog in's they're four of them not using the DAC there's a there's an analog out one one analog out you could you could find a use for that I'm sure I just am not in this case but that might be useful if you have something like a low-frequency oscillator or other analog output it's not gonna be high super high resolution and then here's what's going on in the code it's actually fairly simple what I do is I assign the raw value read of one of these inputs the PCF in to in this case to this variable color raw value and then I do some manipulations to make that useful the way I'm gonna use it so I'm subtracting it from one to kind of reverse that I actually hooked up my ground and VCC backwards so all these potentiometers I kind of had to flip their their left and right to be down and up and then I am dividing that by its top range this is actually read as a 16 bit internally the library casts this as 16 bit even though these are 8 bit so if you watch them closely I just realized this morning you'll see those values those raw values will jump in chunks of 255 or 256 the setup is the same for the next knob and then these are being divided by 4096 which gives me 0 through 15 which is how I want to array the the pixels and lines in order to print this on the Moo plotter again you can see here as I as I adjust those you'll see that that plotter doing its thing there we go oh yeah it's a nice nice blue bright as you see the values change on that plotter it's because I have created this print statement which sets them all into this tuple and that's what the plotter in Moo is looking for is anything you want to show up on the plotter you put in a print statement with a couple of parentheses around it and it will show up the unicorn hat gets cleared then I set the range for the pixels to fire off from the what's going to be considered the column pixel and the row pixel and then we set the center pixel to black I just didn't didn't want that crossing pixel I just wanted that to be a little black spot there so that's what this line here does is just sets it to zero zero zero the brightness is changed anytime we're changing that brightness value it's just kind of continuously all this is running so fast on the Raspberry Pi that I don't need to have the code be very efficient it runs great and then lastly once all those things have been set up for a given cycle unicorn hat show sort of blitz that all to the screen we take a little pause just so we don't flood things and then that's it if there's an error it will it will allow me to control C out cleanly so that's why it has this key interrupt turns off the unicorn hat HD so if I go go back full screen where are you full screen there you are there we go so you can see oh yeah Todd in the comments said that he likes the hacker style monitor so I had a bear 10 inch HDMI IPS display that I've built this into a few different projects but it was sitting out it was in a typewriter case at one point but I pulled it out so I built this little maker beam sort of like a skinny little version of 8020 I built this little frame for it and hooked it up to there so that it holds the the HDMI controller board the little control panel there I strapped some speakers to the sides and it's nice and small and I can kind of it's lightweight I can kind of stick it where I need to and get it out of the way so there if we take a look back at there there is our board I'm gonna do a little focus refocus on this bear with me it's a little better can't get it too close now it's way out of focus hold on hold it was there there goes that's close so here you can see what I've done this board has the analog outs as well as the one analog out the four analog ends VCC ground on the top bottom these are the I squared C pins which I'm actually not using I just used it for mechanically soldering this to the board I'm using this little cable right here for the for the connection to the board the either the microcontroller or the single board computer that you're using and then I have these just kind of hand wired I just used hookup wire and wired that up so all of those are sharing a ground all those are sharing the voltage and then they're running to the four analog in pins to read and this is actually some of this cute little perf board that we started selling not too long ago in the Adafruit store I like the look of it it's kind of got a nice look it's clean no logos on it on this side it's black cool looking and it has M2 hole so you need some pretty tiny screws if you want to attach that to anything I just put some through there to act as sort of standoffs and that's it now one of the neat things about this I'm gonna I'm gonna go ahead and cancel that stop that from running there one of the neat things here is that we can unplug this board and this is portable this has no microcontroller associated with it has no particular single board computer associated with it's just I squared C over these stem of QT connectors so I can plug that into name your micro controller if you have something that you want to add for analog in's to and that one analog out this is it this is very simple you could even do a custom PCB for it if you wanted but I thought keep it lean solder this down I'm not I didn't put a socket on here I kept this lean by soldering this to the board I soldered these potentiometers down so this is a little hey I need for analog in's just grab this you can make a few of these you can sort of do this sort of design with a lot of our breakout boards if you like and it makes it makes it very convenient to prototype stuff so I can plug that back in and it's gonna restart my Raspberry Pi it was not happy about me hot hot plugging that in that's a bummer I wonder if I was shorting it holding the backside of it so we'll give that a moment to restart there I'll see how fast how fast this this Raspberry Pi boots and I will relaunch the program just so you can see how we call that you can also SSH into the Pi from another device and launch it but I I'm not on the same Wi-Fi with it on this computer so that's that's not straightforward so let's see when this wakes up alright let's run Mu and it even left that open for me thanks Mu can open up the plotter here hit run on our code and we're up and running again so really fun I I'm enjoying doing some of this development on the Raspberry Pi a lot of possibilities there and I'm also really loving this the cyber deck for adding this little light show here and giving me the I squared C stem of QT ports it actually is what inspired me to to build this frame and in a sort of cyber punky way so there you go let's see before I forget let me show you again here is the QR code that will get you right to that product page 4648 if you head on over there you're gonna get a lovely 50% off a maximum of 10 of them one thing I think lady Aida mentioned it in her video and I'll reiterate you can use the little jumpers on the back of this to pick addresses I squared C addresses and there are four different addresses available which means that you can hook up up to 32 you're sorry eight there are eight addresses available so you can hook up to eight of these am I right with that I think that's right yeah and you can have 32 analog inputs and eight analog outputs all on one machine you just wire them from board to board with some little short stem of QT cables if you want and now you're adding some serious analog in to a project that could use something tiny this could be running on a QT Pi or a Pico or Trinket whatever you want that has I squared C should be able to drive this and read a whole bunch of analog inputs which is really cool the product page let's jump over there for a second mention this before this will give you a little bit info about the board and a convenient add to cart button but if we click on the learn guide link that's on that page this will take you all through the pinouts of the board how to use it with Arduino we have a very convenient Arduino library how to use it in Python like I am here right on this on this Raspberry Pi single board computer or in circuit Python on any of the hundred plus circuit Python compatible microcontrollers out there and if you take a look through this info get down to the downloads page there's a link there that'll take you to the data sheet for this chip this is the PCF 8951 chip you can read all about it check out some of the operating supply voltage how it works sample rates what the what the data structure is on it you can find out all of those specifications right here on the on the datasheet they don't even mention usually I go here and find out okay what do they think this board is for I think they are real vague and say it gives you for analog input someone output over I squared C good luck you decide what you want to use it for but I like Lady Aida's theory that yeah when whenever you have a car stereo these days there's a there's a need for two or four knobs to control some stuff and so this type of chip will give you that analog in that you can then run into your digital microcontroller to do the rest all right well hey any questions in the in the chat let me know I can pull this I'm gonna pull that board off of there again and I can show you this up close someone mentioned something about the the wiring on the board let's see give you that down shooter and now let me try to refocus there we go yeah so there's the there's the board so this is a perf board it does not have any connections it's just places to solder stuff but wiring is up to you there's it's not like a breadboard or a perma proto board so or a strip board you just decide what you're soldering what to so that's that's the diagram actually have have put I put this together first in fritzing I made a little diagram for myself I can share that if anyone's interested and these are some 10k pots with some cute little knobs grippy little knobs on them that make it look nice and easily identifiable I say it's easy there we go get that back on there and there's the chip itself PCF 8591 8 bit ADC and DAC so I think that's gonna do for today let me know if you have any other questions Susan says the unicorn hat was exactly I was looking for the other day kept searching for matrix now I got it in my cart oh excellent yeah that is a cool little board there's there's a few variations on these unicorn hats and they're nice to work with a lot of example code up on Pimerote that you can use to use it with circuit Python and probably Arduino as well but I've just used it on circuit Python mmm all right well sorry I didn't have any peanuts but that's gonna do it for today that is my product pick of the week it is the PCF 8591 8 bit ADC and DAC in STEM a QT format and I'll sit that on my STEM a QT board of goodness is actually the 28th episode of this show that we've done here I have 29 things up here because I doubled them up one time and through the the pie in there the or the Pico rather in there and I probably should have thrown the cyberdeck on on the wall too but it's kind of hooked up to something right now so I can't but I'll maybe I'll look at that a little closer another time so I think that's gonna do it for today thank you all for stopping by head on over to this URL to get to this page and you can get 50% off right now until the end of this show you can get a limit of 10 so if you have big big analog input plans spend $30 and 25 cents to have that math right and get yourself 10 of these boards why not and that will that will give you tremendous possibilities for adding analog input to your projects that's gonna do it thank you so much I'm John Park this has been JP's product pick of the week and I will see you next time