Tuesday, 26 August 2014

ArduinoISP – avrdude

For those of us that have been receiving the avrdude error “” when uploading sketches using the Arduino Uno as an ISP, I have found the following modified version of the ArduinoISP.ino.

I’ve had a look through the sketch and it would appear that the main difference between the two is the inclusion of the SPI library in the header and then later in the sketch setup, the SPI library is included.

Unfortunately, the version number in the ino file is still 04m3, it would have been nice to change that ;) but, woteva.

I would also like to change the pin assignment for the LED indicator lights as there is a lot of cramping around pins 13 – 10 … it would be nice if the LED pins were outside of this area. I’m going to change the pins to

// 3: Heartbeat   - shows the programmer is running
// 2: Error       - Lights up if something goes wrong (use red if that makes sense)
// 1: Programming - In communication with the slave

#define LED_HB    3
#define LED_ERR   2
#define LED_PMODE 1

Pin 3 on the Arduino is PWM so it should still work for doing the heartbeat pulse, hopefully it doesn’t conflict with something I’ve missed.


The above Fritzing diagram shows the wiring layout using pins 3, 2, and 1 for the LED indicators and assumes that the sketch has been changed accordingly.

I’ll make the changes tonight and try to reload the blink sketch to the ATTiny85 and see if there are still any avrdude errors appearing in the IDE.

Okay, so I’ve tried it with 3, 2, 1 and it appears that 1 is interfering with TX, so I’ve changed it to 3, 2, 4 instead, now the new ArduinoISP sketch has loaded successfully, it’s on to loading the blink sketch onto the ATTiny85.

No … that didn’t work …


back to 9, 8, 7 for the monitoring pins. Still a no go … so it’s back to the original ArduinoISP.ino and just deal with getting the avrdude error … how disappointing … I’ll work on that more later.

UPDATE: I’ve looked into this problem some more and it appears that there may be a fix to the avrdude.conf that could resolve the issue. Check out my article AVRDUDE PAGEL and BS2 for more information. I will be updating that article when I have tested the suggested fix.

Arduino as ISP for ATTiny85

Following on from my previous post (ATTiny85 with Arduino Uno as ISP), I thought that I would have a crack at explaining the method of using the Arduino as an ISP for an ATTiny85.

The first step that I missed, the one that I had a lot of trouble finding, was configuring the Arduino UNO as an Inline Serial Programmer. This is really quite an easy step to complete and doesn’t require anything other than the Arduino UNO, the USB connection to your computer and the IDE.

Connect the UNO to the computer using the USB cable and launch the Arduino IDE.

When the IDE is open, click File > Examples > ArduinoISP. This sketch comes with the IDE, so there isn’t anything to download (so long as you already have the IDE).

In the comment block, the sketch contains the information that you need to connect a device serially to program it.

// This sketch turns the Arduino into a AVRISP
// using the following arduino pins:
// pin name:    not-mega:         mega(1280 and 2560)
// slave reset: 10:               53
// MOSI:        11:               51
// MISO:        12:               50
// SCK:         13:               52

It also gives you some other information so that you can display the progress of the sketch load from the Arduino.

// Put an LED (with resistor) on the following pins:
// 9: Heartbeat   - shows the programmer is running
// 8: Error       - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave

In addition to the connections from the Arduino to the ATTiny, it really does make sense to add in a couple of LED and resistors to show that the communication between the two is happening and the real time results. I for one am going to go back to my simple ISP PCB design and add in these LED. This is really something that I should have been doing all along.

When the sketch is loaded onto your Arduino, the next step is to connect your ATTiny85. I have simplified the connection diagram here.


Connect the ATTiny85 to your Arduino UNO according to the diagram and then connect the LED to the Arduino for real time monitoring of the UNO.

Load the blink sketch into the IDE and change the Board (Tools > Board > ATtiny85 with 1 MHz clock).

The Programmer should be Arduino as ISP (Tools > Programmer > Arduino as ISP), so change that too.

