So, I FINALY learned how to send a float value over VirtualWire. I have an ATtiny85 with a thermistor and 433 Mhz TX. That reads the thermistor, converts it, averages 5 readings over 1 second, and transmits the data. I am using an ATtiny84 for the RX end of this. Using an LCD and 433 Mhz RX. While using VirtualWire.h and LiquidCrystal.h the LCD does not work. If i comment out the VW setup stuff in "void setup()" the LCD works. I read this, [SOLVED] I can have VirtualWire OR LCD running, not both. - Networking, Protocols, and Devices - Arduino Forum but this didn't help me. I declared my pins and have no overlapping pins. I am not sure what the issue is? Thank you in advance for help.
TX Code:
//THE THERMISTOR IS A 10K THERMISTOR
// DIAGRAM
// GROUND-----------10K RESISTOR-----------INPUT A7-----------10K THERMISTOR-----------5V
#include <VirtualWire.h>
int Thermostat = A1;
float ThermostatReading = 0;
float Res = 0;
float TempK = 0; //Tempature in K
float TempC = 0; //Tempature in C
float TempF = 0; //Tempature in F
float L1 = 0;
float L2 = 0;
float L3 = 0;
float L4 = 0;
float L5 = 0;
float AvgK = 0;
int Avg = 1; //Average the temp
char Temp[7];
void setup()
{
//Serial.begin(9600);
// Initialise the IO and ISR
vw_set_tx_pin(0); //Setting up the transmitter pin
//vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
}
void loop()
{
//Get the Thermistor resistance
Res = analogRead(Thermostat);
Res = 1023 / Res - 1;
Res = 10000 / Res;
//Calculate the Temp
ThermostatReading = analogRead(Thermostat);
TempK = log(10000.0 * (1024.0 / ThermostatReading - 1));
TempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempK * TempK)) * TempK);
//Average the Readings
if (Avg == 1)
{
L1 = TempK;
}
if (Avg == 2)
{
L2 = TempK;
}
if (Avg == 3)
{
L3 = TempK;
}
if (Avg == 4)
{
L4 = TempK;
}
if (Avg == 5)
{
L5 = TempK;
AvgK = (L1 + L2 + L3 + L4 + L5);
AvgK = (AvgK / 5);
TempC = AvgK - 273.15;
TempF = TempC * 1.8 + 32;
dtostrf(TempF, 6, 2, Temp);
//Serial.println(Temp);
vw_send((uint8_t *)Temp, strlen(Temp));
vw_wait_tx();
Avg = 1;
}
if (Avg <= 0 || Avg >= 6)
{
Avg = 1;
}
Avg = Avg + 1;
delay(200);
}
RX Code:
#include <VirtualWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
const int ValBL = 85; //Value for BackLight Brightness
const int BackLight = 6; //BackLight PWM Output
int TempF;
char Temp[10];
int i;
void setup()
{
//Serial.begin(9600);
pinMode(BackLight, OUTPUT);
lcd.begin(16, 2);
analogWrite(BackLight, ValBL);
// Initialise the IO and ISR
vw_set_rx_pin(8);
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
for (i = 0; i < buflen; i++)
{
Temp[i] = buf[i];
}
lcd.clear();
lcd.setCursor(1,0);
lcd.print("TEMPERATURE");
lcd.setCursor(2, 1);
lcd.print(Temp);
lcd.print((char)223);
lcd.print("F");
//Serial.print("char: ");
//Serial.println(Temp);
}
}