Programming Attiny45 with Uno. Problems finding good information.

Thanks for doing my tech support for me, Pert!

My hope is that I'll be able to do a release this weekend - it's been a while.

I'll check the code again. Based upon the sketch, would you agree the ATtiny45 should be able to handle it? Is it possible that I'm declaring a pin on the ATtiny45 that is unable to support a LoRa function?

/*
  LoRa Duplex communication

  Sends a message every half second, and polls continually
  for new incoming messages. Implements a one-byte addressing scheme,
  with 0xFF as the broadcast address.

  Uses readString() from Stream class to read payload. The Stream class'
  timeout may affect other functuons, like the radio's callback.

  created 28 April 2017
  by Tom Igoe
*/
#include <SPI.h>              // include libraries
#include <LoRa.h>


const int receiveLED = 3;
const int csPin = 0;          // LoRa radio chip select
const int resetPin = 5;       // LoRa radio reset
const int irqPin = 4;         // change for your board; must be a hardware interrupt pin

byte localAddress = 0xFF;     // address of this device
byte destination = 0xBB;      // destination to send to
byte syncWord = 0xB4;        // sync word (network ID)
byte spreadingFactor = 8;    // spreading factor (6-12)


void setup() {
  LoRa.setPins(csPin, resetPin, irqPin);  //set CS, reset, IRQ pin
  LoRa.begin(900E6);              // initialize ratio at 900 MHz

  LoRa.setSyncWord(syncWord);
  LoRa.setSpreadingFactor(spreadingFactor);
  LoRa.setTimeout(10);
  pinMode(receiveLED, OUTPUT); // set the I/O pin modes
}

void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return
  digitalWrite(receiveLED, HIGH);       // turn on the receive LED

  // read packet header bytes
  int recipient = LoRa.read();          // recipient address
  byte msgLength = LoRa.read();    // incoming msg length
  String incoming = LoRa.readString();  //payload of packet


  // if the recipient isn't this device or broadcast,
  if (recipient != localAddress && recipient != 0xFF) {
    return;                             // skip rest of function
    digitalWrite(receiveLED, LOW);      // turn off receive LED
  }
}

Sorry. Didn't see pert's response after posting the above. I will try the updated library tonight.

3Dtj

Hmm. I removed the Spence core and downloaded the AATinyCore-master.zip using the above link. Do I need to install the Spence file from the board manger again? I don't see options to select the ATTiny boards when I go into the board menu of the IDE and I'm not able to open the avrdude.conf file from the master.zip

3Dtj:
Do I need to install the Spence file from the board manger again?

No, don't do that. The .zip file contains the same core but with all the latest development work in it, rather than the release version you get from Boards Manager, which is missing those changes.

3Dtj:
I don't see options to select the ATTiny boards when I go into the board menu of the IDE and I'm not able to open the avrdude.conf file from the master.zip

That means you didn't do the installation correctly.

3Dtj:
I'm not able to open the avrdude.conf file from the master.zip

You weren't supposed to leave the folder in the .zip file. I said "Copy the folder ATTinyCore-master from the downloaded file" because, at least on Windows, you can treat .zip files as folders and copy their contents out of them without actually going through an unzip stage. If you put the .zip file in the hardware folder then you need to unzip it. The folder structure should look like this:

{sketchbook folder}
|_hardware
|_ATTinyCore-master
|_avr

Make sure to not create an extra folder level between the hardware folder and the avr folder.

We are making progress. I did have an extra subfolder inserted thus removed that and was able to see ATTiny45 as a board selection. Upon compiling, I received a new error message:

