Hello, I'm running following code on an arduino with ethernetshield:
#include <Ethernet.h>
#include <SHT1x.h>
#include <SPI.h>byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; // RESERVED MAC ADDRESS
IPAddress ip(192, 168, 2, 177);EthernetClient client;
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 51
#define clockPin 53
SHT1x sht1x(dataPin, clockPin);void setup()
{
Serial.begin(19200); // Open serial connection to report values to host
Serial.println("Starting up");
}void loop()
{
float temp_c;
float temp_f;
float humidity;// Read values from the sensor
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();// Print the values to the serial port
Serial.print("Temperature: ");
Serial.print(temp_c, DEC);
Serial.print("C / ");
Serial.print(temp_f, DEC);
Serial.print("F. Humidity: ");
Serial.print(humidity);
Serial.println("%");
Ethernet.begin(mac, ip);
if (client.connect("XXXXX.de",80)) { // REPLACE WITH YOUR SERVER ADDRESS
client.println("POST /add.php HTTP/1.1");
client.println("Host: XXXXXX.de"); // SERVER ADDRESS HERE TOO
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
//client.println(data.length());
client.println();
client.print("temp=");
client.print(temp_c);
client.print("&");
client.print("humidity=");
client.print(humidity);
} else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");}
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}delay(2000);
}
I don't get any correct values. When i delete the ethernet-client part in the code i get correct values. What could be the problem? The SHT11 is not connected to pins 10 and 11 which are reserved for the ethernet shield.