RadioHead ASK on ATtiny84

I dearly want to use an ATtiny84 with a RadioHead ASK transmitter project (I have it running on a ProMini but want to make it smaller).
I read up about using an external 8MHz crystal for frequency stability (hence I am not using an ATtiny85 - not enough pins) and can load a ‘Blinki’ sketch on my target ATtiny84 running with its external 8MHz clock.
When I try to load the sample ASK transmitter code - the compiler gets hung up on the definition of HardwareSerial in the RH_Serial.h file.
Does anyone know what I am doing wrong or a fix for this?
BTW - I read a similar post and included the SPI ignore line in the platformio.ini but it had no effect.
I’d also really like to run this on an ATtiny1604 - oddles more memory but I’ve not seen any doco says RadioHead support for Series ‘0’ ATtiny. Do you know any different?

My source, platformio.ini, output from compiler are all below:

// ask_transmitter.pde
// -*- mode: C++ -*-
// Simple example of how to use RadioHead to transmit messages
// with a simple ASK transmitter in a very simple way.
// Implements a simplex (one-way) transmitter with an TX-C1 module
// Tested on Arduino Mega, Duemilanova, Uno, Due, Teensy, ESP-12

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

//RH_ASK driver;
// RH_ASK driver(2000, 4, 5, 0); // ESP8266 or ESP32: do not use pin 11 or 2
 RH_ASK driver(2000, 3, 4, 0); // ATTiny, RX on D3 (pin 2 on attiny85) TX on D4 (pin 3 on attiny85), 
// RH_ASK driver(2000, PD14, PD13, 0); STM32F4 Discovery: see tx and rx on Orange and Red LEDS

void setup()
    Serial.begin(9600);	  // Debugging only
    if (!driver.init())
         Serial.println("init failed");

void loop()
    const char *msg = "hello";

    driver.send((uint8_t *)msg, strlen(msg));
; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = atmelavr
board = attiny84
framework = arduino
upload_protocol = custom
upload_port = usb
upload_flags = 
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
lib_deps = mikem/RadioHead@^1.120
lib_ignore = SPI

 *  Executing task in folder ATTiny84_RH_ASK_Test: C:\Users\Peter\.platformio\penv\Scripts\platformio.exe run 

