• 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
Ciągły błąd kompilacji
#1
Mam taki kod:
Kod:
/**
 * Supla.org NodeMCU WiFi minimal example
 * Author: Programistyk - Kamil Kaminski <kamil@programistyk.pl>
 *
 * This example shows how to configure SuplaDevice for building for NodeMCU within Arduino IDE
 */
#include <OneWire.h>
#include <DallasTemperature.h>

#include <srpc.h>
#include <log.h>
#include <eh.h>
#include <proto.h>
#include <IEEE754tools.h>
// We define our own ethernet layer
#define SUPLADEVICE_CPP
#include <SuplaDevice.h>
#include <lck.h>
#include <WiFiClient.h>
#include <ESP8266WiFiType.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiServer.h>
#include <ESP8266WiFiGeneric.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiSTA.h>
#include <WiFiUdp.h>
// Setup a oneWire instance
OneWire oneWire(2); // D4 GPIO 2 - Pin number
// Pass oneWire reference to Dallas Temperature
DallasTemperature sensors(&oneWire);

WiFiClient client;
// Setup Supla connection
const char* ssid     = "AAAAAA" ;
const char* password = "xxxxxx";

// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {
    double t = -275;
   
    if ( sensors.getDeviceCount() > 0 )
      {
         sensors.requestTemperatures();
         t = sensors.getTempCByIndex(0);
      };
    return t; 
}
void setup() {
  Serial.begin(115200);
 
     // Init DS18B20 library
        sensors.begin();
 
       
  delay(10);
  // Replace the falowing GUID
  char GUID[SUPLA_GUID_SIZE] = {0x1D,0xE2,0xA9,0x88,0x44,0x11,0x9B,0x88,0x41,0x37,0xF0,0xD5,0x3C,0xEE,0x63,0xE6};
  // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
  // Ethernet MAC address
  uint8_t mac[6] = {0x02, 0x02, 0x00, 0x02, 0x05, 0x06};
  /*
   * Having your device already registered at cloud.supla.org,
   * you want to change CHANNEL sequence or remove any of them,
   * then you must also remove the device itself from cloud.supla.org.
   * Otherwise you will get "Channel conflict!" error.
   */
 
    // CHANNEL 0
    SuplaDevice.addDS18B20Thermometer(); //czujnik temperatury DS18B20 na D2 GPIO-4
   
  // CHANNEL1 - RELAY
  SuplaDevice.addRelay(D1, true);      // GPIO5 - Pin number where the relay is connected     
                                      // Call SuplaDevice.addRelay(D1, true) with an extra "true" parameter
                                      // to enable "port value inversion"
                                      // where HIGH == LOW, and LOW == HIGH  
  // CHANNEL2 - RELAY
 SuplaDevice.addRelay(D2, true);           // GPIO4 - Pin dla przekaznika - dopisanie true odwraca logikę, czyli dla przekaznikow zalaczanych masa
                                            // omijam D3 gdyz jest to GPIO 0 i sluzy do flashowania
 // CHANNEL3 - RELAY
 SuplaDevice.addRelay(D6, true);           // GPIO2 - Pin number where the relay is connected   
  // CHANNEL4 - RELAY
 SuplaDevice.addRelay(D5, true);           // GPIO14 - Pin number where the relay is connected 
 // CHANNEL5 - Opening sensor (Normal Open)
 // SuplaDevice.addSensorNO(D5); // 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

  // CHANNEL5 - Opening sensor (Normal Open)
  //SuplaDevice.addSensorNO(D7); // A1 - Pin number where the sensor is connected

  // CHANNEL6 - DHT22 Sensor
  // SuplaDevice.addDHT11();
  // SuplaDevice.addAM2302();
  // SuplaDevice.addDHT22();
  SuplaDevice.begin(GUID,              // Global Unique Identifier
                    mac,               // Ethernet MAC address
                    "xxxxx.supla.org",  // SUPLA server address
                    yyyyy,                 // Location ID
                    "1234");               // Location Password
}
void loop() {
  SuplaDevice.iterate();
}
// Supla.org ethernet layer
    int supla_arduino_tcp_read(void *buf, int count) {
        _supla_int_t size = client.available();
      
        if ( size > 0 ) {
            if ( size > count ) size = count;
            return client.read((uint8_t *)buf, size);
        };
   
        return -1;
    };
   
    int supla_arduino_tcp_write(void *buf, int count) {
        return client.write((const uint8_t *)buf, count);
    };
   
    bool supla_arduino_svr_connect(const char *server, int port) {
          return client.connect(server, 2015);
    }
   
    bool supla_arduino_svr_connected(void) {
          return client.connected();
    }
   
    void supla_arduino_svr_disconnect(void) {
         client.stop();
    }
   
    void supla_arduino_eth_setup(uint8_t mac[6], IPAddress *ip) {
       // Serial.println("WiFi init");
        WiFi.begin(ssid, password);
        while (WiFi.status() != WL_CONNECTED) {
            delay(500);
        //    Serial.print(".");
        }
        //Serial.print("\nlocalIP: ");
        //Serial.println(WiFi.localIP());
        //Serial.print("subnetMask: ");
        //Serial.println(WiFi.subnetMask());
        //Serial.print("gatewayIP: ");
        //Serial.println(WiFi.gatewayIP());
    }
SuplaDeviceCallbacks supla_arduino_get_callbacks(void) {
          SuplaDeviceCallbacks cb;
         
          cb.tcp_read = &supla_arduino_tcp_read;
          cb.tcp_write = &supla_arduino_tcp_write;
          cb.eth_setup = &supla_arduino_eth_setup;
          cb.svr_connected = &supla_arduino_svr_connected;
          cb.svr_connect = &supla_arduino_svr_connect;
          cb.svr_disconnect = &supla_arduino_svr_disconnect;
          cb.get_temperature = &get_temperature;
          cb.get_temperature_and_humidity = NULL;
          cb.get_rgbw_value = NULL;
          cb.set_rgbw_value = NULL;
       
          return cb;
}
Nie udaje mi się wgrać na żadną płytkę. Ani ESP8266 ani na ESP32.
Coś jest nie tak z tym kodem czy coś w moim laptopie i programem?
Może ktoś mi pomoże? Mogę wkleić błędy.
Dzięki
PS Może coś da się usunąć z tego programu. Potrzebuje tylko DS18B20 i potem sterowanie bramy.
 
Odpowiedź
  


Wiadomości w tym wątku
Ciągły błąd kompilacji - przez OMK - 26-01-2020, 21:56
RE: Ciągły błąd kompilacji - przez Robson Kerman - 26-01-2020, 22:59
RE: Ciągły błąd kompilacji - przez OMK - 30-01-2020, 00:59
RE: Ciągły błąd kompilacji - przez -adamek - 30-01-2020, 16:10

Skocz do:


Przeglądający: 1 gości