ATtiny167 / ATtiny87 Complete Programming Setup Guide plus Examples [Linux]

hello everybody today we will be looking at programming and eighty tiny one sixty seven and the first thing we are going to do is just going to get a simple led to blink we’re going to set this all up we’ll set it up on the computer and everything like that I’ll have two separate videos one for Linux and one for Windows so this if you don’t if this isn’t your operating system then you might find in the description the video for the other operating system if it is done at this time what we have here is we’re not going to be happy we’re not going to have all this setup you for example you won’t need this whole module over here but right now I just have a lot of stuff connected up but we won’t be doing all that we are simply going to upload a program so that we can do a simple little blink program and then we are going to look at something a little bit more complex such as powering this Adafruit neopixel now these chips are very small they are this small compared to my finger and they have 20 pins the this 18 2167 it has 20 pins 16 kilobytes of flash and it’s quite a powerful chip for how small it is so if you’re creating a project or something like that and you need something small and multiple pins then this may be the chip you want to use so what we have here is everything that you’re going to need is obviously a computer and then we’ll need a programmer in this case we are using the Arduino is P over a duo Malave now this works pretty much exactly the same using an Arduino Uno if you have that instead which most people will and the other thing you’re going to need is a cable for that and if you do not use the Arduino ISP programmer it may be a bit more calm complicated so I would advise to follow it this way at least at the start now we also will need a capacitor a a12 10uf capacitor and then to hold the chip we have this SOP 28 dip and you can see it just goes right into here you can pull this out by pushing down and then you can pull it out and put it back in alright so the first thing that we need to do is actually set up it so you can program the 80 tiny 167 so the chip over here that’s the 18 21 67 I have all the pins labeled and things like that now this is going to be on top of the SOI P adapter which goes onto the breadboard as I showed you in the previous part of this video and this is where we’re going to use the 1 to 10 you have capacitor that I was talking about earlier make sure that the positive side is going to reset and the negative side of the capacitor is going to ground the way you you know that is that the positive side is longer than the negative lead so that’s how you know which way to put the capacitor in there now the next thing is the actual reason that we use this capacitor is because sometimes when we’re uploading the sketch to the 89 167 or any chip for that matter sometimes there’s some sort of power issue and the whole Arduino Uno just randomly resets and this capacitor somehow fixes that issue now the next thing we want to do is actually power the 8021 67 and that can be done from the positive and negative from the uno or whatever arguing out a chip you’re using Arduino board you’re using so I’m going from the Phi down to the VCC on the 8020 167 and as well as the ground to the ground on the 167 and you could use this pin for ground but that’s already use so might as well just use this one now the next thing is connecting all these pins and now these are the pins that actually do the programming to the chip and all that type of stuff it it controls the chip so

from pin 31 or pin 13 goes to pin 8 and that’s because of the s CK that’s mainly what we’re trying to connect the SS CK from pin 13 to the s CK on the 801 67 so that’s the main thing that we’re connecting for that and then for pin 12 we’re connecting 12 to pin 3 on the chip and be sure that you have the chip oriented correctly there’ll be a little dot on the top left of the chip so that you know it’s oriented correctly now for pin 12 the main thing we’re connecting is the Miss so M is o master in slave out and then the next part is pin 11 and that will connect to n7 on the 80 2167 and the main thing for this one is mostly mo SI master out slave in and then finally pin 10 we are connecting up to pin 11 and the main reason we’re doing that or the reason we’re doing that is because of the reset pin on the 80 2167 that’s the main main reason why we’re going to these specific pins because they have those specific properties now the last thing is the actual LED lights now these aren’t necessary but it’s definitely useful in programming and it’s pretty simple to set up it goes along with the arduino isp program it’s part of the Arduino ISP program that shows you what’s going on so the nine on pin nine the LED make sure you have positive to the actual pin nine that’s the longer side of that LED and then the negative just to the negative and what I do is for like the ground and the power I usually on the on the breadboard put it to the long strips on the side so that we had get a full power rail of positive and negative so that we can easily connect these LEDs up to the negative rail on the breadboard for each of these so we’ve got pin nine eight and seven now the LED on pin nine shows that the programmer is actually running it shows that it’s on and working pin eight is an error led it it shows up when the sketch fails to upload or something like that and then pin seven will blink whenever it’s communicating with the 89 to 167 or the slave whatever you want to call it and by the way these pins are described in the Arduino ISP program which brings me to the next point we need to upload the Arduino ISP code on to the duma living before you put on the capacitor if whenever you’re programming the duma maleva itself or the uno whichever board you have the programmer what you’re using as a programmer you need to take off that capacitor and after you do that what you do to get to the the Arduino ISP is from file examples and you should have Arduino is be built in to Arduino the Arduino software and it will open up this and if you scroll down you can see it does have all these the pin setup right here and also down here for the most see miss of an s CK just in case you need to know that so that is what you need to upload to the Duma live a or you know whatever board you’re using just make sure that you put the board onto your correct one if it’s the uno do the uno if its doom alive a set it to do maleva make sure you have the right processor setup and the port and then just choose upload and that will upload on to your Arduino board and then you can use it as a programmer and after you upload it put that capacitor back on after you get the board and all the wires set up now we can move on to actually getting it so we can program it from the computer now when we going to file what we need to go into is preferences and then under additional

