rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Wed May 07, 2014 9:13 pm

I see a few ways to program the ATtiny85 with the RPi directly, but what I've found doesn't allow you to use the Arduino IDE to do the programming/uploading, like you can with the ATmega328 on the Gertboard.

Can someone point me in the direction of information on how to configure the Arduino IDE and my Gertboard to work as an ISP for an ATtiny85?

Thanks
Rick
Last edited by rickseiden on Fri May 09, 2014 2:50 am, edited 1 time in total.
There are 10 types of people in this world. Those that understand binary, and those that don't.

User avatar
JRV
Posts: 270
Joined: Mon Apr 02, 2012 1:39 pm
Location: Minneapolis, MN

Re: ATtiny85 with Arduino IDE and Gertboard

Thu May 08, 2014 12:30 pm

I don't know if this will help, it's just a best guess.

The additions to the Arduino IDE for this programmer: https://www.sparkfun.com/products/11801
might work.
Look here: https://learn.sparkfun.com/tutorials/ti ... kup-guide/

rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

Re: ATtiny85 with Arduino IDE and Gertboard

Fri May 09, 2014 2:49 am

I figured it out, and it was relatively easy.

As a starting point, I'm going to assume that you have followed Gordon's instructions on getting the Arduino IDE running with the ATmega 328 on the Gertboard. You can find those instructions here.

Next, I'm going to turn to an Instructable to start hooking up the ATTiny85 to the Raspberry Pi. Follow the instructions in Step 2, but hook up pin 1 on the ATtiny85 to pin 24 on the Raspberry Pi. This gives the connections as follows:

Code: Select all

RPI pin 24 / GPIO  8 / Reset --> ATtiny85 pin 1
RPI pin  6 / Ground          --> ATtiny85 pin 4
RPI pin 19 / GPIO 10 / MOSI  --> ATtiny85 pin 5
RPI pin 21 / GPIO  9 / MISO  --> ATtiny85 pin 6
RPI pin 23 / GPIO 11 / SCLK  --> ATtiny85 pin 7
RPI pin  1 / Vcc             --> ATtiny85 pin 8
Now I turn the Arduino Playground, and download the Attiny 44/45/84/85 files. (Although, I include the ATtiny85 relevant text here, so you don't have to download them for the ATtiny85.)

Once they are downloaded, you want to use your favorite text editor, as sudo, to modify the boards.txt file (I use nano):

Code: Select all

cd /usr/share/arduino/hardware/arduino
sudo cp boards.txt boards.bkup
sudo nano boards.txt
That will make a backup of the current board configuration, and then bring it up in the nano editor. At the start of the file, paste the following text from the Arduino Playground files we downloaded earlier (note, I added the comment lines with the # signs to keep it consistent with the rest of the file):

Code: Select all

##############################################################

attiny85.name=ATtiny85 (internal 1 MHz clock)
attiny85.bootloader.low_fuses=0x62
attiny85.bootloader.high_fuses=0xdf
attiny85.bootloader.extended_fuses=0xff
attiny85.upload.maximum_size=8192
attiny85.build.mcu=attiny85
attiny85.build.f_cpu=1000000L
attiny85.build.core=arduino:arduino
attiny85.build.variant=tiny8

##############################################################

attiny85-8.name=ATtiny85 (internal 8 MHz clock)
attiny85-8.bootloader.low_fuses=0xe2
attiny85-8.bootloader.high_fuses=0xdf
attiny85-8.bootloader.extended_fuses=0xff
attiny85-8.upload.maximum_size=8192
attiny85-8.build.mcu=attiny85
attiny85-8.build.f_cpu=8000000L
attiny85-8.build.core=arduino:arduino
attiny85-8.build.variant=tiny8

##############################################################

Save and exit (Ctrl-O Ctrl-X).

Now we need to make a variant directory for the tiny8 we've specified above.

Code: Select all

cd variants
sudo mkdir tiny8
cd tiny8


A pins_arduino.h file is needed here:

Code: Select all

sudo nano pins_arduino.h
Paste in the following code:

Code: Select all

/*
  pins_arduino.c - pin definitions for the Arduino board
  Part of Arduino / Wiring Lite

  Copyright (c) 2005 David A. Mellis

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA

  $Id: pins_arduino.c 565 2009-03-25 10:50:00Z dmellis $

  Modified 28-08-2009 for attiny84 R.Wiersma
  Modified 09-10-2009 for attiny45 A.Saporetti
*/

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

// ATMEL ATTINY45 / ARDUINO
//
//                  +-\/-+
// Ain0 (D 5) PB5  1|    |8  Vcc
// Ain3 (D 3) PB3  2|    |7  PB2 (D 2)  Ain1
// Ain2 (D 4) PB4  3|    |6  PB1 (D 1) pwm1
//            GND  4|    |5  PB0 (D 0) pwm0
//                  +----+

static const uint8_t A0 = 6;
static const uint8_t A1 = 7;
static const uint8_t A2 = 8;
static const uint8_t A3 = 9;

#define digitalPinToPCICR(p)    ( ((p) >= 0 && (p) <= 4) ? (&GIMSK) : ((uint8_t *)0) )
#define digitalPinToPCICRbit(p) ( PCIE )
#define digitalPinToPCMSK(p)    ( ((p) <= 4) ? (&PCMSK) : ((uint8_t *)0) )
#define digitalPinToPCMSKbit(p) ( (p) )

#define analogPinToChannel(p)   ( (p) < 6 ? (p) : (p) - 6 )

#ifdef ARDUINO_MAIN

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing) tiny45 only port B 
const uint16_t PROGMEM port_to_mode_PGM[] = {
	NOT_A_PORT,
	NOT_A_PORT,
	(uint16_t) &DDRB,
};

const uint16_t PROGMEM port_to_output_PGM[] = {
	NOT_A_PORT,
	NOT_A_PORT,
	(uint16_t) &PORTB,
};

const uint16_t PROGMEM port_to_input_PGM[] = {
	NOT_A_PIN,
	NOT_A_PIN,
	(uint16_t) &PINB,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
	PB, /* 0 */
	PB,
	PB,
	PB,
	PB, 
	PB, // 5
	PB, // A0
	PB,
	PB,
	PB, // A4

};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
	_BV(0), /* 0, port B */
	_BV(1),
	_BV(2),
	_BV(3), /* 3 port B */
	_BV(4),
	_BV(5),
	_BV(5),
	_BV(2),
	_BV(4),
	_BV(3),
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
	TIMER0A, /* OC0A */
	TIMER0B,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
	NOT_ON_TIMER,
};

