Arduino Polska Forum
Czujnik DS18B20 i moduł Ethernet ENC28J60 - Wersja do druku

+- Arduino Polska Forum (https://forum.arduinopolska.pl)
+-- Dział: Korzystanie z Arduino (https://forum.arduinopolska.pl/dzial-korzystanie-z-arduino)
+--- Dział: Sieciowe Protokoły i Urządzenia (https://forum.arduinopolska.pl/dzial-sieciowe-protoko%C5%82y-i-urz%C4%85dzenia)
+--- Wątek: Czujnik DS18B20 i moduł Ethernet ENC28J60 (/watek-czujnik-ds18b20-i-modu%C5%82-ethernet-enc28j60)



Czujnik DS18B20 i moduł Ethernet ENC28J60 - magikKSG - 20-07-2020

Proszę o pomoc w takiej sytuacji:
Arduino UNO + moduł Ethernet ENC28J60. Wszystko skonfigurowane i działa prawidłowo.

Jednak, gdy podłączę do Arduino (port A2) czujnik temperatury DS18B20 to zachodzi takie zjawisko, że na monitorze portu szeregowego mam prawidłową wartość temperatury, ale przestaje działać moduł ethernet (brak pingu i dostępu http). W momencie jak wyjmę czujnik to natychmiast sieć ethernet rusza. 

Poniżej mój kod.
Kod:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <EtherCard.h>

#define STATIC 1
#if STATIC
static byte myip[] = { 10,18,26,41 };
static byte gwip[] = { 10,18,26,1 };
#endif

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[500];

const char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "<h3>This service is currently unavailable</h3>"
    "<p><em>"
      "The main server is currently off-line.<br />"
      "Please try again later."
    "</em></p>"
  "</body>"
"</html>"
;

OneWire oneWire(A2);
DallasTemperature sensors(&oneWire);

void setup(){
  Serial.begin(57600);
  sensors.begin();
 
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
    Serial.println( "Failed to access Ethernet controller");
#if STATIC
  ether.staticSetup(myip, gwip);
#else
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
#endif

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);
}

void loop(){
   sensors.requestTemperatures();
   float x=sensors.getTempCByIndex(0);
   Serial.println(x);

    if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
 
}
Jak nie wywołuję metody sensors.requestTemperatures() w loop, to moduł sieciowy działa (oczywiście nie ma zmierzonej temperatury). Nic innego do Arduino nie jest podłączone.
Gdy zastosuję program test z przykładu pochodzącego z biblioteki Dallas temperature i komunikuję się z portem cyfrowym w Arduino to sytuacja jest identyczna.

Pozdrawiam i proszę o pomoc.


RE: Czujnik DS18B20 i moduł Ethernet ENC28J60 - Xenu - 20-07-2020

Jeżeli nie działa ci biblioteka EtherCard.h to użyj standardowej biblioteki ethernet która jest na oficjalnej stronie arduino.
Próbowałeś na innym analogu ? (sorki za orto) PS jak niby odczytujesz informacje po analogu z czujnika cyfrowego ? xD