The example Blink sketch has pin 13 configured for the LED. There isn’t a pin 13 on  the ATTiny85, so you will need to change it to something else. For example, Pin 5 on the ATTiny85 maps to PB0, change the sketch to use PB0 instead:

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 0;

Save the sketch (File > Save) and give it a filename that indicates that it is for ATTiny85.

At this point, you could connect an LED to pin 5 of the ATTiny85. Connect the long leg (the Anode) of the LED to pin 5 and then the short leg (Cathode) to a resistor, then the other end of the resistor to pin 4 of the ATTiny85 (Ground).

So far, we have programmed the Arduino UNO as an ISP and connected the ATTiny85 to our ISP. We have also connected the load to the ATTiny85 so that when we’re done, the LED will blink.

Right … upload the sketch (File > Upload Using Programmer or Control-Shift-U). You should see the LED on pin 9 and 7 of the Arduino flashing and then … the LED attached to pin 5 (PB0) of the ATTiny85 will start blinking.

You can expect to get the avrdude error that everyone tells you is OK – “avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85”. At this stage, that kinda means that it all went OK and your sketch is loaded … the proof should be that the LED is blinking on Pin 5 (PB0).

Job Done.

The ArduinoISP sketch handles the reset function of the Arduino, so there is no need to connect a resistor or capacitor across the Arduino RESET pin.

I plan to return to the avrdude error, I’m sure that this is just a configuration issue with boards.txt, but we’ll see.

Hopefully, you will find this article and follow it rather than the plethora of other articles that were probably right for previous versions of IDE/Arduino. Good luck, and watch out for those hungry, hungry hippos.

Monday, 25 August 2014

ATTiny85 with Arduino Uno as ICSP

Well, that was frustrating. I received 5 bright shiny new ATTiny85 from eBay while I was away on a business trip so I couldn’t play with them straight away. That was one minor piece of irritation.

I returned to my apartment where I have all of my electronics gear and got ready to play with the ATTiny85 (I also received 5 x ATTiny84 and 2 x ATMega328P … so there are lots of new toys to play with) and started to play.

I followed a couple of tutorials online and connected my Arduino Uno to my ATTiny85 and then attempted to load the blink sketch (the “Hello World” of physical programming), only to receive the cryptic and unhelpful “avrdude stk500_getsync() not in sync resp=0x00” message in the IDE.

Of course, I searched the Interweb for solutions to this problem but there wasn’t much that was helpful. Many opinions about the wrong USB driver, the chip inserted incorrectly, the presence (and absence) of a capacitor to expiate the Reset on the Uno … all useful for the specific problems that others were facing, I guess. I then stumbled upon an instructable by mr_mac3 (Turn Your Arduino Into and ISP) where the author, very helpfully, includes the step that I was missing. The step, you may ask? Which Step? Well, dear reader, the step where you make your Arduino an ISP (or ICSP if you want).

The step that I was missing was simply that, before you can program the ATTiny85 from the Arduino UNO, you have to load the Arduino ISP sketch onto the Arduino UNO. Holy Schemolly, what an ass basket! Once this step was completed, the Arduino UNO worked as an ICSP.

I had a couple of other issues, like rather than routing the power and ground via the +/- rails on the prototype board, I ran them straight to the correct pins of the ATTiny85 (that also made a difference). With the UNO that I’m using and the version of the IDE, there wasn’t any need to bypass the reset … that happens in the Arduino ISP sketch.



After the Arduino ISP sketch was loaded, I loaded the new sketch (the example Blink)I changed the Board to ATTiny85 with Internal 1 MHz clock and left the programmer on AVR ISP and changed the LED pin to 0. Next, I compiled the sketch and uploaded the sketch to the ATTiny85. I received the obligatory “avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85” message that I happily ignored and then connected my 2x2 SMD LED to ground and to the ATTiny85 pin 0 and, presto … blinky goodness was found.

Next, I loaded my sinusoidal fade sketch (modified from another tutorial) and ran it on the ATTiny85 … again, success! Woot!

Now that I have succeeded in loading a sketch onto the ATTiny85 from the Arduino UNO it’s on to the PCB version of the rats nest.