Archiving built core (caching) in: C:\Users\TBK\AppData\Local\Temp\arduino_cache_732459\core\core_ATTinyCore-master_avr_attinyx5_LTO_disable,TimerClockSource_default,chip_45,clock_8internal,bod_disable_3652342df78470b424b7590a57f0d9c7.a
C:\Users\TBK\AppData\Local\Temp\arduino_build_648684/core\core.a(main.cpp.o): In function `main':

C:\Users\TBK\Documents\Arduino\hardware\ATTinyCore-master\avr\cores\tiny/main.cpp:13: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ATtiny25/45/85.

So close to getting this to work. What recommendation do you have? Really appreciate the help pert.

Typically this error means that the sketch you're compiling doesn't contain a loop function. Every sketch must have a setup and a loop function, even if they are left empty.

Try this:

  • File > New
  • Sketch > Verify/compile

Does the error still occur?

No error occurred when I created a new sketch and compiled as you recommended. I did find where I had removed the previous void loop (because there was no code). I re-entered the void loop command to address that issue. I attempted to compile the updated code an received the following error:

Build options changed, rebuilding all
Archiving built core (caching) in: C:\Users\TBK\AppData\Local\Temp\arduino_cache_458644\core\core_ATTinyCore-master_avr_attinyx5_LTO_disable,TimerClockSource_default,chip_45,clock_8internal,bod_disable_3652342df78470b424b7590a57f0d9c7.a
Sketch uses 2790 bytes (68%) of program storage space. Maximum is 4096 bytes.
Global variables use 70 bytes (27%) of dynamic memory, leaving 186 bytes for local variables. Maximum is 256 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xae

Is 0xae referring to the local or destination that I used for the LoRa addresses in my sketch?

Not responding usually indicates something's not getting through. Are the wiring correct? If you used Arduino as ISP, did you upload ArduinoISP sketch first? Set the programmer correctly in the menu? (ArduinoISP and Arduino as ISP aren't the same!) Maybe a pullup resistor from ATTiny's reset pin to 5v?

I made a slight change to the code and seems to be compiling but now it says sketch is too big (exceeds by 122%) but I only added a few lines of code. Should just a few lines of code really exceed the storage of the ATtiny45?? Would an ATTiny85 solve the issue if it really is a matter or storage?

Compare the #s.
Attiny 25/45/85:
2/4/8K Bytes of In-System Programmable Program Memory Flash
128/256/512 Bytes Internal SRAM
128/256/512 Bytes In-System Programmable EEPROM

Double the memory from 45 to 85.

3Dtj:
Should just a few lines of code really exceed the storage of the ATtiny45?

That absolutely depends on the lines of code. A single line could do that or not increase the program size at all.

3Dtj:
Would an ATTiny85 solve the issue if it really is a matter or storage?

Yes. If you're currently at 5 kB and an ATTiny85 is 8 kB then it gives you some breathing room but you can fill up an ATtiny85 pretty fast also. It's fun to see how much you can do with very limited resources but you can't just expect to be able to keep adding features to your program indefinitely, especially if you're not willing to do a lot of work to optimize your code down as small as possible.

Fascinating that what in my mind is hardly any code at all is causing the limitation issue.

Sketch uses 5006 bytes (122%) of program storage space. Maximum is 4096 bytes.

Global variables use 84 bytes (32%) of dynamic memory, leaving 172 bytes for local variables. Maximum is 256 bytes.
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
Error compiling for board ATtiny25/45/85.

Guess I'm express ordering from Adafruit for ATtiny85 chips. Will get the chips this weekend and give you an update. Again I appreciate your assistance in this effort.

3Dtj

Received the ATtiny85 chips and no longer getting the error regarding capacity but I'm back to the earlier message stating the programmer is not responding.

Sketch uses 5000 bytes (61%) of program storage space. Maximum is 8192 bytes.
Global variables use 84 bytes (16%) of dynamic memory, leaving 428 bytes for local variables. Maximum is 512 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I did upload the sketch to the UNO before using the Ardurino as ISP to the ATtiny85. I'll check connections some more but unclear the issue.

For some reason now I'm unable to upload the simple Blink sketch to the ATtiny45 even though it was working last week. I did update the Arduino IDE to 1.8.5 thus unclear if that impacted the ability to use the previous core to send code to ATtiny45. Any suggestions? I'm going back and removing/reinstalling the cores for the ATtiny45 again.

Please do this:

  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Sketch > Upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

I corrected the one minor oversight and was able to upload Blink sketch to the ATtiny85 and confirmed the LED blinks using only the ATtiny85. When I attempt to upload the LoRa sketch, I receive the following error:

C:\Users\TBK\Documents\Arduino\LoRaDuplex_Reciever_mini\LoRaDuplex_Reciever_mini.ino:9:18: fatal error: LoRa.h: No such file or directory

 #include <LoRa.h>

                  ^

compilation terminated.

exit status 1
Error compiling for board ATtiny25/45/85.

My bad. Had accidentally moved library folder.

File compiled to ATtiny85!!! Now checking to see if it actually works with the LoRa chip.