'Serial' was not declared in this scope: ATTiny84 code through Arduino ISP

I have just got a new kit from Cooking Hacks called "Open Garden Outdoor". Here is the link for the kit assembly:

https://www.cooking-hacks.com/documentation/tutorials/open-garden-hydroponics-irrigation-system-sensors-plant-monitoring#img_117

Now, in theory, this kit looks relatively straight forward to set up and get running, but I have hit a few snags, and there doesn't seem to be any information on these specific issues.

The first and only one I will address here

  • I have gone through all the steps to complete uploading to the ATTiny84 using Arduino Uno as the ISP. The LED light shows that the Arduino ISP is working to upload to the ATTiny using the "Blink" example, BUT when I go to upload the following code, there are many errors.
#include <OpenGardenNode.h>

Payload nodePacket;
 
void setup() {
    //Initialize the transceiver
    OpenGardenNode.initRF(1); //Write here the number for your node ID  (1, 2 or 3)
    OpenGardenNode.initSensors(); //Initialize sensors power  
}

void loop() {
    OpenGardenNode.sensorPowerON();  //Turns on the sensor power supply
    OpenGardenNode.readSensors();    //Read all node sensors
    OpenGardenNode.sensorPowerOFF(); //Turns off the sensor power supply
    
    OpenGardenNode.sendPackage();  // Send data via RF asking for ACK
    OpenGardenNode.nodeWait(60);   //Enter low power mode for 60 seconds (max: 60 seconds)
}

Errors from this:

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Stream.h:26,
from C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/HardwareSerial.h:28,
from C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:193,
from C:\Users\Ashten Sawitsky\Documents\Arduino\libraries\OpenGardenNode/OpenGardenNode.h:29,
from NodeProgrammer.ino:25:
C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Print.h:32:1: warning: "BIN" redefined
In file included from c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/avr/iotn84.h:38,
from c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/avr/io.h:290,
from c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/avr/pgmspace.h:82,
from C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/Arduino.h:8,
from C:\Users\Ashten Sawitsky\Documents\Arduino\libraries\OpenGardenNode/OpenGardenNode.h:29,
from NodeProgrammer.ino:25:
c:/program files (x86)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/avr/iotnx4.h:71:1: warning: this is the location of the previous definition
In file included from C:\Users\Ashten Sawitsky\Documents\Arduino\libraries\OpenGardenNode/OpenGardenNode.h:32,
from NodeProgrammer.ino:25:
C:\Users\Ashten Sawitsky\Documents\Arduino\libraries\OpenGardenNode/Ports.h:697: error: 'Serial' was not declared in this scope
C:\Users\Ashten Sawitsky\Documents\Arduino\libraries\OpenGardenNode/Ports.h:698: error: 'Serial' was not declared in this scope

I have looked up how to troubleshoot the serial problem by using SoftwareSerial, but nothing seems to work.

SO, does anyone have any idea to get this code uploaded to the ATTiny84?

You are using a core that does not provide a builtin software serial (the attiny84 does not have hardware serial support) - you may be able to use SoftwareSerial with that core.

If you were using my core, it does have a builtin software serial implementation (which makes use of the ACO interrupt instead of a pinchange interrupt, greatly reducing compatibility issues - everyone uses pin change interrupts, but hardly anyone uses the analog comparator), which is named Serial (for compatibility) on the AIN0 and AIN1 pins. See the included documentation for more details. You can also use SoftwareSerial with my core.

Bear in mind, that either way, it is a software serial implementation - so you can't send and receive at the same time, and sending is blocking, not done in the background like with real hardware serial.

You might want to consider the ATTiny841 - it's SMD only, but it's pin compatible with the tiny84, only with an extra 16-bit timer (timer2 exactly like timer1) and has not one, but TWO fully functional hardware serial ports.

It looks like the troublesome file Ports.h contains conditional compilation like:

#ifdef Stream_h // only available in recent Arduino IDE versions

/// Simple parser for input data and one-letter commands
class InputParser {

 // Do something with "Serial"

I suspect that early versions of the attiny84 code managed to NOT define "Stream_h" because there was no Serial port, but the new structure is "more flexible", resulting in an error.
Try changing the line:

#ifdef Stream_h // only available in recent Arduino IDE versions

To

#if defined(Stream_h) && defined(HAVE_HWSERIAL0)