0

I am using Arduino Uno R3 board and a wiznet W5100 ethernet Shield. The temperature from the One wire sensors before using Ethernet Shield was showing correct. However later after connecting the shield, the temperature is showing to be 85. The server and everything else works fine, but the data is all wrong. Now I am pretty sure the connections are correct and it is not in parasite mode. Any suggestions of how I might get the accurate reading ?

/*
  Web Server

  A simple web server that shows the value of the analog input pins.
  using an Arduino Wiznet Ethernet shield.

*/

#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
            0xF0, 0xBF, 0x97, 0x67, 0xF6, 0x98
        };
IPAddress ip(192, 168, XXX, XXX);

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
EthernetServer server(80);

void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(9600);
    sensors.begin();
    while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
    }
    // start the Ethernet connection and the server:
    Ethernet.begin(mac, ip);
    server.begin();
    Serial.println(sensors.getTempCByIndex(0));
    Serial.print("Siddhartha Temperature ");
    Serial.print("server is at ");
    Serial.println(Ethernet.localIP());
}

void loop() {
    // 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("Connection: close");  
                    client.println("Refresh: 2");
                    client.println();
                    client.println("<!DOCTYPE HTML>");
                    client.println("<html>");
                    // output the value of each analog input pin
                    for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                        float sensorReading = sensors.getTempCByIndex(0);
                        client.print("Temperature ");
                        client.print(analogChannel);
                        client.print(" is ");
                        client.print(sensorReading);
                        Serial.println(sensorReading);
                        client.println("<br />");
                    }
                    client.println("</html>");
                    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 disconnected");
    }
}
3
  • The power-on reset value of the temperature register is 85 degC. Is it possible that something is interrupting the power to your sensors?
    – JRobert
    Apr 10 '15 at 23:49
  • I highly doubt that ! I checked it using the multimeter, and everythings connected just as fine.
    – Siddian93
    Apr 11 '15 at 9:38
  • It looks like digital pin 2 might be connected (solder jumper) to the INT pin of the W5100. Try using pin 3 instead.
    – Gerben
    Apr 11 '15 at 15:20
0

The Solution was actually much simpler. Apparently the Ground on the voltage I/O ports wasn't the right place to connect the ground terminal of the sensor. rather The Ground of the Digital I/O should be connected. Mistake retrieved by trail and error!! Its working just fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.