Проблема с ENC28J60 и DS18B20

Тема в разделе "Arduino & Shields", создана пользователем Grek1130, 9 дек 2016.

  1. Grek1130

    Grek1130 Нуб

    Здравствуйте!
    Имеется 6 датчиков температуры и ENC28J60. Окно в браузере должно обновляться каждые несколько секунд. Все работает без строки
    ds.requestTemperatures();
    Может ее в другое какое место прикрутить?

    #include <UIPEthernet.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #define POWER_MODE 0 //внешнее питание датчиков

    byte mac[] = {
    0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    IPAddress ip(192,168,1,150);
    EthernetServer server(80);
    OneWire oneWire(9);//вход датчиков 18b20
    DallasTemperature ds(&oneWire);

    DeviceAddress sensor1 = {0x28, 0xFF, 0x25, 0xC9, 0x70, 0x16, 0x04, 0x00};
    DeviceAddress sensor2 = {0x28, 0xFF, 0x1E, 0x18, 0x71, 0x16, 0x03, 0x52};
    DeviceAddress sensor3 = {0x28, 0xFF, 0x99, 0x40, 0x72, 0x16, 0x03, 0xE8};
    DeviceAddress sensor4 = {0x28, 0xCD, 0xB3, 0x1E, 0x00, 0x00, 0x80, 0x6B};
    DeviceAddress sensor5 = {0x28, 0xFF, 0xF6, 0x24, 0x72, 0x16, 0x03, 0x08};
    DeviceAddress sensor6 = {0x28, 0xFF, 0xBF, 0xE6, 0x71, 0x16, 0x04, 0x4B};
    float Temp1;
    float Temp2;
    float Temp3;
    float Temp4;
    float Temp5;
    float Temp6;


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

    pinMode (A0,INPUT); //Р1
    pinMode (A1,INPUT); //Р2
    pinMode (A2,INPUT); //Р3
    pinMode (A3,INPUT); //Р3
    pinMode (A4,INPUT); //York1
    pinMode (A5,INPUT); //York2
    ds.begin();
    }

    void loop() {
    ds.requestTemperatures(); // считываем температуру с датчиков
    Temp2=ds.getTempC(sensor2);
    Temp3=ds.getTempC(sensor3);
    Temp4=ds.getTempC(sensor4);
    Temp5=ds.getTempC(sensor5)+1;
    Temp6=ds.getTempC(sensor6)+1;

    // 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"); // the connection will be closed after completion of the response
    client.println("Refresh: 5"); // refresh the page automatically every 5 sec

    client.println();
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");

    client.println("<html><H1><FONT COLOR = #402CF5>Приточки стр.1</FONT></H1>");
    client.println("<H2>П1 <FONT COLOR = #030305>");
    client.println(Temp1);
    client.println("</FONT> ºC");
    if (digitalRead(A0) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р1
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");

    client.println("</H2><H2>П2 ");
    client.println(Temp2);
    client.println(" ºC");
    if (digitalRead(A1) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р2
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");

    client.println("</H2><H2>П3 ");
    client.println(Temp3);
    client.println(" ºC");
    if (digitalRead(A2) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р2
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");

    client.println("</H2><H2>П4 ");
    client.println(Temp4);
    client.println(" ºC");
    if (digitalRead(A3) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р2
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");

    client.println("</H2><H2>York1 ");
    client.println(Temp5);
    client.println(" ºC");
    if (digitalRead(A4) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р2
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");

    client.println("</H2><H2>York2 ");
    client.println(Temp6);
    client.println(" ºC");
    if (digitalRead(A5) == HIGH)client.println("<H2><FONT COLOR = #402CF5>ON</FONT>"); //работа Р2
    else client.println("<H2><FONT COLOR = red>OFF</FONT>");
    client.println("</H2>");

    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 disonnected");

    }
    }
     
  2. Grek1130

    Grek1130 Нуб

    Заработало! Убрал строку
    ds.begin();
     
  3. Grek1130

    Grek1130 Нуб

    А то даже не пинговалось. Но в arp -a адрес был.