Skip to content
Giovanni Blu Mitolo edited this page Nov 6, 2017 · 30 revisions

AVR ATtiny microcontroller family is a really interesting and compact platform supported by PJON Arduino compatible implementation.

How to program ATtiny 45/85

You physically need at least one ATtiny microcontroller, a breadboard, some jumpers and an Arduino duemilanove / Uno used as an Arduino ISP programmer. Follow High-Low Tech tutorial by David Mellis and get the last version of the attiny repository.

Use PJON with ATtiny45/85 with external oscillator

Because of the internal clock's lack of precision, with some ATtiny85 in particular, low communication performance can be detected; extended tests proven the ATtiny internal clock to be extremely inaccurate (timing inconsistency between two identical ATtiny85 can be detected). Here is an example how it works with external 16 MHz oscillator.

image

Avoid using the packet handler, or the use update or send functions, use only send_packet or send_packet_blocking along with receive instead. Consider defining PJON_MAX_PACKETS with a value of 0 to free memory from the unused packet buffer and define PJON_PACKET_MAX_LENGTH with a value fitting your application requirements:

This sketch demonstrates continuous data transmission from an Arduino to an ATtiny84/84A/85, Arduino blinks if an acknowledgment from ATtiny is received.

#include <PJON.h>
PJON<SoftwareBitBang> bus(1); // <Strategy name> bus(selected device id)

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  bus.strategy.set_pin(12);
  bus.begin();
}

void loop() {  
  if(bus.send_packet_blocking(2, "B",1) == PJON_ACK) {
    digitalWrite(13, HIGH);
    delay(10);
    digitalWrite(13, LOW);
    delay(100);
  }
};

This is the sketch for ATtiny85:

// Max 10 characters packet (including overhead)
#define PJON_PACKET_MAX_LENGTH 10 
// Avoid using packet buffer
#define PJON_MAX_PACKETS        0
#include <PJON.h>
// <Strategy name> bus(selected device id)
PJON<SoftwareBitBang> bus(2);
 
void setup() {
  bus.strategy.set_pin(2);
  bus.begin();
}

void loop() {
  bus.receive();
};

If all works properly you should see the Arduino Duemilanove/Uno/Nano blinking quickly and regularly.