Mega brak łączenia z Internetem

patrykelek
Posty: 7
Rejestracja: czw wrz 19, 2019 7:53 pm

wt gru 29, 2020 3:26 pm

Hej,
mam problem z łączeniem z mega przez enc28j60
serial wyrzuca coś takiego
(ocalIP: 0.0.0.0
subnetMask: 0.0.0.0
gatewayIP: 0.0.0.0
dnsServerIP: 0.0.0.0
SuplaDevice initialized
Not connected
Register in progress
Not connected
Register in progress

kabel sprawny , połączenia przewodów są ok
Proszę o waszą pomoc

poniżej kod

Kod: Zaznacz cały

#include <SPI.h>
#include <UIPEthernet.h>
#include <SuplaDevice.h>
#include <OneWire.h>
#include <DallasTemperature.h>
int redLed = 43;
int smokeA0 = A5;
 
// Setup a oneWire instance
OneWire oneWire(42); // 24 - Pin number

// Pass oneWire reference to Dallas Temperature
DallasTemperature sensors(&oneWire);

DeviceAddress piwnica = { 0x28, 0xFF, 0x8A, 0x4D, 0x40, 0x18, 0x2, 0x54};       
DeviceAddress korytarz = { 0x28, 0xFF, 0x13, 0x9C, 0x2, 0x17, 0x4, 0x25 };    
// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {

    double t = -275;
    
    if ( sensors.getDeviceCount() > 0 )
      {
         sensors.requestTemperatures();
         switch(channelNumber)

          {
            case 0:
                   
                    t = sensors.getTempC(piwnica);
                    break;
            case 1:
                    t = sensors.getTempC(korytarz);
                    break;
           
              
          
             };
      };

    return t;  



}
    
void setup() {

  Serial.begin(9600);

  // Init DS18B20 library 
  sensors.begin();
  
  // Set temperature callback
   SuplaDevice.setTemperatureCallback(&get_temperature);
 pinMode (45, INPUT_PULLUP); //ustawiamy Pin 16 (D0) na przycisk
  pinMode(44,OUTPUT);
   pinMode(redLed, OUTPUT);
  pinMode(smokeA0, INPUT);
  // Replace the falowing GUID
  char GUID[SUPLA_GUID_SIZE] = {0x85,0x6B,0x6D,0x58,0x1D,0x72,0x40,0xBF,0x88,0x7D,0x7A,0x39,0xFF,0x13,0xAC,0xC3};
  // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid


  // Ethernet MAC address
  uint8_t mac[6] = {0x98, 0x79, 0x9D, 0xF2, 0x89, 0x25};

   // CHANNEL0 - Thermometer DS18B20
  SuplaDevice.addDS18B20Thermometer();

   // CHANNEL1 - Thermometer DS18B20
  SuplaDevice.addDS18B20Thermometer(); 
  // CHANNEL2 - RELAY
  SuplaDevice.addRelay(47, true);           // 44 - Pin number where the relay is connected      
                                      // Call SuplaDevice.addRelay(44, true) with an extra "true" parameter 
                                      // to enable "port value inversion"
                                      // where HIGH == LOW, and LOW == HIGH   

  // CHANNEL3 - RELAY
  SuplaDevice.addRelay(48, true);           // 45 - Pin number where the relay is connected   

    // CHANNEL4 - RELAY
  SuplaDevice.addRelay(49, true);    // 47 - Pin number where the 2nd relay is connected  

  // CHANNEL5 - Opening sensor (Normal Open)
  SuplaDevice.addSensorNO(45); // A0 - Pin number where the sensor is connected
                               // Call SuplaDevice.addSensorNO(A0, true) with an extra "true" parameter
                               // to enable the internal pull-up resistor


  
  

  SuplaDevice.begin(GUID,              // Global Unique Identifier 
                    mac,               // Ethernet MAC address
                    "svr1.supla.org",  // SUPLA server address
                    xxxx,                 // Location ID 
                    "xxxx");               // Location Password
    
}

void loop() {
  SuplaDevice.iterate();

if(digitalRead(45)==LOW){
  digitalWrite(44,HIGH);
}
else {
  digitalWrite(44,LOW);
}

 int analogSensor = analogRead(smokeA0);
  //Serial.println(analogSensor);
  if (analogSensor > 400)
  {
    digitalWrite(redLed, HIGH);
  }
  else
  {
    digitalWrite(redLed, LOW);
  }
  delay(100);
  
 
}
  
Awatar użytkownika
klew
Posty: 1786
Rejestracja: czw cze 27, 2019 12:16 pm

wt gru 29, 2020 4:40 pm

Pobierz bibliotekę z brancha develop https://github.com/SUPLA/arduino/tree/develop

Ale nie polecam tego układu do sieci. W readme jest opisane kilka problemów
ODPOWIEDZ

Wróć do „FAQ / Jak to zrobić”