Serial Communication Between Tiny84 and Arduino

So I have split my program up to two micros per another request to over complicate this project by my client. He wants this system to be wireless eventually, but for now I’m setting everything up with serial until parts and stuff arrive to finish this. So I have a Tiny84 doing all the heavy work and sending telemetry back to the Arduino. The Arduino also needs to be able to send a couple numbers back to the Tiny84 to ndicate the program setting. But one step at a time.

Tiny84 Code:

#include <SoftwareSerial.h>

// Set Tx and Rx Pins for SoftwareSerial
int TxPin = 0;
int RxPin = 1;

// Declare Object
SoftwareSerial serial(TxPin, RxPin);

// Declare and Set Pin Names
int FanPWM = 2;    // Digital Pin 2: Up To 120A PWM Controlled DC Fan\Motor Controlled By TI CSD18503KCS 40V N-Channel NexFET™ Power MOSFET
int TemperatureADC = 7; // Analog Pin 7: Analog Voltage Controlled Temperature Probe

// Declare Variables
double TemperatureVal;    // Variable to Store the Value From the Analog Temperature Probe
double PrevTemperatureVal;    // Variable to Store the Previous Value From the Analog Temperature Probe

void setup() {
  //Set IO Pins
  pinMode(FanPWM, OUTPUT); // Set OUTPUT Pin for PWM Controlled DC Fan
  serial.begin(9600); // Start Serial Output
}

void loop() {
  TemperatureVal = analogRead(TemperatureADC);  // Reads Temperature Probe (value between 0 and 1023)
  analogWrite(FanPWM, TemperatureVal / 4); // Scale to Range (0 to 255) and Write Scaled Value To PWMFan Pin

  //Write Fan Speed and Temperature Value To SoftSerial

  if (TemperatureVal != PrevTemperatureVal) {
    serial.print(TemperatureVal);    // print as an ASCII-encoded decimal
    PrevTemperatureVal = TemperatureVal;
  }
  delay(200);
}

Arduino Code:

#include <LiquidCrystal.h>

// Declare IO Pins
int LCDBacklight = 3; //Digital Pin 3: LCD Backlight

//Declare Variables
double TemperatureVal;
double PrevTemperatureVal;

// Set LCD Pins
LiquidCrystal lcd(2, 8, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Initiate And Turn On The Backlight
  pinMode(LCDBacklight, OUTPUT);
  digitalWrite(LCDBacklight, HIGH);
  lcd.setCursor(0, 0);
  lcd.print("Loading...");
  // initialize the serial communications:
  Serial.begin(9600);

  delay(1000);
  lcd.clear();
}

void loop() {
  // when characters arrive over the serial port...
  if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // read all the available characters
    while (Serial.available() > 0) {
      TemperatureVal = Serial.read();
      // display each character to the LCD
      lcd.setCursor(0, 0);
      lcd.print((int)((TemperatureVal*100L) / 1023)); // scale to range (0 to 100)
      lcd.print("% ");
    }
  }
}

At the moment, nothing is showing on the LCD screen (with the exception of the Loading message, so the LCD works). So I opened up the Serial Monitor on the Arduino and every now and again I’m getting a value from the Tiny84. They’re the right values. They get smashed back to back, no new line, and they don’t always appear every time the values change like they’re supposed to. So the heck if I know. This project USED to be so simple.

Of course there's no newline, why would there be? If you want a newline between them, use Serial.println() not Serial.print(). But your code doesn't need that

You should also test the Arduino side with serial monitor - you would find that it won't work. Serial.read() gets a single character at a time (among other things)

Serial.parseInt() might do what you want. https://www.arduino.cc/en/Reference/ParseInt

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R