board manager now this is assuming that you have the latest Arduino you should have Arduino one point six point eight one point six point seven it should also work as well but point eight is the latest and what you want to do is go into this additional boards manager and enter in this URL and this will be in the description of the video so you don’t have to copy from this video now choose ok choose okay go into tools board board manager and then let it download the files and then go under contributed and you’ll see 280 tiny packages that you can install either this one or the eighty tiny core what you want to do is get the eighty tiny core and since mine is already installed I don’t need to install again but you just simply click on this and click the install button now after this install it is important that you do not Jews burn bootloader from this menu because this may cause your ad tiny 167 to be soft bricked until you fix it by adding a clock basically a constant clock rate on to the 167 this is due to some bug in this repository it’s using the wrong it’s setting the wrong fuses therefore causing the 167 to try and use an external clock instead of its internal clock now in order to get this right now when we when you buy the 80 tiny one 6m chip it does come with a 1 megahertz rate and this is not good enough this is this is not what you want when programming Arduino you’re going to have a lot of issues if you keep it at that rate for example if you do the blink programming program for one second it’s going to be either extremely too long for example like 5 seconds or extremely too short depending on your setting now to avoid this you actually do need to burn a different bootloader or set the fuses and set the fuses in order to do this we need to add compatibility for the 167 into the AVR dude config file so we need to add support for AVR dude if you don’t know what AVR dude is it’s a program that allows you to do various things on the AVR chips and what you need to do we need to go to this link and I will leave this in the description as well and what you want to do is just copy this part of his comment and what we need to do is add this on to some files what you need to do is go into either the user share arduino hardware tools AVR et Cie AVR config or slash home your user your username slash darden you know 15 packages arduino tools AVR dude 6.0.1 are there you know v /e TC + AVR dude comp either that or both so for example in your home folder you have you should have a dot a dot over you know 15 folder and this may be you may need to show hidden files as a setting in your file manager to get to this and then go into packages arduino tools are during AVR dude and then et Cie and then you get finally get to avrdude comp you can see ctrl L you can see the location so I’ll leave these two locations in the description and you also may need to use sudo if you have G edit on on Linux or

whatever text file editor you have you can use that for the slash for the slash user file you will need to use root so you can either type in su first or you can do sudo and then the command and I’m using G edit so we have G edit the location your password and then you can get into the file now when you get into the file just scroll all the way down to the bottom make sure that you have the file the the contents copied from this post that I had up so copy that content and simply add it to the very bottom of the file so if I copy this and paste it into here that’s all you needs to do but I already have it so I’m going to do ctrl Z to undo that as you can see it has code for the 167 as well as the 80 to 87 that’s because these chips are pretty much identical just some slight differences and what you want to do from there is save and after you’ve got that saved you can go on to the next step what we want to do is go to this link TC world link our 80 tiny core etc and what we want to do is download the a tiny 167 hex file so it’s empty 167 hex just press on that choose raw and it should go ahead and give you the raw file and then right click choose save as and just save that to your download now what you’re going to need to do is move that into the location that you have AVR dude now in Linux you should have AVR dude in slash home slash Michael or your user name slash dot artery no fifteen slash packages slash Arduino slash tools sascha AVR dude slash 6.0.1 – charter you know 5 slash bin it might be it might be slightly different maybe based on your version or something like that but this should be the correct location Linux so from your terminal you can go ahead and type in CD and the location and I’ll have this in the description as well first copy over the hex file into this folder so what you want to do is first of all let me check if I have the file already in here which I don’t so what you want to do is use the MV command or CP command and go to /home your username downloads and then empty one 67 dot hex and then space and then dot and that should move it to the current folder so if I do LS now I have the file now the next command is quite a bit long so I’m just going to copy and paste what it is is this AVR dude command you should make sure that you have AVR dude in your in the directory that you’re in and we can use that command which it actually already processed if you don’t want it to go automatically make sure you don’t have a character after make sure you don’t copy a character after the line of text which is the inter character but what it is is dot slash AVR dude – see a VR is PPT 167 – P and then the location for your device for your programming device which we’re using the Duma living and if you check the the Arduino software you can see that the port is slash dev slash TTY USB zero so that is why we are setting it to that – B this is the bond rate – you this is setting fuses the external extended fuse the high fuse

