ESP8266 Primary GUI

cino111
Posty: 714
Rejestracja: pn maja 07, 2018 8:00 pm

Espablo pisze: pt maja 03, 2019 5:04 pm Trochę się odgrzebałem zawodowo i znowu będę miał czas na SUPLE. Niebawem zapodam poprawiony kod.
Espablo czy da radę na twojej bibliotece skompilować program pod Arduino Mega? Zależy mi żeby moduł był podłączony LANem
Zmodyfikowałem program jak niżej, ale ciągle mam błąd:

exit status 1
Błąd kompilacji dla płytki Arduino/Genuino Mega or Mega 2560.


Kod: Zaznacz cały





#define SUPLADEVICE_CPP
#include <SuplaDevice.h>

#include <OneWire.h>
#include <DallasTemperature.h>
#include <DHT.h>

// linki bezposrednie

#include "supla_settings.h"

#include "supla_board_settings.h"






int nr_button = 0;
int nr_relay = 0;
int invert = 0;
int nr_ds18b20 = 0;
int nr_dht = 0;
int dht_channel[MAX_DHT];
int ds18x20_channel[MAX_DS18B20];
int relay_button_channel[MAX_RELAY];



// Setup a DHT instance
//DHT dht(DHTPIN, DHTTYPE);
DHT dht_sensor[MAX_DHT] = {
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
  { 0, 0 },
};

// Setup a DS18B20 instance
//OneWire oneWire(DS18B20PIN);
//DallasTemperature sensors(&oneWire);

OneWire ds18x20[MAX_DS18B20] = { 0, 0, 0, 0, 0, 0, 0, 0 };
//const int oneWireCount = sizeof(ds18x20) / sizeof(OneWire);
DallasTemperature sensor[MAX_DS18B20];
DeviceAddress deviceAddress;

void setup() {
  Serial.begin(74880);
 

  supla_board_configuration();

  



  SuplaDevice.setStatusFuncImpl(&status_func);
 

  // Replace the falowing GUID
  char GUID[SUPLA_GUID_SIZE] = {0xBE,0x27,0x48,0x7B,0xB2,0xC,0xB5,0x48,0xFD,0x9D};
  // with GUID that you can retrieve from https://www.supla.org/arduino/get-guid


  // Ethernet MAC address
  uint8_t mac[6] = {0x00, 0x05, 0x04, 0x03, 0x02, 0x01};



  supla_ds18b20_start();
  supla_dht_start();
  /*
     // CHANNEL0 - TWO RELAYS (Roller shutter operation)
    SuplaDevice.addRollerShutterRelays(5,     // 46 - Pin number where the 1st relay is connected
                                       13);    // 47 - Pin number where the 2nd relay is connected


    SuplaDevice.setRollerShutterButtons(0,    // 0 - Channel Number
                                        14,   // 20 - Pin where the 1st button is connected
                                        12);  // 21 - Pin where the 2nd button is connected

  */

  SuplaDevice.begin(GUID,              // Global Unique Identifier
                    mac,               // Ethernet MAC address
                    "192.168.1.10",  // SUPLA server address
                    1,                 // Location ID
                    "xxxx");


}

//*********************************************************************************************************

void loop() {
   SuplaDevice.iterate();
}
//*********************************************************************************************************








void get_temperature_and_humidity(int channelNumber, double *temp, double *humidity) {
  *temp = dht_sensor[channelNumber].readTemperature();
  *humidity = dht_sensor[channelNumber].readHumidity();
  //  static uint8_t error;
  //  Serial.print("get_temperature_and_humidity - "); Serial.print(channelNumber); Serial.print(" -- "); Serial.print(*temp); Serial.print(" -- "); Serial.println(*humidity);
  if ( isnan(*temp) || isnan(*humidity) ) {
    *temp = -275;
    *humidity = -1;
    //    error++;
  }
  //  Serial.print("error - "); Serial.println(error);
}

double get_temperature(int channelNumber, double last_val) {
  double t = -275;
  if ( sensor[channelNumber].getDeviceCount() > 0 ) {
    sensor[channelNumber].requestTemperatures();
    t = sensor[channelNumber].getTempCByIndex(0);
    if (t == -127) t = -275;
  }
  return t;
}

void supla_led_blinking_func(void *timer_arg) {
  int val = digitalRead(LED_CONFIG_PIN);
  digitalWrite(LED_CONFIG_PIN, val == HIGH ? 0 : 1);
}

void supla_led_blinking(int led, int time) {

  os_timer_disarm(&led_timer);
  os_timer_setfn(&led_timer, supla_led_blinking_func, NULL);
  os_timer_arm (&led_timer, time, true);

}

void supla_led_blinking_stop(void) {
  os_timer_disarm(&led_timer);
  digitalWrite(LED_CONFIG_PIN, 1);
}

void supla_led_set(int ledPin) {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, 1);
}

void supla_ds18b20_start(void) {
  for (int i = 0; i < MAX_DS18B20; i++) {
    sensor[i].setOneWire(&ds18x20[i]);
    sensor[i].begin();
    if (sensor[i].getAddress(deviceAddress, 0)) sensor[i].setResolution(deviceAddress, TEMPERATURE_PRECISION);
  }
}

void supla_dht_start(void) {
  for (int i = 0; i < MAX_DHT; i++) {
    dht_sensor[i].begin();
  }
}

void add_Sensor(int sensor) {
  SuplaDevice.addSensorNO(sensor);
}

void add_Roller_Shutter_Buttons(int channel, int button1, int button2) {
  SuplaDevice.setRollerShutterButtons(channel, button1, button2);
}

