[solved]Attiny85 hangs after Send RadioHead RH_ASK

Hello!

Im trying to get the rh_ask driver to work on attiny85, but it seems to hang after Send command?

Im using RadioHead 1.113, and the Attiny core from https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Attiny85 running at 8Mhz. (Burning bootloader through a UNO)

The sketch runs fine on arduino Nano, but seems to hang on the ATTINY85?

Im Running the example ask_transmitter sketch but I added blinking led in the loop for debugging, and it seems like the Attiny85 hangs after driver.send.
If I comment that line the sketch runs fine? (led keeps blinking)

I tried the ATTINY85-20SU and ATTINY85-20PU with the same result?

Here´s the Code:

#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif




RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 on attiny85), 


#define LED_PIN 0


void setup()
{
#ifdef RH_HAVE_SERIAL
    Serial.begin(9600);	  // Debugging only
#endif
    if (!driver.init())
#ifdef RH_HAVE_SERIAL
         Serial.println("init failed");
#else
	;
#endif


 pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(300);                       // wait for a second
    digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
    delay(300);
    digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(300);                       // wait for a second
    digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
    delay(300);
    digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(300);                       // wait for a second
    digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
    delay(300);


}


void loop()
{
  digitalWrite(LED_PIN, HIGH);
    const char *msg = "hello";


    //driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(500);
    digitalWrite(LED_PIN, LOW);
    delay(500);
}

I Also tried other Cores like SpenceKode Core, even tried the TinyHead lib, but I can’t get it to work? :frowning:

Best regards

Whitout knowing much about the library, I guess that "driver.waitPacketSent()" will actually wait until a packet has been sent and your code does not send anything. You may want to try to implement a timeout with "driver.waitPacketSent(1000)" and see if that changes anything.

RadioHead docs.

Thanks for the advice, I didn´t know I could define a timeout.

I made the led blink for each step to see were the Attiny Hangs, and the the wierd thing is that ist seems to be at the second Send in the loop? and not the first one?

Setup - 2 blink wait 2sec.

loop begins - 3 blink wait 2sec.

send - 4 blink wait 2sec. (Nothing recieved on the Nano RX)

waitPacketSent - 5 blink wait 2 sec.

loop begins (second time) - 3 blink wait 2 sec.

hangs…

:confused:

The RadioHead library pretty much fills up the ATtiny85, so you will be lucky to get it running. There is even a warning to that effect in the library.

VirtualWire works great and takes up much less space. Ignore the "end of life" warning -- the VW library has been thoroughly tested, and has no known bugs.

jremington:
The RadioHead library pretty much fills up the ATtiny85, so you will be lucky to get it running. There is even a warning to that effect in the library.

VirtualWire works great and takes up much less space. Ignore the “end of life” warning – the VW library has been thoroughly tested, and has no known bugs.

Thanks for the Advice, but I already tried the VirtualWire Lib, and it works fine.
I also tried the Manchester Lib which also works fine!

The Problem is that the Reciever part is a ESP32 which doesn’t support VirtualWire or Manchester :frowning:
So i seem to be stucked with the RadioHead that works with the ESP32, but i just can’t get it to work on the Attiny85. :frowning:

I would not use an ATtiny85. If board size is an issue, use one of these.

jremington:
I would not use an ATtiny85. If board size is an issue, use one of these.

Thanks for the tip.

Yeah board size and price is an issue. Im making cheap wireless 433mhz sensors for temp and humidity.
the ATTINY85-20-SU is very small when soldered to the PCB, and also cheap.

The RadioHead lib is supposed to be supporting the ATTINY85, I don´t get it why It doesn't work? :frowning:

Most likely, it doesn't work because you run out of memory. Did you read the library warning about the ATtiny85?

If this is for a commercial product where every penny counts, do your research. Otherwise, skip the next cup of cappuccino and use the proceeds to upgrade.

jremington:
Most likely, it doesn't work because you run out of memory. Did you read the library warning about the ATtiny85?

If this is for a commercial product where every penny counts, do your research. Otherwise, skip the next cup of cappuccino and use the proceeds to upgrade.

Yeah I did** read** the library warning about the ATtiny85 when using SpenceKonde ATTinyCore, which I don't, Im using the recommended damellis core.

The library clearly states that it supports ATtiny85:

"ATTiny built using Arduino IDE 1.8 and the ATTiny core from https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json using the instructions at ATtiny85 Easy Flashing Through Arduino | by J3 | Jungletronics | Medium"

They even mentions the ATtiny85 in the example sketch:

"RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 on attiny85)"

Im pretty sure they didn't add that just for fun?...

The example sketch uses (47%) of program storage space. and (73%) of dynamic memory, so out of memory is most likely not the problem.

Sure, that is one way of solving a problem, just change the hardware and the problem is gone.... :slight_smile:

Do let us know when you get it to work.

sparwen:
The example sketch uses (47%) of program storage space. and (73%) of dynamic memory, so out of memory is most likely not the problem.

You do know that the 73% of dynamic memory does not account for how large the stack can grow when the code is actually running, yes? It only measures your global allocation of memory. When the program actually runs, the stack grows with every function call, so depending on how deep these calls get, you could quite easily run out of memory.

jremington:
Do let us know when you get it to work.

I got it working! :slight_smile:

Here´s what i did:

But as mentioned, the Lib eats up quite alot of memory, a empty sketch with the Lib included takes 4114 bytes (50%) of program storage and 349 bytes (68%) of dynamic memory, leaving 163 bytes for local variables.

So use them wisely! :slight_smile:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.