low fuse and we’re flashing the empty 167 hex file right here and what you do is press enter and it will run through this which I already did you got to make sure the chip is all connected up correctly now it is using 8 megahertz internal clock processor and that is that for this example it does use the /et see the I believe this uses one of these config files it might be the e TC config file or or the one in gardena 15 like I’m not exactly sure which config file date it uses but I did add one such a TC / AVR dude I did copy the configuration from the other file into Sasha ET z / AVR dude just in case so if you’re having any issues for example if it says I can’t find the configuration file or it can’t find T 167 then it’s just a configuration file issue and you need to either copy that text that we that we use for the 167 into the config file or do something else it should be pretty obvious so now that we have that setup I know this is a long process in it and it really is it was quite complicated to get stuff especially the first time so now that we have that set up we can go ahead and start in and setup the board so that we can upload the blink program and test that so here I’ve added an LED to pin 13 so on pin 13 and on the a tiny 167 that’s where we’re going to have the blinking LED what we want to do is go into the Arduino software go into file examples go under basic and choose blink set this to pin 13 which already changed you’ll need to change this number and this number and this number in order for it to Alton work and then what you want to do is go into tools and for the board go down and choose the eighty tiny x7 series in which this is what we installed earlier from the board manager now go into tools and then make sure that Bo D is disabled we don’t need that we need this on new style chip is the one 67 not the 87 and the clock is 8 megahertz internal and the port is such dev sus TTY USB and the programmer is Arduino as ISP so make sure it’s set to that or else you’ll have issues so what you want to do now is you can simply choose upload after you’ve got the LED on there it should upload pretty pretty easily and now you can see it running and it’s blinking now we are going to go into a bit more complicated example just so I can show you all these external libraries that will work for the H tiny 167 now the first thing is we’re going to test out the Adafruit neopixel library with an 88 if root neopixel 12 so what we’re going to do is go ahead and download this library from github comm slash Adafruit 2/8 a fruit on the ski underscore neopixel and this is going to be in the description as well once you have it downloaded it should be in your downloads folder what we want to do is go into the Arduino software Gunder sketch choose include library go to add dot zip library and then go into downloads and you should see the Adafruit neopixel library now just press on that and choose ok and now it says library added to your libraries check include library menu now go into file examples and under

the examples under under Adafruit neopixel choose strand test now this is just a simple program that tests the neopixels now we only need to change a couple of things like first open up the schematics and let me show you the setup real quick so here’s the updated diagram so what we’re using is pin 13 again and instead of the led we’re going to connect it to the neopixel ring the input of the neopixel ring not doing anything with the output that’s for adding extra neopixel strip some rings and then we’ll add a power add power from the 5 bolt rail and ground from the ground rail and then from the Strand test all we need to change is the pin number basically if you just change that to pin 13 that’s the pin we’re using the only other thing you need to do is change the number of neopixels to 12 and I was having issues at the very beginning but that may just have been because of the different settings that I set the clock settings – I was just having issues so I did change this to 400 instead of 800 but it seems to be working just fine with this setup now I’m just going to go ahead and compile this and it compiles just fine and then I’m going to upload it and it’s uploading so it compiles in uploads just fine now at the beginning of this video I did think I did think that this library was using more than it actually is I thought it was using some other libraries that weren’t going to eat weren’t going to work but it actually works fine with the 167 right off the box but if you if you did when you’re adding more components and adding more code you’re gonna run into some issues on the 80/20 167 most likely in that a lot of the just the standard libraries won’t work on it for example wire the wire library if I do pound include wire dot H and try to compile that it has an error compiling but if I did this from for example the Duma live a and then try to compile it it has no issues so that’s because there’s some incompatible libraries for the 167 and you may be asking why don’t you just try a tiny wire and I did try that and that also does not work on the 167 so we need to do is get a specialized set of libraries and you can get this from the digi stump Arduino page on their github and and the digit stump AVR in the libraries section you can see that there’s a bunch of libraries here including the wire library so if you want to use those and you’re probably going to use some of these if you’re going to be using the 167 go ahead and just download this and I’ve already done that and then from the Downloads folder just go ahead and extract it and go into the folder go into the AVR folder go into libraries and then just choose whichever libraries you want in this example I want to use the wire library so what I’m going to do is just copy this then just go into your home folder go into our Barrino arduino and then go into the libraries folder and then just go ahead and paste the wire library in there next thing you want to do is check the arduino software and you’re probably not you may need to restart the Arduino program but let’s just go ahead and see we’re going to change over to the 167 again and I’m going to try and compile it and it looks like it has compiled so successfully so it works just fine with the wire library included in this package of a bunch of

libraries now what this is the did you stumped Arduino they do have a product called the digi stump or the digi spark Pro v2 which uses the 80/20 167 which looks something like this which is a prototyping board that you can buy so this actually would be a more suitable thing for some people if they aren’t actually going into production and they just want something to do for fun and that works for that and so they developed a bunch of libraries that are compatible with the 80 tiny 167 since their board uses it so I that concludes this video I thank you all for watching I know it was a long video and it was a lot of different steps and all that and I apologize for that but there’s just no way to get around it so thank you all for watching I you’ve learned something or had fun watching if you like this type of stuff please subscribe