Just try to clean up my program code. Therefore, my classes has relocated to different files, via New Tab.
Now when I try to initialize a class from the file *.ino I get the following error message:
28: error: 'Weather' does not name a type
Weather myWaether(0,300000); // initialized Class Weather
^
exit status 1
'Weather' does not name a type
Here my code: Weather.ino
// DHT library
#include <DHT.h>
#include <SPI.h>
#define DHTTYPE DHT22 // DHT11 or DHT21 or DHT22
#define DHTPIN 2 // DataPin for the DHT Module
DHT dht(DHTPIN, DHTTYPE); // Create instance DHT
class Weather
{
// Class Member variables
// These are initialized at startup
long OnTime; // milliseconds of on-time
long OffTime; // milliseconds of off-time
volatile unsigned long previousMillis; // will store last time LEDs was updatted
float temperature; // lokal variable to store the temperature from DHT
float humility; // lokal variable to store the humility from DHT
// Constructor - creates a weather instance
// and initiliazes the member varialbles and state
public:
Weather(long _on, long _off)
{
OnTime = _on;
OffTime = _off;
previousMillis = 0;
dht.begin();
}
float readDHT_temperature(unsigned long currentMillis)
// read the temperature from the DHT Module
{
if ( currentMillis - previousMillis >= OnTime)
{
float temperature = dht.readTemperature(); // read temperature
if ( isnan(temperature) ) // check
{
Serial.println("Error - Can't read temperature from DHT!");
return -1000;
}
else
{
Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" °C");
return temperature;
}
}
}
float readDHT_humility(unsigned long currentMillis)
// read the humility from the DHT Module
{
if ( currentMillis - previousMillis >= OnTime)
{
float humility = dht.readTemperature(); // read temperature
if ( isnan(humility) ) // check
{
Serial.println("Error - Can't read humility from DHT!");
return -1000;
}
else
{
Serial.print("Humility: "); Serial.print(humility); Serial.println(" %");
return humility;
}
}
}
};
and here the main program:
// Ethernet
#include <Ethernet.h>
/* Deinition for Ethernet communikation */
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC address for ethernet controller
IPAddress ip(UUU,XXX,YYY,ZZZ); // IP Address for ethernet controller
Weather myWaether(0,300000); // initialized Class Weather
void setup() {
// put your setup code here, to run once:
Ethernet.begin(mac, ip);
}
void loop() {
// put your main code here, to run repeatedly:
}
Why is the class named "does not name a type" if it exists in the * .ino file?
ZHermann