void add_Roller_Shutter_Relays(int relay1, int relay2) {
  SuplaDevice.addRollerShutterRelays(relay1, relay2);
  //  SuplaDevice.setRollerShutterFuncImpl(&supla_rs_SavePosition, &supla_rs_LoadPosition, &supla_rs_SaveSettings, &supla_rs_LoadSettings);
}

void add_Led_Config(int led) {
  supla_led_set(led);
}

void add_Relay(int relay) {
  SuplaDevice.addRelay(relay);
  relay_button_channel[nr_relay] = relay;
  nr_relay++;
}

void add_Relay_Invert(int relay) {
  SuplaDevice.addRelay(relay, true);
  relay_button_channel[nr_relay] = relay;
  nr_relay++;
}

void add_DHT11_Thermometer(int thermpin) {
  int channel = SuplaDevice.addDHT11();
  dht_sensor[channel] = { thermpin, DHT11 };
  dht_channel[nr_dht] = channel;
  nr_dht++;
}

void add_DHT22_Thermometer(int thermpin) {
  int channel = SuplaDevice.addDHT22();
  dht_sensor[channel] = { thermpin, DHT22 };
  dht_channel[nr_dht] = channel;
  nr_dht++;
}

void add_DS18B20_Thermometer(int thermpin) {
  int channel = SuplaDevice.addDS18B20Thermometer();
  ds18x20[channel] = thermpin;
  ds18x20_channel[nr_dht] = channel;
  nr_ds18b20++;
}

void add_Relay_Button(int relay, int button, int type) {
  relay_button_channel[nr_relay] = relay;
  nr_button++;
  nr_relay++;
  if (type == CHOICE_TYPE) {
    int select_button = read_supla_button_type(nr_button);
    type = select_button;
  }

  SuplaDevice.addRelayButton(relay, button, type, read_supla_relay_flag(nr_relay));
}

void add_Relay_Button_Invert(int relay, int button, int type) {
  invert = 1;
  relay_button_channel[nr_relay] = relay;
  nr_button++;
  nr_relay++;
  if (type == CHOICE_TYPE) {
    int select_button = read_supla_button_type(nr_button);
    type = select_button;
  }

  SuplaDevice.addRelayButton(relay, button, type, read_supla_relay_flag(nr_relay), true);
}
arekrgw
Posty: 44
Rejestracja: śr sie 15, 2018 6:42 pm

Witam, czy jest możliwość aby zapobiec przełączaniu przekaźników podczas podłączania do zasilania? Próbowałem kilku sposobów ale niestety zawiodły. Testowałem na Sonoff Basic.
gbiel
Posty: 30
Rejestracja: ndz cze 04, 2017 11:57 am

Espablo pisze: pt maja 03, 2019 5:04 pm Trochę się odgrzebałem zawodowo i znowu będę miał czas na SUPLE. Niebawem zapodam poprawiony kod.
Jakiś przybliżony termin ?
flisiu
Posty: 17
Rejestracja: sob sty 07, 2017 4:08 am

Witam
Mam problem z kompilacją programu dla funkcji rollershutter, wysypuje się na 3 linii


add_Roller_Shutter_Relays(5, 13);
add_Roller_Shutter_Buttons(0, 14, 12);
SuplaDevice.setRollerShutterFuncImpl(&supla_rs_SavePosition, &supla_rs_LoadPosition, &supla_rs_SaveSettings, &supla_rs_LoadSettings);

z kodem błędu:

supla_board_settings.cpp:36:115: error: 'supla_rs_LoadSettings' was not declared in this scope

SuplaDevice.setRollerShutterFuncImpl(&supla_rs_SavePosition, &supla_rs_LoadPosition, &supla_rs_SaveSettings, &supla_rs_LoadSettings);

exit status 1
'supla_rs_SavePosition' was not declared in this scope

czy ktoś może mi poradzić gdzie szukać błędu i jak to rozwiązać?
Kiedy kompiluję bez tej linii kompilacja przebiega poprawnie lecz przekaźniki nie pracują poprawnie.
Z góry dziękuję za podpowiedź.
Awatar użytkownika
pzygmunt
Posty: 18284
Rejestracja: wt sty 19, 2016 9:26 am
Lokalizacja: Paczków
Kontakt:

Brakuje Ci funkcji supla_rs_LoadPosition
flisiu
Posty: 17
Rejestracja: sob sty 07, 2017 4:08 am

A jak to dodać?
Kompiluję dla płytki wemos
cino111
Posty: 714
Rejestracja: pn maja 07, 2018 8:00 pm

Dziś skompilowałem soft z kilkoma przekaźnikami. Ustawiłem przekaźniki z pamięcią stanu, ale po zaniku zasilania przekaźniki nie wracają do poprzedniego stanu. Też tak macie?
Rafaello
Posty: 108
Rejestracja: ndz maja 29, 2016 1:34 pm

Witam

Czy udało się komuś odpalić np. dwa DSy, kombinuje i nic, próbowałem wielu kombinacji na jednym pinie na dwóch, widzi tylko jeden czujnik, w cloud pokazuje dwa termometry z tą samą temperaturą z jednego czujnika. Przekaźniki natomiast działają wyśmienicie.
Awatar użytkownika
wojtas567
Posty: 2209
Rejestracja: ndz kwie 03, 2016 7:16 pm
Lokalizacja: Olsztyn

A jak masz ustawione tu te DS?
add_DHT22_Thermometer(2);
add_DS18B20_Thermometer(2);
...
Pozdrawiam
Wojtek
cino111
Posty: 714
Rejestracja: pn maja 07, 2018 8:00 pm

Dajesz po jednym ds na gpio i możesz ich dać nawet 9. Normalnie dziala.
ODPOWIEDZ

Wróć do „Nowości”