Processing attiny84 (platform: atmelavr; board: attiny84; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Atmel AVR (3.4.0) > Generic ATtiny84
HARDWARE: ATTINY84 8MHz, 512B RAM, 8KB Flash  
DEBUG: Current (simavr) On-board (simavr)     
 - framework-arduino-avr-attiny @ 1.5.2       
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
|-- RadioHead @ 1.120.0
Building in release mode
Compiling .pio\build\attiny84\lib464\RadioHead\RH_Serial.cpp.o
Compiling .pio\build\attiny84\FrameworkArduino\WString.cpp.o
Compiling .pio\build\attiny84\FrameworkArduino\abi.cpp.o
Compiling .pio\build\attiny84\FrameworkArduino\main.cpp.o
Compiling .pio\build\attiny84\FrameworkArduino\new.cpp.o
Compiling .pio\build\attiny84\FrameworkArduino\wiring.c.o
Compiling .pio\build\attiny84\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\attiny84\FrameworkArduino\wiring_digital.c.o
In file included from .pio\libdeps\attiny84\RadioHead\RH_Serial.cpp:6:0:
.pio\libdeps\attiny84\RadioHead/RH_Serial.h:159:29: error: expected ')' before '&' token
     RH_Serial(HardwareSerial& serial);
.pio\libdeps\attiny84\RadioHead/RH_Serial.h:163:5: error: 'HardwareSerial' does not name a type; did you mean 'HardwareSerial_h'?
     HardwareSerial& serial();
In file included from .pio\libdeps\attiny84\RadioHead\RH_Serial.cpp:6:0:
.pio\libdeps\attiny84\RadioHead/RH_Serial.h:247:5: error: 'HardwareSerial' does not name a type; did you mean 'HardwareSerial_h'?
     HardwareSerial& _serial;
*** [.pio\build\attiny84\lib464\RadioHead\RH_Serial.cpp.o] Error 1
In file included from C:\Users\Peter\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\Arduino.h:187:0,
                 from C:\Users\Peter\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\wiring_private.h:35,
                 from C:\Users\Peter\.platformio\packages\framework-arduino-avr-attiny\cores\tiny\wiring_digital.c:29:
C:\Users\Peter\.platformio\packages\framework-arduino-avr-attiny\variants\tinyX4/pins_arduino.h:170:2: warning: #warning "This is the COUNTERCLOCKWISE pin mapping - make sure you're using the pinout diagram with the pins in counter clockwise order" [-Wcpp]
 #warning "This is the COUNTERCLOCKWISE pin mapping - make sure you're using the pinout diagram with the pins in counter clockwise order"
=========================================================== [FAILED] Took 6.76 seconds ===========================================================

RadioHead: RadioHead Packet Radio library for embedded microprocessors says

But the SpenceKonde core is exactly what’s being used in PlatformIO per

Hi Max

Thanks again for your non judgemental response.

Yes I was just hoping someone had a magic silver bullet here.

In my quest to build a very small RF ASK transmitter, I previously tried to jig up my own version of the excellent RadioHead transmitter based on my (limited) understanding of the DSS protocol - this is used by model railway enthusiasts - essentially a ‘Morse Code’ style protocol. I was using an ATtiny85 (internal 8MHz clock).

I tried to put this across an RF link - I am aware of the need for training sequences to allow the decoder AGC to align, trying to keep the envelope going up and down and the use of a rudimentary packet with check sum. This was a basic bit bang approach and it almost worked - well, worked some of the time, but not all of the time) - maybe the bit I was missing was the external 8MHz clocked MCU. I was scared to commit but now I have a home made HV programmer - just in case.

I’ll try my ‘home brew’ protocol approach again - maybe I can roll an ATtiny1604 into the mix - I’m keen to save power and these devices have insane low power in Sleep Mode - Standby with window based ADC measurements via event linked RTC also comes out near 4uA - I could live with that.

I have learned that life is a compromise.

Can the sketch be compiled in the Arduino IDE when using that other mentioned core? (GitHub - damellis/attiny: ATtiny microcontroller support for the Arduino IDE)

Hi Max

Thanks again for your suggestion.

I did try developing in Arduino IDE and managed to get a rudimentary RH_ASK transmitter going with another core (I even used TinyHead) on an ATtiny85 - but it was very flakey - I thought it might have been down to the clock, hence moving to ATtiny84 with external crystal.

I am dyslexic and struggle with Arduino IDE as it’s all black 'n white and typing errors are not flagged until compile time. PlatformIO is so much better, I’ll work round things in this environment.

I’ve moved on - I found a RH_ASK Class Reference and noticed a comment

With AtTiny x14 (such as 1614 etc) using Spencer Kondes megaTinyCore…

I also seem to remember reading somewhere that the internal oscillators in these ‘new’ ATtiny parts is much better - the ATtiny 1604 part doesn’t support external crystals anyway.

I just received a packet of ATtiny1604s and am just in the middle of trying to get one to work with RH_ASK transmitter (to RH_ASK receiver running on a [previously tested] Nano).

In PlatformIO, it compiles, loads and runs without locking up - I just need to see if I can get the frequency right and see how temp stable it is.

Time passes - I successfully used ATtiny1604 to run RH_ASK transmitter.

I was initially loosing some packets but I performed some clock Tuning

My packets seem to get through 100% now that I can select the

16MHz internal - tuned

clock option from the Arduino IDE burn bootloader option.

I doesn’t seem to matter that the RH_ASK code seems to ask for a 8Mhz clock - I just set up F_CPU at 16000000 in both the source and platformio.ini file.

I can even get serial data from the USART at the baud rate I select.

Happy days

1 Like