Webserver using Arduino Nano and Ethernet Shield enc28j60

Trying to use arduino nano and ethernet shield enc28j60 as a micro web server for showing temperature and humidity.

Any suggestions on what I should be reading and understanding since I’m “just getting started”. I found some code online for what I want to do but im not sure if its old or new.

The following is my current code after will be the errors I’m receiving.
And as a member of the captain obvious club I am a total newb to arduino.

CODE********
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
#include <UIPEthernet.h>

dht DHT;

#define DHT22_PIN 6

byte mac = { 0x54, 0x34, 0x41, 0x3f, 0x4d, 0x31 };

IPAddress ip(192, 168, 86, 5);
EthernetServer server(80);

double Fahrenheit(double celsius) {
return ((double)(9/5) * celsius) + 32;
}

double Kelvin(double celsius) {
return celsius + 273.15;
}

// dewPoint function NOAA

//
double dewPoint(double celsius, double humidity) {
// (1) Saturation Vapor Pressure = ESGG(T)
double RATIO = 373.15 / (273.15 + celsius);
double RHS = -7.90298 * (RATIO - 1);
RHS += 5.02808 * log10(RATIO);
RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
RHS += log10(1013.246);

// factor -3 is to adjust units - Vapor Pressure SVP * humidity
double VP = pow(10, RHS - 3) * humidity;

// (2) DEWPOINT = F(Vapor Pressure)
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558 - T);
}

// delta max = 0.6544 wrt dewPoint()
// 6.9 x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity) {
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
double Td = (b * temp) / (a - temp);
return Td;
}

void setup() {
Serial.begin(115200);
Serial.println("DHT WEB SERVER ");
Serial.print("LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Ethernet.begin(mac, ip);
server.begin();
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
}

void loop() {
EthernetClient client = server.available();
if (client) {
Serial.println("-> New Connection");
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == ‘\n’ && currentLineIsBlank) {
client.println("");
client.println("");
client.println("\n");
client.println(“Humidity/Temperature Information”);
client.println("\n");
client.println(“

Detail(s)

”);
client.println(“

Humidity / Temperature

”);
client.println("
");

int chk = DHT.read22(DHT22_PIN);

switch (chk) {
case DHTLIB_OK:

client.print("Humidity (%) : ");
client.println((float)DHT.humidity, 2);

client.print("Temperature (°C) : ");
client.println((float)DHT.temperature, 2);

client.print("Temperature (°F) : ");
client.println(Fahrenheit(DHT.temperature), 2);

client.print("Temperature (°K) : ");
client.println(Kelvin(DHT.temperature), 2);

client.print("Dew Point (°C) : ");
client.println(dewPoint(DHT.temperature, DHT.humidity));

client.print("Dew PointFast (°C): ");
client.println(dewPointFast(DHT.temperature, DHT.humidity));

break;
case DHTLIB_ERROR_CHECKSUM:
client.print("\nChecksum error!");
break;
case DHTLIB_ERROR_TIMEOUT:
client.print("\nTime out error!");
break;
default:
client.print("\nUnknown error!");
break;
}
client.println("

");
client.println(“

Powered by an Arduino NANO

”);
client.print("\n");
break;
}

if (c == ‘\n’) currentLineIsBlank = true;
else if (c != ‘\r’) {
currentLineIsBlank = false;
}
}
}

delay(10);
client.stop();
Serial.println(" Disconnected\n");
}
}

Errors when attempting to compile.:******

Arduino: 1.8.9 (Windows 10), Board: “Arduino Nano, ATmega328P (Old Bootloader)”

sketch_aug12a:6:1: error: ‘dht’ does not name a type

dht DHT;

^

C:\Users\matt-\Documents\Arduino\sketch_aug12a\sketch_aug12a.ino: In function ‘void setup()’:

sketch_aug12a:59:18: error: ‘DHT_LIB_VERSION’ was not declared in this scope

Serial.println(DHT_LIB_VERSION);

^

C:\Users\matt-\Documents\Arduino\sketch_aug12a\sketch_aug12a.ino: In function ‘void loop()’:

sketch_aug12a:85:24: error: expected primary-expression before ‘.’ token

int chk = DHT.read22(DHT22_PIN);

^

sketch_aug12a:88:18: error: ‘DHTLIB_OK’ was not declared in this scope

case DHTLIB_OK:

^

sketch_aug12a:91:40: error: expected primary-expression before ‘.’ token

client.println((float)DHT.humidity, 2);

^

sketch_aug12a:94:40: error: expected primary-expression before ‘.’ token

client.println((float)DHT.temperature, 2);

^

sketch_aug12a:97:44: error: expected primary-expression before ‘.’ token

client.println(Fahrenheit(DHT.temperature), 2);

^

sketch_aug12a:100:40: error: expected primary-expression before ‘.’ token

client.println(Kelvin(DHT.temperature), 2);

^

sketch_aug12a:103:42: error: expected primary-expression before ‘.’ token

client.println(dewPoint(DHT.temperature, DHT.humidity));

^

sketch_aug12a:103:59: error: expected primary-expression before ‘.’ token

client.println(dewPoint(DHT.temperature, DHT.humidity));

^

sketch_aug12a:106:46: error: expected primary-expression before ‘.’ token

client.println(dewPointFast(DHT.temperature, DHT.humidity));

^

sketch_aug12a:106:63: error: expected primary-expression before ‘.’ token

client.println(dewPointFast(DHT.temperature, DHT.humidity));

^

sketch_aug12a:109:18: error: ‘DHTLIB_ERROR_CHECKSUM’ was not declared in this scope

case DHTLIB_ERROR_CHECKSUM:

^

sketch_aug12a:112:18: error: ‘DHTLIB_ERROR_TIMEOUT’ was not declared in this scope

case DHTLIB_ERROR_TIMEOUT:

^

Using library DHT_sensor_library at version 1.3.7 in folder: Arduino\libraries\DHT_sensor_library
Using library Adafruit_Unified_Sensor at version 1.0.3 in folder:Arduino\libraries\Adafruit_Unified_Sensor
Using library UIPEthernet at version 2.0.7 in folder Arduino\libraries\UIPEthernet
exit status 1
‘dht’ does not name a type

sketch_aug12a.ino (4.25 KB)

There are multiple DHT libraries (or versions of DHT libraries). It looks like the sketch you found was written for a different one than the library you're using. If you go back to where you copied that code from, you might find documentation that tells you where to get the library it was written for. Otherwise, study the examples that came with the DHT library you're currently using (File > Examples > DHT sensor library) to understand the correct way to use it and then update your code accordingly.

  1. I did say that I am new to this I'm not a programmer.
  2. If anyone has suggestions on this code or a simplistic way of doing this by all means post accordingly.
  3. Telling me to understand the correct way to use code to a beginner is not very helpful. Iv'e read a few books but the logic seems to elude me.
  4. I just want to get this up and running in each room of the house so I can manage the ac better.