#endif

#endif
Save and exit.

That's it. You should now be able to write code in the Arduino IDE on the Raspberry Pi, and have it upload to the ATtiny85. Remember that you have to go to Tools>Board>ATtiny85 (internal 1 MHz clock), thenTools>Programmer>Raspberry Pi GPIO to setup the board and programmer, then you have to use File>Upload Using Programmer to send your sketch to the ATtiny85.

I hope this helps someone out in the future!
Rick
There are 10 types of people in this world. Those that understand binary, and those that don't.

Pranav98k
Posts: 4
Joined: Wed May 13, 2015 1:44 pm

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Wed May 13, 2015 1:49 pm

i am getting this error while uploading the sketch
Blink.cpp:10:21: fatal error: Arduino.h: No such file or directory
compilation terminated.
please help
thanks in advance
pranav

rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Wed May 13, 2015 2:27 pm

Pranav98k wrote:i am getting this error while uploading the sketch
Blink.cpp:10:21: fatal error: Arduino.h: No such file or directory
compilation terminated.
please help
thanks in advance
pranav
It's been a long time since I looked at this. It looks like you're getting this error because it can't find the Arduino.h file in an expected directory. Unfortunately, I don't know how to solve this issue, as I don't know what directory it's looking for. It would be helpful if they changed the error message to include the path.

Good Luck
Rick
There are 10 types of people in this world. Those that understand binary, and those that don't.

Pranav98k
Posts: 4
Joined: Wed May 13, 2015 1:44 pm

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Wed May 13, 2015 7:18 pm

Unfortunately I was not able to find Raspberry pi gpio in the programmer list, I guess I have not followed the steps properly :(

rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Wed May 13, 2015 8:05 pm

Pranav98k wrote:Unfortunately I was not able to find Raspberry pi gpio in the programmer list, I guess I have not followed the steps properly :(
You have to go through the steps that Gordon gives on getting the Raspberry Pi to run the Arduino IDE with the Girtboard. The instructions are linked at the end of the second line of my original message.
There are 10 types of people in this world. Those that understand binary, and those that don't.

Pranav98k
Posts: 4
Joined: Wed May 13, 2015 1:44 pm

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Thu May 14, 2015 6:50 am

Actually I don't have a gertboard, I basically wanted to use arduino uno as isp and then program attiny on Raspberry pi 2

rickseiden
Posts: 411
Joined: Thu Aug 02, 2012 12:21 pm
Location: Buffalo, NY, USA

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Thu May 14, 2015 5:16 pm

Pranav98k wrote:Actually I don't have a gertboard, I basically wanted to use arduino uno as isp and then program attiny on Raspberry pi 2
You're in unexplored territory here, I think. But if you're talking about running the Arduino IDE on the Raspberry Pi, and using the Arduino Uno as a programmer to program the Attiny, then you might not be too far off. You should be able to do it by downloading the files for the Attiny, and then using the Arduino as a programmer normally.

Code: Select all

Uno pin 10  / Reset  --> ATtiny85 pin 1
Uno pin GND / Ground --> ATtiny85 pin 4
Uno pin 11  / MOSI   --> ATtiny85 pin 5
Uno pin 12  / MISO   --> ATtiny85 pin 6
Uno pin 13  / SCLK   --> ATtiny85 pin 7
Uno pin 5v  / Vcc    --> ATtiny85 pin 8
I have not tried this, so I can't help you trouble shoot, but it should, in theory, work.

Remember to choose the Arduino Uno as the programmer.

Good Luck
There are 10 types of people in this world. Those that understand binary, and those that don't.

Pranav98k
Posts: 4
Joined: Wed May 13, 2015 1:44 pm

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Fri May 15, 2015 4:25 am

Thanks rick I'll try those codes if I face any problem I'll let you know, I am new to these things and I am still 16 so I got to learn many things

jackthom41
Posts: 1
Joined: Sat Nov 17, 2018 4:53 am

Re: ATtiny85 with Arduino IDE and Gertboard [SOLVED]

Sat Nov 17, 2018 4:57 am

Hi,

I am working on a similar project but I am unable to interface ATtiny85 with Raspberry Pi. I have also tried above code but no one's working. Can someone, help me out in the right direction.

Thanks.

Return to “HATs and other add-ons”