Go Down

Topic: Arduino Uno v3 + Ethernet Shield (W5100) + LED Display (SSD1306) + DS18B20 (Read 43 times) previous topic - next topic

I apologize for my English.
I can not get to work together Arduino Uno v3 + Ethernet Shield (W5100) + LED Display (SSD1306) + DS18B20. And to be precise, Ethernet Shield + LED Display. We obtain the following. Does not work Etnernet Schild and even in the console there is no output, although the network interface is available, pinged. The display works fine.
Poke nose that I'm doing wrong. Pinout from Shield watched, display and sensor sitting on the other outputs.

Code: [Select]
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Ethernet.h>

#define OLED_MOSI  3 //D0
#define OLED_CLK   5 //D1
#define OLED_DC    6
#define OLED_CS    7
#define OLED_RESET 8


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,121,1,24);
EthernetServer server(80);

Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#define ONE_WIRE_BUS 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(9600);
   while (!Serial) {
    ;
  }

  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());

  display.begin(SSD1306_SWITCHCAPVCC);

  sensors.begin();
}


void loop() {
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
 
 
  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setCursor(10,10);
  display.clearDisplay();
  display.println(tempC);
  display.display();

 

  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
//        Serial.write(c);
        if (c == '\n' && currentLineIsBlank) {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
  client.println("Refresh: 5");
          client.println();
          client.println("<!DOCTYPE HTML>");

          client.println("<html>");
          client.println(tempC);
          Serial.println(tempC);
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          currentLineIsBlank = false;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disconnected");
  }
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy