• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Czujnik DS18B20 i moduł Ethernet ENC28J60
#1
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.
 
Odpowiedź
#2
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
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości