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);
}