Hi all I am writing a program to use a temp and humidity receiver and then calculate the wet bulb temperature using an equation and then display it on a 1602 LCD. I have never worked with RF boards before and also need help in general
The first problem is my "wetbulb" equation is giving me the error 'wetbulb' does not name a type
could you pls also help with he code in whole
Please find the whole program attached
#include "RF24.h"
#include <LiquidCrystal.h> //Includes the LCD library
RF24 myRadio (6, 7);
byte addresses[][6] = {"0"};
float remoteHumidity = 0.0;
float remoteTemperature = 0.0;
struct package
{
float temperature ;
float humidity ;
float wetbulb = 0;
};
float previousRemoteHumidity = 0.1;
float previousRemoteTemperature = 0.1;
typedef struct package Package;
Package data;
float wetbulb = 0;
unsigned long lastMillis; // <----------<<<<
boolean flag;// <----------<<<<
byte temp[8] = //icon for thermometer
{
B00100,
B01011,
B01010,
B01111,
B01110,
B11111,
B11111,
B01110
};
byte drop[8] = //icon for Humidity Symbol
{
B00100,
B00100,
B01110,
B01110,
B11111,
B11111,
B11111,
B01110
};
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //Defines the LCD pins
byte bcdToDec(byte val) //Convert binary coded decimal to normal decimal numbers
{
return ( (val / 16 * 10) + (val % 16) );
}
void setup() {
Serial.begin(9600);
lcd.createChar(1, temp); // create a new character labeled 1
lcd.createChar(2, drop); // create a new character labeled 2
lcd.begin(16, 2); // set up the LCD's number of columns and rows
lcd.begin(16, 2);
{
lcd.setCursor(2, 0);
lcd.print("MAKE IT SNOW");
lcd.setCursor(4, 1);
lcd.print(" .COM.AU");
delay(80);
}
//Display a welcome message on LCD when booting up
startWirelessCommunication();
printUI();
}
void loop() {
checkForWirelessData();
printRemoteTemperature();
printRemoteHumidity();
}
wetbulb = (-5.806+0.672* t -0.006* t * t +(0.061+0.004* t +0.000099* t * t)* h +(-0.000033-0.000005* t -0.0000001*t * t )* h * h ); //This is the equation for wetbulb temperature
void startWirelessCommunication()
{
myRadio.begin();
myRadio.setChannel(115);
myRadio.setPALevel(RF24_PA_MAX);
myRadio.setDataRate( RF24_250KBPS ) ;
myRadio.openReadingPipe(1, addresses[0]);
myRadio.startListening();
delay(100);
}
void checkForWirelessData()
{
if ( myRadio.available())
{
while (myRadio.available())
{
myRadio.read( &data, sizeof(data) );
previousRemoteTemperature = remoteTemperature;
previousRemoteHumidity = remoteHumidity;
remoteTemperature = Celcius2Fahrenheit(data.temperature);
remoteHumidity = data.humidity;
}
Serial.print("\nPackage:");
Serial.print("\n");
Serial.println(data.temperature);
Serial.println(data.humidity);
}
}
void printUI()
{
lcd.setCursor (0, 0);
lcd.print("Wetbulb"); //Prints wetbulb label to the LCD
lcd.print(" ");
lcd.print(wetbulb);
lcd.print((char)223);
lcd.print("C");
}
void printRemoteHumidity()
{
String humidity;
if(remoteHumidity != previousRemoteHumidity)
{
if(remoteHumidity == 0.0 && remoteTemperature == 0.0) //We just booted up
{
humidity = "---";
}else
{
humidity = String(remoteHumidity,1);
}
lcd.setCursor(0, 1); //Position the LCD cursor (col 0, row 1)
lcd.write(1); //Print the new character labeled 1
lcd.print(" ");
lcd.print(Temperature); //Print a message to the lcd.
lcd.print((char)223); //Prints the celicius Symbol
lcd.print(" ");
lcd.write(2); //Print the new character labeled 2
lcd.print(" ");
lcd.print(Humidity);
lcd.print("%"); //Prints the Pertcent symbol
previousRemoteHumidity = remoteHumidity;
}
}
void printRemoteTemperature()
{
String temperature;
if(remoteTemperature != previousRemoteTemperature)
{
if(remoteHumidity == 0.0 && remoteTemperature == 0.0) //We just booted up
{
temperature = "---";
}else if(remoteTemperature>=100)
{
temperature = String(remoteTemperature,0);
}else
{
temperature = String(remoteTemperature,1);
}
lcd.setCursor(0, 1); //Position the LCD cursor (col 0, row 1)
lcd.write(1); //Print the new character labeled 1
lcd.print(" ");
lcd.print(Temperature); //Print a message to the lcd.
lcd.print((char)223); //Prints the celicius Symbol
lcd.print(" ");
lcd.write(2); //Print the new character labeled 2
lcd.print(" ");
lcd.print(Humidity);
lcd.print("%"); //Prints the Pertcent symbol
previousRemoteTemperature = remoteTemperature;
}
}
delay (1250); //Sets the update interval for all functions