i have one a project.
My teacher require me take info DHT11 to save on SD card module and up info DHT11 on Web IP Wiznet w5100.2 devices work same time.
When i put MÍSO of SD card module, Wiznet w5100 not work and show on serial mornitor 250.250.250.250.
I do add code pinmode(ss, OUTPUT) ,digitalWrite ( ss, HIGH) BUT IT NOT WORK.
HELP ME ! THANKS YOU ANYONE !
THIS IS MY CODE
/*
Web Server
A simple web server that shows the temperature & humidity from
a DHT11 sensor using an Arduino Wiznet Ethernet shield.
Circuit:
- Ethernet shield attached to pins 10, 11, 12, 13
- Data from DHT11 is at A2 (analog input 2)
*/
#include <DHT.h>
#define DHTPIN A3 // what pin we're connected the DHT output
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
#include <Wire.h>
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h> // Include SD library
File dataFile;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0, 17);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
const int CS_PIN = 4;
void setup() {
Serial.begin(9600);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
}
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
delay(2000);
dht.begin();
// Open serial communications and wait for port to open:
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
digitalWrite(10, HIGH);
delay(2000);
// rest of your setup
Serial.println("Setup done");
Serial.println("Ready");
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
; // wait for serial port to connect. Needed for native USB port only
}
uint16_t line = 1;
void loop() {
delay(1000);
// Read humidity
byte RH = dht.readHumidity();
//Read temperature in degree Celsius
byte Temp = dht.readTemperature();
dataFile = SD.open("DHT11Log.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (dataFile) {
Serial.print(line);
Serial.print(": Temperature = ");
Serial.print(Temp);
Serial.print("°C, Humidity = ");
Serial.print(RH);
Serial.println("%");
// Write data to SD card file (DHT11Log.txt)
dataFile.print(line++);
dataFile.print(": Temperature = ");
dataFile.print(Temp);
dataFile.print("°C, Humidity = ");
dataFile.print(RH);
dataFile.println("%");
dataFile.close();
}
// if the file didn't open, print an error:
else
Serial.println("error opening DHT11Log.txt");
int h = dht.readHumidity();
int t = dht.readTemperature();
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
client.println("");
client.println("");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv="refresh" content="5">");
client.println("");
client.print("Temperature and Humidity");
client.println("");
// output the value of temperature and humuidity from DHT
client.println("");
client.println("
");
client.print("Data Center");
client.println("
");client.println("
");
client.print("Server Room Temperature and Humidity");
client.println("
");client.println("
");
client.print("Temperature : ");
client.print(t);
client.print("0");
client.print("C");
client.println("
");
client.print("Humidity : ");
client.print(h);
client.print("%");
client.println("
");client.println("");
client.println("");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}