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>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
//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()
{
#ifdef RH_HAVE_SERIAL
Serial.begin(9600); // Debugging only
#endif
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
}
void loop()
{
const char *msg = "hello";
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(200);
}
; 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
; https://docs.platformio.org/page/projectconf.html
[env:attiny84]
platform = atmelavr
board = attiny84
framework = arduino
upload_protocol = custom
upload_port = usb
upload_flags =
-C
${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p
$BOARD_MCU
-P
$UPLOAD_PORT
-c
usbasp
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
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/attiny84.html
PLATFORM: Atmel AVR (3.4.0) > Generic ATtiny84
HARDWARE: ATTINY84 8MHz, 512B RAM, 8KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr-attiny @ 1.5.2
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
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();
^~~~~~~~~~~~~~
HardwareSerial_h
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;
^~~~~~~~~~~~~~
HardwareSerial_h
*** [.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 ===========================================================