Tuesday, 12 August 2014

Voltage Regulator – Breadboard

Originally, I intended to have two separate projects for voltage regulation (9 to 5V and another planned for 9 to 3.3V), but it turns out that there is very little difference between a circuit for 5V and 3.3V power regulation. The only practical difference is that, if you use an LM7805 transistor you will end up with 5V, or if you use aUA78M33C, that you will end up with 3.3V.

I bought the LM7805 from eBay, and the UA78M33C were purchased from element14. I am fairly happy with the 3.3V, however, it cost more for postage than it did for the transistors (more than $12 AUD while the transistors only cost $8 for 10 of them). Nevertheless, I have them and I’m OK with that.

I used the example breadboard for a power regulator that comes with the Fritzing application, you can go to their website if you want to see the layout (download it, it’s free).


There are 2 x 100nF capacitors, the Voltage Regulator and some jumpers, this is a very straight forward circuit, all that is happening is that voltage goes in through input (1) and comes out through output voltage (3). The capacitors are there to smooth the flow. I inadvertently used 100µF rather than 100nF, resulting in a lower output voltage (you can see that later). The circuit only ran for a couple of minutes so I wasn’t able to observe the longer term effects of using the wrong capacitance on the V-Reg.


I connected the circuit to a 9V battery and measured the output using my multimeter set to 20V.

Here is the multimeter when the circuit is not powered.

Multimeter - No Power

And here we are with the circuit powered.

Multimeter - Powered - LM7805

The voltage fluctuated between 4.96 and 4.97V, I expect that the variation and the <5V result was a consequence of the wrong capacitors.

When the power is disconnected, the delivered voltage bleeds out (as it is stored in the two capacitors). After 3 seconds, the output is 0.09V.

Multimeter - Powering Down - LM7805

I replaced the LM7805 with another from the same batch and got a slightly different result.

Multimeter - Powered - LM7805 - 02

But still in the range.

Then, I replaced the LM7805 with the UA78M33C, powered it up and measured the output again.

Multimeter - Powered - UA78M33C

When I build the circuit in anger, I’ll be using the correct capacitor (tee hee). Overall, this was a very simple experiment and it provides me with the circuit that I’ll need to power the ATTiny84 and ATTiny85 circuits that I’ll be building. The goal is to have a ready regulator circuit that will feed the three ATTiny8x circuits further up the food chain.

Well … actually … I retested with 100nF (0.1µF) and the results were the same. I guess the variation may be in the quality of the capacitor? Either way, I calculate that to be within approximately 1% of the target value (actually 0.6 – 0.8% for the 5V and 0.909% for the 3.3V), hopefully that will be sufficient.

Monday, 11 August 2014

ATTiny85 ICSP Arduino Shield – Plan


Following on from my plans with the ATTiny84 chip, I’ve also ordered some ATTiny85 chips from eBay.

Like the ATTiny84, building an ICSP is going to be useful for programming the chip (ATTiny84 ICSP).

The ATTiny85 has 8 pins, rather than the princely sum of 14 pins with the ATTiny84.


The location of the VCC, MOSI, MISO, Reset, Clock and GND pins are almost completely different from the ATTiny84, so the layout of a ICSP for this chip is also … entirely different. There are some … unfortunate … crossing over of pins that makes this design a little more challenging.

I’m using a couple of 0Ω resistors as jumpers in this design, I could have just used some more jumpers, but, what the hell.

Fritzing ATTiny85 ICSP_pcb

I will certainly be bread-boarding this before I commit to making a PCB for it, but, so far, here is the plan based on the pin-out that I have copied from the ATMEL ATTiny85 data sheet.

When you compare the ATTiny85 pins with the ATTiny84 pins:


There are a few challenges, but it is still similar enough that it isn’t completely incomprehensible.

Now that I’ve received the chips … I just have to wait for a fortnight before I can have a good play (the tyranny of working in a different state from where I live … like THAT isn’t becoming a serious pain in the arse).

Paypal Donations

Donations to help me to keep up the lunacy are greatly appreciated, but NOT mandatory.