Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Русский
    3. ioBroker
    4. Скрипты
    5. ioBroker скрипты
    6. Скрипт для счётчика

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Скрипт для счётчика

    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      instalator last edited by

      @smoker_vvo:

      А вот тут и возникла проблема… Не заливаются скетчи.... любая попытка заканчивается ошибкой закачки скетча.... И бешеный светодиод...... `
      Прошей загрузчик оптибут или шей ее через программатор

      1 Reply Last reply Reply Quote 0
      • S
        smoker_vvo last edited by

        Ну тогда давай рекомендации что и как делать, через что прошивать, у меня голова опухла от обилия информации о прошивке оптибута

        1 Reply Last reply Reply Quote 0
        • I
          instalator last edited by

          @smoker_vvo:

          Ну тогда давай рекомендации что и как делать, через что прошивать, у меня голова опухла от обилия информации о прошивке оптибута `

          http://blog.instalator.ru/archives/798

          1 Reply Last reply Reply Quote 0
          • S
            smoker_vvo last edited by

            Доброго времени…

            Появилось время заниматься проектом дальше. и вот какие проблемы, если с WDT я поступил грубо, просто закоментил его, то с ethernetom вообще ни чего не могу понять. Учитывая что у тебя была другая карта, использую библиотеку для своей.... и ничего не работает....

            1. ping - ни чего нет

            2. соответсвенно в IOBе то же тишина.

            заливал другие скетчи - с сетевой проблем нет.

            вот код :

            ! ```
            #include <spi.h> #include <ethernet.h> #include <pubsubclient.h> #include <eeprom.h> //#include <avr wdt.h=""> ! #define PWR_CTRL A2 //Контроль напряжения #define LED 9 //Светодиод #define CHK_ADR 100 #define CNT_ADR 10 #define PWR_ADR 20 #define POLL_ADR 30 #define RATIO_ADR 40 ! const char* topic_err = "myhome/elcounter/error"; const char* topic_cnt = "myhome/elcounter/count"; const char* topic_pwr = "myhome/elcounter/power"; const char* topic_amp = "myhome/elcounter/amp"; const char* topic_save = "myhome/elcounter/save"; const char* topic_correction = "myhome/elcounter/correction"; const char* topic_connection = "myhome/elcounter/connection"; const char* topic_ip = "myhome/elcounter/config/ip"; const char* topic_polling = "myhome/elcounter/config/polling"; const char* topic_bounce = "myhome/elcounter/config/bounce"; const char* topic_num = "myhome/elcounter/config/num"; const char* topic_reset = "myhome/elcounter/config/reset"; const char* topic_raw = "myhome/elcounter/RAW"; const char* subscr = "myhome/elcounter/#"; ! byte mac[] = { 0xDE, 0xAD, 0xBE, 0xE4, 0xDE, 0x35 }; byte ip[] = { 192, 168, 0, 89}; byte server[] = { 192, 168, 0, 15}; ! unsigned long cnt = 0; unsigned long prev_cnt = 2; unsigned long pwr = 0; unsigned long prev_pwr = 2; int amp = 0; int prev_amp = 2; int num = 0; int prev_num; int bounce = 10; int prev_bounce; int chk = 0; int chk_S = 0; unsigned long prevMillis = 0; unsigned long prevMillis_cnt = 0; int poll = 5000; bool error = 0; String cmd = ""; bool strComplete = false; char buf [50]; char buffer[100]; char s[16]; ! //////////////////////////////////////////////////////////////////////////// void callback(char* topic, byte* payload, unsigned int length) { payload[length] = '\0'; String strTopic = String(topic); String strPayload = String((char*)payload); callback_iobroker(strTopic, strPayload); } ! EthernetClient ethClient; PubSubClient client(server, 1883, callback, ethClient); ! void setup() { MCUSR = 0; // wdt_disable(); Serial.println("WDT_disable"); cmd.reserve(100); delay(10000); Serial.begin(57600); Serial.println("Starting......"); ! if (EEPROM.read(1) != 99) { //Если первый запуск EEPROM.write(1, 99); for (int i = 0 ; i < 4; i++) { EEPROM.write(110 + i, ip[i]); } for (int i = 0 ; i < 4; i++) { EEPROM.write(120 + i, server[i]); } } else { chk = EEPROMReadInt(CHK_ADR); cnt = EEPROMReadLong(CNT_ADR); poll = EEPROMReadInt(POLL_ADR); chk_S = poll - 500; if (chk != chk_S) { error = 2; } for (int i = 0; i < 4; i++) { ip[i] = EEPROM.read(110 + i); } for (int i = 0; i < 4; i++) { server[i] = EEPROM.read(120 + i); } } ! pinMode(LED, OUTPUT); ! // client.setServer(server, 1883); // client.setCallback(callback); Ethernet.begin(mac, ip); delay(200); //wdt_enable(WDTO_8S); Serial.println("WDTO_8S"); if (client.connect("elcounter")) { digitalWrite(LED, LOW); Public(); } } ! void serialEvent() { while (Serial.available() > 0) { char inChar = (char)Serial.read(); cmd += inChar; if (inChar == '\n') { strComplete = true; } } } ! void callback_iobroker(String strTopic, String strPayload) { if (strTopic == topic_correction) { cnt = atol((strPayload).c_str()); Serial.print("SC"); Serial.println(cnt); client.publish(topic_correction, "0"); } else if (strTopic == topic_save) { if (strPayload == "true") { Serial.println("SS"); save(); client.publish(topic_save, "false"); } } else if (strTopic == topic_polling) { poll = strPayload.toInt(); if (poll < 1000) { poll = 1000; } else if (poll > 32767) { poll = 32767; } EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации client.publish(topic_polling, IntToChar(poll)); } else if (strTopic == topic_reset) { if (strPayload == "true") { client.publish(topic_reset, "false"); // reboot(); Serial.println("Reboot"); } } else if (strTopic == topic_bounce) { bounce = strPayload.toInt(); if (bounce < 0) { bounce = 0; } else if (bounce > 10000) { bounce = 10000; } Serial.print("SB"); Serial.println(bounce); client.publish(topic_bounce, IntToChar(bounce)); } else if (strTopic == topic_num) { num = strPayload.toInt(); if (num < 0) { num = 0; } else if (num > 32767) { num = 32767; } Serial.print("SN"); Serial.println(num); client.publish(topic_num, IntToChar(num)); } } ! void save() { chk = poll - 500; EEPROMWriteLong(CNT_ADR, cnt); //Пишем показания счетчика в eeprom из переменной EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации EEPROMWriteInt(CHK_ADR, chk); //чек } ! void reboot() { save(); delay(500); // wdt_enable(WDTO_1S); Serial.println("void reboot"); for (;;) {} } ! char* StrToChar (String str) { int length = str.length(); str.toCharArray(buf, length + 1); return buf; } ! void EEPROMWriteLong(int p_address, unsigned long p_value) { byte four = (p_value & 0xFF); byte three = ((p_value >> 8) & 0xFF); byte two = ((p_value >> 16) & 0xFF); byte one = ((p_value >> 24) & 0xFF); EEPROM.write(p_address, four); EEPROM.write(p_address + 1, three); EEPROM.write(p_address + 2, two); EEPROM.write(p_address + 3, one); } ! unsigned long EEPROMReadLong(int p_address) { long four = EEPROM.read(p_address); long three = EEPROM.read(p_address + 1); long two = EEPROM.read(p_address + 2); long one = EEPROM.read(p_address + 3); return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF); } ! void EEPROMWriteInt(int p_address, int p_value) { byte lowByte = ((p_value >> 0) & 0xFF); byte highByte = ((p_value >> 8) & 0xFF); EEPROM.write(p_address, lowByte); EEPROM.write(p_address + 1, highByte); } unsigned int EEPROMReadInt(int p_address) { byte lowByte = EEPROM.read(p_address); byte highByte = EEPROM.read(p_address + 1); return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00); } ! char* IntToChar (unsigned long a) { sprintf(buf, "%lu", a); return buf; } ! void Public() { sprintf(s, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); client.publish(topic_err, " "); client.publish(topic_cnt, IntToChar(cnt)); client.publish(topic_pwr, IntToChar(pwr)); client.publish(topic_amp, IntToChar(amp)); client.publish(topic_save, "false"); client.publish(topic_correction, "0"); client.publish(topic_connection, "true"); client.publish(topic_ip, s); client.publish(topic_polling, IntToChar(poll)); client.publish(topic_bounce, IntToChar(bounce)); client.publish(topic_num, IntToChar(num)); client.publish(topic_reset, "false"); client.subscribe(subscr); } void reconnect() { int a = 0; while (!client.connected()) { a++; digitalWrite(LED, !digitalRead(LED)); //wdt_reset(); Serial.println("WDT reset"); if (client.connect("elcounter")) { digitalWrite(LED, LOW); Public(); } else { delay(10000); } if (a >= 10) { // wdt_enable(WDTO_1S); Serial.println("WDTO_1S"); } } } ! void loop() { // wdt_reset(); Serial.println("WDT_reset"); client.loop(); if (!client.connected()) { reconnect(); } ! if (analogRead(PWR_CTRL) < 1000) { digitalWrite(LED, LOW); save(); delay(10000); } ! if (strComplete) { digitalWrite(LED, !digitalRead(LED)); cmd.toCharArray(buffer, 100); cnt = atoi(strtok(buffer, ";")); pwr = atoi(strtok(NULL, ";")); amp = atoi(strtok(NULL, ";")); bounce = atoi(strtok(NULL, ";")); num = atoi(strtok(NULL, ";")); error = atoi(strtok(NULL, ";")); client.publish(topic_raw, StrToChar(cmd)); cmd = ""; strComplete = false; } ! if (millis() - prevMillis >= poll) { // wdt_reset(); Serial.println("WDT_reset"); prevMillis = millis(); if (cnt != prev_cnt || pwr != prev_pwr || amp != prev_amp) { prev_cnt = cnt; prev_pwr = pwr; prev_amp = amp; client.publish(topic_cnt, IntToChar(cnt)); client.publish(topic_pwr, IntToChar(pwr)); client.publish(topic_amp, IntToChar(amp)); } if (num != prev_num || bounce != prev_bounce) { prev_num = num; prev_bounce = bounce; client.publish(topic_num, IntToChar(num)); client.publish(topic_bounce, IntToChar(bounce)); } if (error > 0) { client.publish(topic_err, "err"); } else { client.publish(topic_err, " "); } } }</avr></eeprom.h></pubsubclient.h></ethernet.h></spi.h>
            код с моими правками[/i][/i][/i][/i]

            1 Reply Last reply Reply Quote 0
            • I
              instalator last edited by

              @smoker_vvo:

              Доброго времени…

              Появилось время заниматься проектом дальше. и вот какие проблемы, если с WDT я поступил грубо, просто закоментил его, то с ethernetom вообще ни чего не могу понять. Учитывая что у тебя была другая карта, использую библиотеку для своей.... и ничего не работает....

              1. ping - ни чего нет

              2. соответсвенно в IOBе то же тишина.

              заливал другие скетчи - с сетевой проблем нет.

              вот код :

              ! `#include <spi.h> #include <ethernet.h> #include <pubsubclient.h> #include <eeprom.h> //#include <avr wdt.h=""> ! #define PWR_CTRL A2 //Контроль напряжения #define LED 9 //Светодиод #define CHK_ADR 100 #define CNT_ADR 10 #define PWR_ADR 20 #define POLL_ADR 30 #define RATIO_ADR 40 ! const char* topic_err = "myhome/elcounter/error"; const char* topic_cnt = "myhome/elcounter/count"; const char* topic_pwr = "myhome/elcounter/power"; const char* topic_amp = "myhome/elcounter/amp"; const char* topic_save = "myhome/elcounter/save"; const char* topic_correction = "myhome/elcounter/correction"; const char* topic_connection = "myhome/elcounter/connection"; const char* topic_ip = "myhome/elcounter/config/ip"; const char* topic_polling = "myhome/elcounter/config/polling"; const char* topic_bounce = "myhome/elcounter/config/bounce"; const char* topic_num = "myhome/elcounter/config/num"; const char* topic_reset = "myhome/elcounter/config/reset"; const char* topic_raw = "myhome/elcounter/RAW"; const char* subscr = "myhome/elcounter/#"; ! byte mac[] = { 0xDE, 0xAD, 0xBE, 0xE4, 0xDE, 0x35 }; byte ip[] = { 192, 168, 0, 89}; byte server[] = { 192, 168, 0, 15}; ! unsigned long cnt = 0; unsigned long prev_cnt = 2; unsigned long pwr = 0; unsigned long prev_pwr = 2; int amp = 0; int prev_amp = 2; int num = 0; int prev_num; int bounce = 10; int prev_bounce; int chk = 0; int chk_S = 0; unsigned long prevMillis = 0; unsigned long prevMillis_cnt = 0; int poll = 5000; bool error = 0; String cmd = ""; bool strComplete = false; char buf [50]; char buffer[100]; char s[16]; ! //////////////////////////////////////////////////////////////////////////// void callback(char* topic, byte* payload, unsigned int length) { payload[length] = '\0'; String strTopic = String(topic); String strPayload = String((char*)payload); callback_iobroker(strTopic, strPayload); } ! EthernetClient ethClient; PubSubClient client(server, 1883, callback, ethClient); ! void setup() { MCUSR = 0; // wdt_disable(); Serial.println("WDT_disable"); cmd.reserve(100); delay(10000); Serial.begin(57600); Serial.println("Starting......"); ! if (EEPROM.read(1) != 99) { //Если первый запуск EEPROM.write(1, 99); for (int i = 0 ; i < 4; i++) { EEPROM.write(110 + i, ip[i]); } for (int i = 0 ; i < 4; i++) { EEPROM.write(120 + i, server[i]); } } else { chk = EEPROMReadInt(CHK_ADR); cnt = EEPROMReadLong(CNT_ADR); poll = EEPROMReadInt(POLL_ADR); chk_S = poll - 500; if (chk != chk_S) { error = 2; } for (int i = 0; i < 4; i++) { ip[i] = EEPROM.read(110 + i); } for (int i = 0; i < 4; i++) { server[i] = EEPROM.read(120 + i); } } ! pinMode(LED, OUTPUT); ! // client.setServer(server, 1883); // client.setCallback(callback); Ethernet.begin(mac, ip); delay(200); //wdt_enable(WDTO_8S); Serial.println("WDTO_8S"); if (client.connect("elcounter")) { digitalWrite(LED, LOW); Public(); } } ! void serialEvent() { while (Serial.available() > 0) { char inChar = (char)Serial.read(); cmd += inChar; if (inChar == '\n') { strComplete = true; } } } ! void callback_iobroker(String strTopic, String strPayload) { if (strTopic == topic_correction) { cnt = atol((strPayload).c_str()); Serial.print("SC"); Serial.println(cnt); client.publish(topic_correction, "0"); } else if (strTopic == topic_save) { if (strPayload == "true") { Serial.println("SS"); save(); client.publish(topic_save, "false"); } } else if (strTopic == topic_polling) { poll = strPayload.toInt(); if (poll < 1000) { poll = 1000; } else if (poll > 32767) { poll = 32767; } EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации client.publish(topic_polling, IntToChar(poll)); } else if (strTopic == topic_reset) { if (strPayload == "true") { client.publish(topic_reset, "false"); // reboot(); Serial.println("Reboot"); } } else if (strTopic == topic_bounce) { bounce = strPayload.toInt(); if (bounce < 0) { bounce = 0; } else if (bounce > 10000) { bounce = 10000; } Serial.print("SB"); Serial.println(bounce); client.publish(topic_bounce, IntToChar(bounce)); } else if (strTopic == topic_num) { num = strPayload.toInt(); if (num < 0) { num = 0; } else if (num > 32767) { num = 32767; } Serial.print("SN"); Serial.println(num); client.publish(topic_num, IntToChar(num)); } } ! void save() { chk = poll - 500; EEPROMWriteLong(CNT_ADR, cnt); //Пишем показания счетчика в eeprom из переменной EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации EEPROMWriteInt(CHK_ADR, chk); //чек } ! void reboot() { save(); delay(500); // wdt_enable(WDTO_1S); Serial.println("void reboot"); for (;;) {} } ! char* StrToChar (String str) { int length = str.length(); str.toCharArray(buf, length + 1); return buf; } ! void EEPROMWriteLong(int p_address, unsigned long p_value) { byte four = (p_value & 0xFF); byte three = ((p_value >> 8) & 0xFF); byte two = ((p_value >> 16) & 0xFF); byte one = ((p_value >> 24) & 0xFF); EEPROM.write(p_address, four); EEPROM.write(p_address + 1, three); EEPROM.write(p_address + 2, two); EEPROM.write(p_address + 3, one); } ! unsigned long EEPROMReadLong(int p_address) { long four = EEPROM.read(p_address); long three = EEPROM.read(p_address + 1); long two = EEPROM.read(p_address + 2); long one = EEPROM.read(p_address + 3); return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF); } ! void EEPROMWriteInt(int p_address, int p_value) { byte lowByte = ((p_value >> 0) & 0xFF); byte highByte = ((p_value >> 8) & 0xFF); EEPROM.write(p_address, lowByte); EEPROM.write(p_address + 1, highByte); } unsigned int EEPROMReadInt(int p_address) { byte lowByte = EEPROM.read(p_address); byte highByte = EEPROM.read(p_address + 1); return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00); } ! char* IntToChar (unsigned long a) { sprintf(buf, "%lu", a); return buf; } ! void Public() { sprintf(s, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); client.publish(topic_err, " "); client.publish(topic_cnt, IntToChar(cnt)); client.publish(topic_pwr, IntToChar(pwr)); client.publish(topic_amp, IntToChar(amp)); client.publish(topic_save, "false"); client.publish(topic_correction, "0"); client.publish(topic_connection, "true"); client.publish(topic_ip, s); client.publish(topic_polling, IntToChar(poll)); client.publish(topic_bounce, IntToChar(bounce)); client.publish(topic_num, IntToChar(num)); client.publish(topic_reset, "false"); client.subscribe(subscr); } void reconnect() { int a = 0; while (!client.connected()) { a++; digitalWrite(LED, !digitalRead(LED)); //wdt_reset(); Serial.println("WDT reset"); if (client.connect("elcounter")) { digitalWrite(LED, LOW); Public(); } else { delay(10000); } if (a >= 10) { // wdt_enable(WDTO_1S); Serial.println("WDTO_1S"); } } } ! void loop() { // wdt_reset(); Serial.println("WDT_reset"); client.loop(); if (!client.connected()) { reconnect(); } ! if (analogRead(PWR_CTRL) < 1000) { digitalWrite(LED, LOW); save(); delay(10000); } ! if (strComplete) { digitalWrite(LED, !digitalRead(LED)); cmd.toCharArray(buffer, 100); cnt = atoi(strtok(buffer, ";")); pwr = atoi(strtok(NULL, ";")); amp = atoi(strtok(NULL, ";")); bounce = atoi(strtok(NULL, ";")); num = atoi(strtok(NULL, ";")); error = atoi(strtok(NULL, ";")); client.publish(topic_raw, StrToChar(cmd)); cmd = ""; strComplete = false; } ! if (millis() - prevMillis >= poll) { // wdt_reset(); Serial.println("WDT_reset"); prevMillis = millis(); if (cnt != prev_cnt || pwr != prev_pwr || amp != prev_amp) { prev_cnt = cnt; prev_pwr = pwr; prev_amp = amp; client.publish(topic_cnt, IntToChar(cnt)); client.publish(topic_pwr, IntToChar(pwr)); client.publish(topic_amp, IntToChar(amp)); } if (num != prev_num || bounce != prev_bounce) { prev_num = num; prev_bounce = bounce; client.publish(topic_num, IntToChar(num)); client.publish(topic_bounce, IntToChar(bounce)); } if (error > 0) { client.publish(topic_err, "err"); } else { client.publish(topic_err, " "); } } }</avr></eeprom.h></pubsubclient.h></ethernet.h></spi.h>` код с моими правками Вроде все норм по сети, в логе тишина? ! byte ip[] = { 192, 168, 0, 89}; айпи самой ардуины ! byte server[] = { 192, 168, 0, 15}; айпи mqtt сервера[/i][/i][/i][/i] `

              1 Reply Last reply Reply Quote 0
              • S
                smoker_vvo last edited by

                А не может быть связанным как то с удаленным конфигом сетевого адреса??

                const char* topic_ip = "myhome/elcounter/config/ip";

                Заливал этот код в Дуню - все работает…

                ! ```
                `#include <spi.h> // Ethernet shield
                #include <ethernet.h> // Ethernet shield
                #include <pubsubclient.h> // MQTT
                #include <servo.h>
                #include <dht.h>
                #include <onewire.h>
                #include <dallastemperature.h>
                Servo servo;
                ! byte mac[] = { 0xC1, 0x7C, 0x38, 0x41, 0x89, 0x35 };
                byte server[] = { 192, 168, 0, 11 }; //IP Брокера
                byte ip[] = { 192, 168, 0, 89 }; //IP Клиента (Arduino)
                ! ////////////////////////////////////////////////////////////////////////////
                void callback(char* topic, byte* payload, unsigned int length) {
                payload[length] = '\0';
                // Serial.print(topic);
                // Serial.print("=");
                String strTopic = String(topic);
                String strPayload = String((char*)payload);
                // Serial.println(strPayload);
                callback_iobroker(strTopic, strPayload);
                }
                ! EthernetClient ethClient;
                PubSubClient client(server, 1883, callback, ethClient);
                #define id_connect "myhome-temp"
                #define id_connect "myhome-status"
                #define Prefix_subscribe "myhome/Temp/"
                #define Prefix_subscribe "myhome/Status/"
                ! ///////////////Объявляем порты ввода-вывода
                #define ServoPin 3 //Порт к которому подключен сервопривод
                ! const int start_DI_pin []= {2, 4, 5}; // Порты Ввода
                int n_DI_pin = sizeof(start_DI_pin) / sizeof(start_DI_pin[0])-1; //Вычисляем длинну массива
                ! const int start_DO_pin []= {6, 7}; //Порты Вывода
                int n_DO_pin = sizeof(start_DO_pin) / sizeof(start_DO_pin[0])-1; //Вычисляем длинну массива
                ! int DI[] = {0, 0, 0};
                int old_DI[] = {0, 0, 0};
                ! ///////////////////////////Переменные для работы с освещением//////////////////////////////////////
                int ServoAngle = 100; //Угол сервопривода при включении
                int flag = 0;
                int flag2 = 0;
                int pause = 0;
                ! //------------------------------------------- Sensors -------------------------------------------//
                const int MQ7_Pin = A0; // Куда подключили MQ7
                //int MQ7Value = 0;
                int MQ7Value = analogRead(MQ7_Pin);

                const int foto_Pin = A1; // устанавливаем входную ногу для Фоторезистора
                //unsigned int fotoValue = 0; // цифровое значение фоторезистора
                unsigned int fotoValue = analogRead(foto_Pin);

                ! #define ONE_WIRE_BUS 8
                //#define TEMPERATURE_PRECISION 9
                OneWire oneWire(ONE_WIRE_BUS);
                DallasTemperature DS_sensors(&oneWire);
                // 28 80 E9 3A 04 00 00 10
                //T0:28 88 AD D7 02 00 00 42
                //T1:28 14 A5 D7 02 00 00 B0
                //T2:28 72 26 7B 04 00 00 2E
                //T3:28 CA 1A 3B 04 00 00 CD
                //T4:28 E6 D5 D7 02 00 00 C1
                //T5:28 16 B4 7A 04 00 00 8A
                //T6:28 2B 86 D7 02 00 00 CF
                //T7:28 AB 9D D7 02 00 00 29
                DeviceAddress addr_T1 = { 0x28, 0x80, 0xE9, 0x3A, 0x4, 0x0, 0x0, 0x10 };//кладовка
                DeviceAddress addr_T2 = { 0x28, 0x88, 0xAD, 0xD7, 0x2, 0x0, 0x0, 0x42 };//кухня
                DeviceAddress addr_T3 = { 0x28, 0x14, 0xA5, 0xD7, 0x2, 0x0, 0x0, 0xB0 };//детская
                DeviceAddress addr_T4 = { 0x28, 0x72, 0x26, 0x7B, 0x4, 0x0, 0x0, 0x2E };//гараж
                DeviceAddress addr_T5 = { 0x28, 0xCA, 0x1A, 0x3B, 0x4, 0x0, 0x0, 0xCD };//ванная
                DeviceAddress addr_T6 = { 0x28, 0xE6, 0xD5, 0xD7, 0x2, 0x0, 0x0, 0xC1 };//улица
                DeviceAddress addr_T7 = { 0x28, 0x16, 0xB4, 0x7A, 0x4, 0x0, 0x0, 0x8A };//спальня2
                DeviceAddress addr_T8 = { 0x28, 0x2B, 0x86, 0xD7, 0x2, 0x0, 0x0, 0xCF };//зал
                DeviceAddress addr_T9 = { 0x28, 0xAB, 0x9D, 0xD7, 0x2, 0x0, 0x0, 0x29 };//мансарда
                ! float T1=0;
                float T2=0;
                float T3=0;
                float T4=0;
                float T5=0;
                float T6=0;
                float T7=0;
                float T8=0;
                float T9=0;
                ! //dht DHT;
                //#define DHT22_PIN 9
                //float Hout = 0;
                //float Tout = 0;
                ! ////////////////////////////////////////////////////////////////////////////
                //void callback(char* topic, byte* payload, unsigned int length) {
                // payload[length] = '\0';
                // Serial.print(topic);
                // Serial.print("=");
                // String strTopic = String(topic);
                // String strPayload = String((char*)payload);
                // Serial.println(strPayload);
                // callback_iobroker(strTopic, strPayload);
                //}
                ////////////////////////////////////////////////////////////////////////////
                void setup() {
                Serial.begin(57600);
                Serial.println("start");

                Serial.print("Locating devices...");
                DS_sensors.begin();
                Serial.print("Found ");
                Serial.print(DS_sensors.getDeviceCount(), DEC);
                Serial.println(" devices.");

                ! // report parasite power requirements
                Serial.print("Parasite power is: ");
                if (DS_sensors.isParasitePowerMode()) Serial.println("ON");
                else Serial.println("OFF");

                //Объявляем порты Digital inputs/outputs
                

                for(int i=0 ;i<=n_DI_pin; i++) { pinMode (start_DI_pin [i], INPUT); }
                digitalWrite(5, HIGH); //Насос скважины
                digitalWrite(4, HIGH); //Электрика
                for(int i=0 ;i<=n_DO_pin; i++) { pinMode (start_DO_pin [i], OUTPUT); }

                ! Ethernet.begin(mac, ip);
                if (client.connect(id_connect)) {
                getSensors();
                control();
                //client.publish("myhome/Kitchen/Change_Counter", "0");
                //client.publish("myhome/Kitchen/Temp_room", "0");
                //client.publish("myhome/Kitchen/Humidity_room", "0");
                client.publish("myhome/Temp/Kladovka", "0");
                client.publish("myhome/Temp/Kitchen", "0");
                client.publish("myhome/Temp/Detskaya", "0");
                client.publish("myhome/Temp/Garage", "0");
                client.publish("myhome/Temp/Street", "0");
                client.publish("myhome/Temp/Spalnya2", "0");
                client.publish("myhome/Temp/Zal", "0");
                client.publish("myhome/Temp/Mansarda", "0");
                client.publish("myhome/Temp/Vannaya", "0");

                //client.publish("myhome/Kitchen/Lux", "0");
                //client.publish("myhome/Kitchen/Servo", "0");
                client.publish("myhome/Temp/MQ7", "0");
                
                client.publish("myhome/Status/Power", "0");
                client.publish("myhome/Status/Pompe", "0");
                
                client.subscribe("myhome/Temp/#");
                client.subscribe("myhome/Status/#");
                

                }
                }
                /////////////////////////////////////////////////////////////////////////
                void loop() {
                client.loop();
                control();
                getSensors();
                if (!client.connected()) {
                if (client.connect(id_connect)) {
                control();
                getSensors();
                client.subscribe("myhome/Temp/#");
                }
                }
                }</dallastemperature.h></onewire.h></dht.h></servo.h></pubsubclient.h></ethernet.h></spi.h>`

                ! и все пингуется, а вот заливаю счетчик - и фиг-вам.... пинг не проходит....[/i][/i]

                1 Reply Last reply Reply Quote 0
                • S
                  smoker_vvo last edited by

                  В свое время натыкался на проблемы с СД картами и W5100

                  1 Reply Last reply Reply Quote 0
                  • I
                    instalator last edited by

                    @smoker_vvo:

                    А не может быть связанным как то с удаленным конфигом сетевого адреса??

                    const char* topic_ip = "myhome/elcounter/config/ip";

                    Заливал этот код в Дуню - все работает…

                    ! ```
                    `#include <spi.h> // Ethernet shield
                    #include <ethernet.h> // Ethernet shield
                    #include <pubsubclient.h> // MQTT
                    #include <servo.h>
                    #include <dht.h>
                    #include <onewire.h>
                    #include <dallastemperature.h>
                    Servo servo;
                    ! byte mac[] = { 0xC1, 0x7C, 0x38, 0x41, 0x89, 0x35 };
                    byte server[] = { 192, 168, 0, 11 }; //IP Брокера
                    byte ip[] = { 192, 168, 0, 89 }; //IP Клиента (Arduino)
                    ! ////////////////////////////////////////////////////////////////////////////
                    void callback(char* topic, byte* payload, unsigned int length) {
                    payload[length] = '\0';
                    // Serial.print(topic);
                    // Serial.print("=");
                    String strTopic = String(topic);
                    String strPayload = String((char*)payload);
                    // Serial.println(strPayload);
                    callback_iobroker(strTopic, strPayload);
                    }
                    ! EthernetClient ethClient;
                    PubSubClient client(server, 1883, callback, ethClient);
                    #define id_connect "myhome-temp"
                    #define id_connect "myhome-status"
                    #define Prefix_subscribe "myhome/Temp/"
                    #define Prefix_subscribe "myhome/Status/"
                    ! ///////////////Объявляем порты ввода-вывода
                    #define ServoPin 3 //Порт к которому подключен сервопривод
                    ! const int start_DI_pin []= {2, 4, 5}; // Порты Ввода
                    int n_DI_pin = sizeof(start_DI_pin) / sizeof(start_DI_pin[0])-1; //Вычисляем длинну массива
                    ! const int start_DO_pin []= {6, 7}; //Порты Вывода
                    int n_DO_pin = sizeof(start_DO_pin) / sizeof(start_DO_pin[0])-1; //Вычисляем длинну массива
                    ! int DI[] = {0, 0, 0};
                    int old_DI[] = {0, 0, 0};
                    ! ///////////////////////////Переменные для работы с освещением//////////////////////////////////////
                    int ServoAngle = 100; //Угол сервопривода при включении
                    int flag = 0;
                    int flag2 = 0;
                    int pause = 0;
                    ! //------------------------------------------- Sensors -------------------------------------------//
                    const int MQ7_Pin = A0; // Куда подключили MQ7
                    //int MQ7Value = 0;
                    int MQ7Value = analogRead(MQ7_Pin);

                    const int foto_Pin = A1; // устанавливаем входную ногу для Фоторезистора
                    //unsigned int fotoValue = 0; // цифровое значение фоторезистора
                    unsigned int fotoValue = analogRead(foto_Pin);

                    ! #define ONE_WIRE_BUS 8
                    //#define TEMPERATURE_PRECISION 9
                    OneWire oneWire(ONE_WIRE_BUS);
                    DallasTemperature DS_sensors(&oneWire);
                    // 28 80 E9 3A 04 00 00 10
                    //T0:28 88 AD D7 02 00 00 42
                    //T1:28 14 A5 D7 02 00 00 B0
                    //T2:28 72 26 7B 04 00 00 2E
                    //T3:28 CA 1A 3B 04 00 00 CD
                    //T4:28 E6 D5 D7 02 00 00 C1
                    //T5:28 16 B4 7A 04 00 00 8A
                    //T6:28 2B 86 D7 02 00 00 CF
                    //T7:28 AB 9D D7 02 00 00 29
                    DeviceAddress addr_T1 = { 0x28, 0x80, 0xE9, 0x3A, 0x4, 0x0, 0x0, 0x10 };//кладовка
                    DeviceAddress addr_T2 = { 0x28, 0x88, 0xAD, 0xD7, 0x2, 0x0, 0x0, 0x42 };//кухня
                    DeviceAddress addr_T3 = { 0x28, 0x14, 0xA5, 0xD7, 0x2, 0x0, 0x0, 0xB0 };//детская
                    DeviceAddress addr_T4 = { 0x28, 0x72, 0x26, 0x7B, 0x4, 0x0, 0x0, 0x2E };//гараж
                    DeviceAddress addr_T5 = { 0x28, 0xCA, 0x1A, 0x3B, 0x4, 0x0, 0x0, 0xCD };//ванная
                    DeviceAddress addr_T6 = { 0x28, 0xE6, 0xD5, 0xD7, 0x2, 0x0, 0x0, 0xC1 };//улица
                    DeviceAddress addr_T7 = { 0x28, 0x16, 0xB4, 0x7A, 0x4, 0x0, 0x0, 0x8A };//спальня2
                    DeviceAddress addr_T8 = { 0x28, 0x2B, 0x86, 0xD7, 0x2, 0x0, 0x0, 0xCF };//зал
                    DeviceAddress addr_T9 = { 0x28, 0xAB, 0x9D, 0xD7, 0x2, 0x0, 0x0, 0x29 };//мансарда
                    ! float T1=0;
                    float T2=0;
                    float T3=0;
                    float T4=0;
                    float T5=0;
                    float T6=0;
                    float T7=0;
                    float T8=0;
                    float T9=0;
                    ! //dht DHT;
                    //#define DHT22_PIN 9
                    //float Hout = 0;
                    //float Tout = 0;
                    ! ////////////////////////////////////////////////////////////////////////////
                    //void callback(char* topic, byte* payload, unsigned int length) {
                    // payload[length] = '\0';
                    // Serial.print(topic);
                    // Serial.print("=");
                    // String strTopic = String(topic);
                    // String strPayload = String((char*)payload);
                    // Serial.println(strPayload);
                    // callback_iobroker(strTopic, strPayload);
                    //}
                    ////////////////////////////////////////////////////////////////////////////
                    void setup() {
                    Serial.begin(57600);
                    Serial.println("start");

                    Serial.print("Locating devices...");
                    DS_sensors.begin();
                    Serial.print("Found ");
                    Serial.print(DS_sensors.getDeviceCount(), DEC);
                    Serial.println(" devices.");

                    ! // report parasite power requirements
                    Serial.print("Parasite power is: ");
                    if (DS_sensors.isParasitePowerMode()) Serial.println("ON");
                    else Serial.println("OFF");

                    //Объявляем порты Digital inputs/outputs
                    

                    for(int i=0 ;i<=n_DI_pin; i++) { pinMode (start_DI_pin [i], INPUT); }
                    digitalWrite(5, HIGH); //Насос скважины
                    digitalWrite(4, HIGH); //Электрика
                    for(int i=0 ;i<=n_DO_pin; i++) { pinMode (start_DO_pin [i], OUTPUT); }

                    ! Ethernet.begin(mac, ip);
                    if (client.connect(id_connect)) {
                    getSensors();
                    control();
                    //client.publish("myhome/Kitchen/Change_Counter", "0");
                    //client.publish("myhome/Kitchen/Temp_room", "0");
                    //client.publish("myhome/Kitchen/Humidity_room", "0");
                    client.publish("myhome/Temp/Kladovka", "0");
                    client.publish("myhome/Temp/Kitchen", "0");
                    client.publish("myhome/Temp/Detskaya", "0");
                    client.publish("myhome/Temp/Garage", "0");
                    client.publish("myhome/Temp/Street", "0");
                    client.publish("myhome/Temp/Spalnya2", "0");
                    client.publish("myhome/Temp/Zal", "0");
                    client.publish("myhome/Temp/Mansarda", "0");
                    client.publish("myhome/Temp/Vannaya", "0");

                    //client.publish("myhome/Kitchen/Lux", "0");
                    //client.publish("myhome/Kitchen/Servo", "0");
                    client.publish("myhome/Temp/MQ7", "0");
                    
                    client.publish("myhome/Status/Power", "0");
                    client.publish("myhome/Status/Pompe", "0");
                    
                    client.subscribe("myhome/Temp/#");
                    client.subscribe("myhome/Status/#");
                    

                    }
                    }
                    /////////////////////////////////////////////////////////////////////////
                    void loop() {
                    client.loop();
                    control();
                    getSensors();
                    if (!client.connected()) {
                    if (client.connect(id_connect)) {
                    control();
                    getSensors();
                    client.subscribe("myhome/Temp/#");
                    }
                    }
                    }</dallastemperature.h></onewire.h></dht.h></servo.h></pubsubclient.h></ethernet.h></spi.h>`

                    ! и все пингуется, а вот заливаю счетчик - и фиг-вам.... пинг не проходит....нет, вечером будет время проверю твой код[/i][/i]
                    ``` `

                    1 Reply Last reply Reply Quote 0
                    • S
                      smoker_vvo last edited by

                      ок.

                      а я еще с твоим по колдую…..

                      1 Reply Last reply Reply Quote 0
                      • I
                        instalator last edited by

                        @smoker_vvo:

                        ок.

                        а я еще с твоим по колдую….. `

                        ! ```
                        `#include <spi.h>
                        #include <ethernet.h>
                        #include <pubsubclient.h>
                        #include <eeprom.h>
                        //#include <avr wdt.h="">
                        ! #define PWR_CTRL A2 //Контроль напряжения
                        #define LED 9 //Светодиод
                        #define CHK_ADR 100
                        #define CNT_ADR 10
                        #define PWR_ADR 20
                        #define POLL_ADR 30
                        #define RATIO_ADR 40
                        ! const char* topic_err = "myhome/test/error";
                        const char* topic_cnt = "myhome/test/count";
                        const char* topic_pwr = "myhome/test/power";
                        const char* topic_amp = "myhome/test/amp";
                        const char* topic_save = "myhome/test/save";
                        const char* topic_correction = "myhome/test/correction";
                        const char* topic_connection = "myhome/test/connection";
                        const char* topic_ip = "myhome/test/config/ip";
                        const char* topic_polling = "myhome/test/config/polling";
                        const char* topic_bounce = "myhome/test/config/bounce";
                        const char* topic_num = "myhome/test/config/num";
                        const char* topic_reset = "myhome/test/config/reset";
                        const char* topic_raw = "myhome/test/RAW";
                        const char* subscr = "myhome/test/#";
                        ! byte mac[] = { 0xDE, 0xA3, 0xBE, 0xE4, 0xDE, 0x35 };
                        byte ip[] = { 192, 168, 1, 59};
                        byte server[] = { 192, 168, 1, 190};
                        ! unsigned long cnt = 0;
                        unsigned long prev_cnt = 2;
                        unsigned long pwr = 0;
                        unsigned long prev_pwr = 2;
                        int amp = 0;
                        int prev_amp = 2;
                        int num = 0;
                        int prev_num;
                        int bounce = 10;
                        int prev_bounce;
                        int chk = 0;
                        int chk_S = 0;
                        unsigned long prevMillis = 0;
                        unsigned long prevMillis_cnt = 0;
                        int poll = 5000;
                        bool error = 0;
                        String cmd = "";
                        bool strComplete = false;
                        char buf [50];
                        char buffer[100];
                        char s[16];
                        ! ////////////////////////////////////////////////////////////////////////////
                        void callback(char* topic, byte* payload, unsigned int length) {
                        payload[length] = '\0';
                        String strTopic = String(topic);
                        String strPayload = String((char*)payload);
                        callback_iobroker(strTopic, strPayload);
                        }
                        ! EthernetClient ethClient;
                        PubSubClient client(ethClient);
                        ! void setup() {
                        Serial.begin(57600);
                        //MCUSR = 0;
                        // wdt_disable();
                        Serial.println("WDT_disable");
                        cmd.reserve(100);
                        delay(10000);

                        Serial.println("Starting......");

                        ! if (EEPROM.read(1) != 99) { //Если первый запуск
                        EEPROM.write(1, 99);
                        for (int i = 0 ; i < 4; i++) {
                        EEPROM.write(110 + i, ip[i]);
                        }
                        for (int i = 0 ; i < 4; i++) {
                        EEPROM.write(120 + i, server[i]);
                        }
                        } else {
                        chk = EEPROMReadInt(CHK_ADR);
                        cnt = EEPROMReadLong(CNT_ADR);
                        poll = EEPROMReadInt(POLL_ADR);
                        chk_S = poll - 500;
                        if (chk != chk_S) {
                        error = 2;
                        }
                        for (int i = 0; i < 4; i++) {
                        ip[i] = EEPROM.read(110 + i);
                        }
                        for (int i = 0; i < 4; i++) {
                        server[i] = EEPROM.read(120 + i);
                        }
                        }
                        ! pinMode(LED, OUTPUT);
                        ! client.setServer(server, 1883);
                        client.setCallback(callback);
                        Ethernet.begin(mac, ip);

                        delay(200);
                        //wdt_enable(WDTO_8S);
                        Serial.println("WDTO_8S");
                        if (client.connect("test")){
                        digitalWrite(LED, LOW);
                        Public();
                        }
                        }

                        ! void serialEvent() {
                        while (Serial.available() > 0) {
                        char inChar = (char)Serial.read();
                        cmd += inChar;
                        if (inChar == '\n') {
                        strComplete = true;
                        }
                        }
                        }
                        ! void loop() {
                        // wdt_reset();
                        Serial.println("WDT_reset");
                        client.loop();
                        if (!client.connected()) {
                        reconnect();
                        }
                        ! /if (analogRead(PWR_CTRL) < 1000) {
                        digitalWrite(LED, LOW);
                        save();
                        delay(10000);
                        }
                        /
                        ! if (strComplete) {
                        digitalWrite(LED, !digitalRead(LED));
                        cmd.toCharArray(buffer, 100);
                        cnt = atoi(strtok(buffer, ";"));
                        pwr = atoi(strtok(NULL, ";"));
                        amp = atoi(strtok(NULL, ";"));
                        bounce = atoi(strtok(NULL, ";"));
                        num = atoi(strtok(NULL, ";"));
                        error = atoi(strtok(NULL, ";"));
                        client.publish(topic_raw, StrToChar(cmd));
                        cmd = "";
                        strComplete = false;
                        }
                        ! if (millis() - prevMillis >= poll) {
                        // wdt_reset();
                        Serial.println("WDT_reset-");
                        prevMillis = millis();
                        if (cnt != prev_cnt || pwr != prev_pwr || amp != prev_amp) {
                        prev_cnt = cnt;
                        prev_pwr = pwr;
                        prev_amp = amp;
                        client.publish(topic_cnt, IntToChar(cnt));
                        client.publish(topic_pwr, IntToChar(pwr));
                        client.publish(topic_amp, IntToChar(amp));
                        }
                        if (num != prev_num || bounce != prev_bounce) {
                        prev_num = num;
                        prev_bounce = bounce;
                        client.publish(topic_num, IntToChar(num));
                        client.publish(topic_bounce, IntToChar(bounce));
                        }
                        if (error > 0) {
                        client.publish(topic_err, "err");
                        } else {
                        client.publish(topic_err, " ");
                        }
                        }
                        }
                        ! void callback_iobroker(String strTopic, String strPayload) {
                        if (strTopic == topic_correction) {
                        cnt = atol((strPayload).c_str());
                        Serial.print("SC");
                        Serial.println(cnt);
                        client.publish(topic_correction, "0");
                        }
                        else if (strTopic == topic_save) {
                        if (strPayload == "true") {
                        Serial.println("SS");
                        save();
                        client.publish(topic_save, "false");
                        }
                        }
                        else if (strTopic == topic_polling) {
                        poll = strPayload.toInt();
                        if (poll < 1000) {
                        poll = 1000;
                        } else if (poll > 32767) {
                        poll = 32767;
                        }
                        EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации
                        client.publish(topic_polling, IntToChar(poll));
                        }
                        else if (strTopic == topic_reset) {
                        if (strPayload == "true") {
                        client.publish(topic_reset, "false");
                        // reboot();
                        Serial.println("Reboot");
                        }
                        }
                        else if (strTopic == topic_bounce) {
                        bounce = strPayload.toInt();
                        if (bounce < 0) {
                        bounce = 0;
                        } else if (bounce > 10000) {
                        bounce = 10000;
                        }
                        Serial.print("SB");
                        Serial.println(bounce);
                        client.publish(topic_bounce, IntToChar(bounce));
                        }
                        else if (strTopic == topic_num) {
                        num = strPayload.toInt();
                        if (num < 0) {
                        num = 0;
                        } else if (num > 32767) {
                        num = 32767;
                        }
                        Serial.print("SN");
                        Serial.println(num);
                        client.publish(topic_num, IntToChar(num));
                        }
                        }
                        ! void save() {
                        chk = poll - 500;
                        EEPROMWriteLong(CNT_ADR, cnt); //Пишем показания счетчика в eeprom из переменной
                        EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации
                        EEPROMWriteInt(CHK_ADR, chk); //чек
                        }
                        ! void reboot() {
                        //save();
                        //delay(500);
                        // wdt_enable(WDTO_1S);
                        Serial.println("void reboot");
                        //for (;;) {}
                        }
                        ! char* StrToChar (String str) {
                        int length = str.length();
                        str.toCharArray(buf, length + 1);
                        return buf;
                        }
                        ! void EEPROMWriteLong(int p_address, unsigned long p_value) {
                        byte four = (p_value & 0xFF);
                        byte three = ((p_value >> 😎 & 0xFF);
                        byte two = ((p_value >> 16) & 0xFF);
                        byte one = ((p_value >> 24) & 0xFF);
                        EEPROM.write(p_address, four);
                        EEPROM.write(p_address + 1, three);
                        EEPROM.write(p_address + 2, two);
                        EEPROM.write(p_address + 3, one);
                        }
                        ! unsigned long EEPROMReadLong(int p_address) {
                        long four = EEPROM.read(p_address);
                        long three = EEPROM.read(p_address + 1);
                        long two = EEPROM.read(p_address + 2);
                        long one = EEPROM.read(p_address + 3);
                        return ((four << 0) & 0xFF) + ((three << 😎 & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
                        }
                        ! void EEPROMWriteInt(int p_address, int p_value) {
                        byte lowByte = ((p_value >> 0) & 0xFF);
                        byte highByte = ((p_value >> 😎 & 0xFF);
                        EEPROM.write(p_address, lowByte);
                        EEPROM.write(p_address + 1, highByte);
                        }
                        unsigned int EEPROMReadInt(int p_address) {
                        byte lowByte = EEPROM.read(p_address);
                        byte highByte = EEPROM.read(p_address + 1);
                        return ((lowByte << 0) & 0xFF) + ((highByte << 😎 & 0xFF00);
                        }
                        ! char* IntToChar (unsigned long a) {
                        sprintf(buf, "%lu", a);
                        return buf;
                        }
                        ! void Public() {
                        sprintf(s, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
                        client.publish(topic_err, " ");
                        client.publish(topic_cnt, IntToChar(cnt));
                        client.publish(topic_pwr, IntToChar(pwr));
                        client.publish(topic_amp, IntToChar(amp));
                        client.publish(topic_save, "false");
                        client.publish(topic_correction, "0");
                        client.publish(topic_connection, "true");
                        client.publish(topic_ip, s);
                        client.publish(topic_polling, IntToChar(poll));
                        client.publish(topic_bounce, IntToChar(bounce));
                        client.publish(topic_num, IntToChar(num));
                        client.publish(topic_reset, "false");
                        client.subscribe(subscr);
                        }
                        void reconnect() {
                        int a = 0;
                        while (!client.connected()) {
                        a++;
                        digitalWrite(LED, !digitalRead(LED));
                        //wdt_reset();
                        Serial.println("WDT reset");
                        if (client.connect("test")) {
                        digitalWrite(LED, LOW);
                        Public();
                        } else {
                        delay(10000);
                        }
                        if (a >= 10) {
                        // wdt_enable(WDTO_1S);
                        Serial.println("WDTO_1S");
                        }
                        }
                        }</avr></eeprom.h></pubsubclient.h></ethernet.h></spi.h>`
                        Работает[/i][/i][/i][/i]

                        1 Reply Last reply Reply Quote 0
                        • S
                          smoker_vvo last edited by

                          Убейте меня!!! ОН НЕ РАБОТАЕТ….. Ну не пингуется этот ip, я поменял на свои......

                          1 Reply Last reply Reply Quote 0
                          • I
                            instalator last edited by

                            @smoker_vvo:

                            Убейте меня!!! ОН НЕ РАБОТАЕТ….. Ну не пингуется этот ip, я поменял на свои...... `
                            библиотеки последних версии?

                            1 Reply Last reply Reply Quote 0
                            • S
                              smoker_vvo last edited by

                              Начнем с простого…. Какая IDE

                              1 Reply Last reply Reply Quote 0
                              • S
                                smoker_vvo last edited by

                                в IDE 1.5.2 гружу вот этот скетч:

                                ! ````
                                /*
                                Web Server

                                A simple web server that shows the value of the analog input pins.
                                using an Arduino Wiznet Ethernet shield.

                                Circuit:

                                • Ethernet shield attached to pins 10, 11, 12, 13
                                • Analog inputs attached to pins A0 through A5 (optional)

                                created 18 Dec 2009
                                by David A. Mellis
                                modified 9 Apr 2012
                                by Tom Igoe

                                */

                                ! #include <spi.h>#include <ethernet.h>// Enter a MAC address and IP address for your controller below.
                                // The IP address will be dependent on your local network:
                                byte mac[] = {
                                0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
                                IPAddress ip(192,168,0, 89);
                                ! // Initialize the Ethernet server library
                                // with the IP address and port you want to use
                                // (port 80 is default for HTTP):
                                EthernetServer server(80);
                                ! void setup() {
                                // Open serial communications and wait for port to open:
                                Serial.begin(9600);
                                while (!Serial) {
                                ; // wait for serial port to connect. Needed for Leonardo only
                                }
                                ! // start the Ethernet connection and the server:
                                Ethernet.begin(mac, ip);
                                server.begin();
                                Serial.print("server is at ");
                                Serial.println(Ethernet.localIP());
                                }
                                ! void loop() {
                                // listen for incoming clients
                                EthernetClient client = server.available();
                                if (client) {
                                Serial.println("new client");
                                // an http request ends with a blank line
                                boolean currentLineIsBlank = true;
                                while (client.connected()) {
                                if (client.available()) {
                                char c = client.read();
                                Serial.write(c);
                                // if you've gotten to the end of the line (received a newline
                                // character) and the line is blank, the http request has ended,
                                // so you can send a reply
                                if (c == '\n' && currentLineIsBlank) {
                                // send a standard http response header
                                client.println("HTTP/1.1 200 OK");
                                client.println("Content-Type: text/html");
                                client.println("Connection: close");
                                client.println();
                                client.println("");
                                client.println("");
                                // add a meta refresh tag, so the browser pulls again every 5 seconds:
                                client.println("");
                                // output the value of each analog input pin
                                for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
                                int sensorReading = analogRead(analogChannel);
                                client.print("analog input ");
                                client.print(analogChannel);
                                client.print(" is ");
                                client.print(sensorReading);
                                client.println("
                                ");
                                }
                                client.println("");
                                break;
                                }
                                if (c == '\n') {
                                // you're starting a new line
                                currentLineIsBlank = true;
                                }
                                else if (c != '\r') {
                                // you've gotten a character on the current line
                                currentLineIsBlank = false;
                                }
                                }
                                }
                                // give the web browser time to receive the data
                                delay(1);
                                // close the connection:
                                client.stop();
                                Serial.println("client disonnected");
                                }
                                }</ethernet.h></spi.h>

                                
                                Пинг - отличный, и веб пускает,
                                1 Reply Last reply Reply Quote 0
                                • S
                                  smoker_vvo last edited by

                                  в 1ю8ю2 - тоже проблем нет…...

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    smoker_vvo last edited by

                                    1ю6ю13 - полет нормальный

                                    и 1.0.6 - работает…...

                                    1 Reply Last reply Reply Quote 0
                                    • S
                                      smoker_vvo last edited by

                                      IDE 1.6.13 этот скетч - работает, все пингуется и данные идут

                                      ! ```
                                      `#include <spi.h> // Ethernet shield
                                      #include <ethernet.h> // Ethernet shield
                                      #include <pubsubclient.h> // MQTT
                                      #include <servo.h>
                                      #include <dht.h>
                                      #include <onewire.h>
                                      #include <dallastemperature.h>
                                      Servo servo;
                                      ! byte mac[] = { 0xC1, 0x7C, 0x38, 0x41, 0x89, 0x35 };
                                      byte server[] = { 192, 168, 0, 11 }; //IP Брокера
                                      byte ip[] = { 192, 168, 0, 89 }; //IP Клиента (Arduino)
                                      ! ////////////////////////////////////////////////////////////////////////////
                                      void callback(char* topic, byte* payload, unsigned int length) {
                                      payload[length] = '\0';
                                      // Serial.print(topic);
                                      // Serial.print("=");
                                      String strTopic = String(topic);
                                      String strPayload = String((char*)payload);
                                      // Serial.println(strPayload);
                                      callback_iobroker(strTopic, strPayload);
                                      }
                                      ! EthernetClient ethClient;
                                      PubSubClient client(server, 1883, callback, ethClient);
                                      #define id_connect "myhome-temp"
                                      #define id_connect "myhome-status"
                                      #define Prefix_subscribe "myhome/Temp/"
                                      #define Prefix_subscribe "myhome/Status/"
                                      ! ///////////////Объявляем порты ввода-вывода
                                      #define ServoPin 3 //Порт к которому подключен сервопривод
                                      ! const int start_DI_pin []= {2, 4, 5}; // Порты Ввода
                                      int n_DI_pin = sizeof(start_DI_pin) / sizeof(start_DI_pin[0])-1; //Вычисляем длинну массива
                                      ! const int start_DO_pin []= {6, 7}; //Порты Вывода
                                      int n_DO_pin = sizeof(start_DO_pin) / sizeof(start_DO_pin[0])-1; //Вычисляем длинну массива
                                      ! int DI[] = {0, 0, 0};
                                      int old_DI[] = {0, 0, 0};
                                      ! ///////////////////////////Переменные для работы с освещением//////////////////////////////////////
                                      int ServoAngle = 100; //Угол сервопривода при включении
                                      int flag = 0;
                                      int flag2 = 0;
                                      int pause = 0;
                                      ! //------------------------------------------- Sensors -------------------------------------------//
                                      const int MQ7_Pin = A0; // Куда подключили MQ7
                                      //int MQ7Value = 0;
                                      int MQ7Value = analogRead(MQ7_Pin);

                                      const int foto_Pin = A1; // устанавливаем входную ногу для Фоторезистора
                                      //unsigned int fotoValue = 0; // цифровое значение фоторезистора
                                      unsigned int fotoValue = analogRead(foto_Pin);

                                      ! #define ONE_WIRE_BUS 8
                                      //#define TEMPERATURE_PRECISION 9
                                      OneWire oneWire(ONE_WIRE_BUS);
                                      DallasTemperature DS_sensors(&oneWire);
                                      // 28 80 E9 3A 04 00 00 10
                                      //T0:28 88 AD D7 02 00 00 42
                                      //T1:28 14 A5 D7 02 00 00 B0
                                      //T2:28 72 26 7B 04 00 00 2E
                                      //T3:28 CA 1A 3B 04 00 00 CD
                                      //T4:28 E6 D5 D7 02 00 00 C1
                                      //T5:28 16 B4 7A 04 00 00 8A
                                      //T6:28 2B 86 D7 02 00 00 CF
                                      //T7:28 AB 9D D7 02 00 00 29
                                      DeviceAddress addr_T1 = { 0x28, 0x80, 0xE9, 0x3A, 0x4, 0x0, 0x0, 0x10 };//кладовка
                                      DeviceAddress addr_T2 = { 0x28, 0x88, 0xAD, 0xD7, 0x2, 0x0, 0x0, 0x42 };//кухня
                                      DeviceAddress addr_T3 = { 0x28, 0x14, 0xA5, 0xD7, 0x2, 0x0, 0x0, 0xB0 };//детская
                                      DeviceAddress addr_T4 = { 0x28, 0x72, 0x26, 0x7B, 0x4, 0x0, 0x0, 0x2E };//гараж
                                      DeviceAddress addr_T5 = { 0x28, 0xCA, 0x1A, 0x3B, 0x4, 0x0, 0x0, 0xCD };//ванная
                                      DeviceAddress addr_T6 = { 0x28, 0xE6, 0xD5, 0xD7, 0x2, 0x0, 0x0, 0xC1 };//улица
                                      DeviceAddress addr_T7 = { 0x28, 0x16, 0xB4, 0x7A, 0x4, 0x0, 0x0, 0x8A };//спальня2
                                      DeviceAddress addr_T8 = { 0x28, 0x2B, 0x86, 0xD7, 0x2, 0x0, 0x0, 0xCF };//зал
                                      DeviceAddress addr_T9 = { 0x28, 0xAB, 0x9D, 0xD7, 0x2, 0x0, 0x0, 0x29 };//мансарда
                                      ! float T1=0;
                                      float T2=0;
                                      float T3=0;
                                      float T4=0;
                                      float T5=0;
                                      float T6=0;
                                      float T7=0;
                                      float T8=0;
                                      float T9=0;
                                      ! //dht DHT;
                                      //#define DHT22_PIN 9
                                      //float Hout = 0;
                                      //float Tout = 0;
                                      ! ////////////////////////////////////////////////////////////////////////////
                                      //void callback(char* topic, byte* payload, unsigned int length) {
                                      // payload[length] = '\0';
                                      // Serial.print(topic);
                                      // Serial.print("=");
                                      // String strTopic = String(topic);
                                      // String strPayload = String((char*)payload);
                                      // Serial.println(strPayload);
                                      // callback_iobroker(strTopic, strPayload);
                                      //}
                                      ////////////////////////////////////////////////////////////////////////////
                                      void setup() {
                                      Serial.begin(57600);
                                      Serial.println("start");

                                      Serial.print("Locating devices...");
                                      DS_sensors.begin();
                                      Serial.print("Found ");
                                      Serial.print(DS_sensors.getDeviceCount(), DEC);
                                      Serial.println(" devices.");

                                      ! // report parasite power requirements
                                      Serial.print("Parasite power is: ");
                                      if (DS_sensors.isParasitePowerMode()) Serial.println("ON");
                                      else Serial.println("OFF");

                                      //Объявляем порты Digital inputs/outputs
                                      

                                      for(int i=0 ;i<=n_DI_pin; i++) { pinMode (start_DI_pin [i], INPUT); }
                                      digitalWrite(5, HIGH); //Насос скважины
                                      digitalWrite(4, HIGH); //Электрика
                                      for(int i=0 ;i<=n_DO_pin; i++) { pinMode (start_DO_pin [i], OUTPUT); }

                                      ! Ethernet.begin(mac, ip);
                                      if (client.connect(id_connect)) {
                                      getSensors();
                                      control();
                                      //client.publish("myhome/Kitchen/Change_Counter", "0");
                                      //client.publish("myhome/Kitchen/Temp_room", "0");
                                      //client.publish("myhome/Kitchen/Humidity_room", "0");
                                      client.publish("myhome/Temp/Kladovka", "0");
                                      client.publish("myhome/Temp/Kitchen", "0");
                                      client.publish("myhome/Temp/Detskaya", "0");
                                      client.publish("myhome/Temp/Garage", "0");
                                      client.publish("myhome/Temp/Street", "0");
                                      client.publish("myhome/Temp/Spalnya2", "0");
                                      client.publish("myhome/Temp/Zal", "0");
                                      client.publish("myhome/Temp/Mansarda", "0");
                                      client.publish("myhome/Temp/Vannaya", "0");

                                      //client.publish("myhome/Kitchen/Lux", "0");
                                      //client.publish("myhome/Kitchen/Servo", "0");
                                      client.publish("myhome/Temp/MQ7", "0");
                                      
                                      client.publish("myhome/Status/Power", "0");
                                      client.publish("myhome/Status/Pompe", "0");
                                      
                                      client.subscribe("myhome/Temp/#");
                                      client.subscribe("myhome/Status/#");
                                      

                                      }
                                      }
                                      /////////////////////////////////////////////////////////////////////////
                                      void loop() {
                                      client.loop();
                                      control();
                                      getSensors();
                                      if (!client.connected()) {
                                      if (client.connect(id_connect)) {
                                      control();
                                      getSensors();
                                      client.subscribe("myhome/Temp/#");
                                      }
                                      }
                                      }</dallastemperature.h></onewire.h></dht.h></servo.h></pubsubclient.h></ethernet.h></spi.h>`

                                      ! А заливаем этот - и ни чего....
                                      ! >! [spoiler]`[code]#include <spi.h>
                                      #include <ethernet.h>
                                      #include <pubsubclient.h>
                                      #include <eeprom.h>
                                      //#include <avr wdt.h="">
                                      ! #define PWR_CTRL A2 //Контроль напряжения
                                      #define LED 9 //Светодиод
                                      #define CHK_ADR 100
                                      #define CNT_ADR 10
                                      #define PWR_ADR 20
                                      #define POLL_ADR 30
                                      #define RATIO_ADR 40
                                      ! const char* topic_err = "myhome/test/error";
                                      const char* topic_cnt = "myhome/test/count";
                                      const char* topic_pwr = "myhome/test/power";
                                      const char* topic_amp = "myhome/test/amp";
                                      const char* topic_save = "myhome/test/save";
                                      const char* topic_correction = "myhome/test/correction";
                                      const char* topic_connection = "myhome/test/connection";
                                      const char* topic_ip = "myhome/test/config/ip";
                                      const char* topic_polling = "myhome/test/config/polling";
                                      const char* topic_bounce = "myhome/test/config/bounce";
                                      const char* topic_num = "myhome/test/config/num";
                                      const char* topic_reset = "myhome/test/config/reset";
                                      const char* topic_raw = "myhome/test/RAW";
                                      const char* subscr = "myhome/test/#";
                                      ! byte mac[] = { 0xDE, 0xA3, 0xBE, 0xE4, 0xDE, 0x35 };
                                      byte ip[] = { 192, 168, 0, 89};
                                      byte server[] = { 192, 168, 0, 15};
                                      ! unsigned long cnt = 0;
                                      unsigned long prev_cnt = 2;
                                      unsigned long pwr = 0;
                                      unsigned long prev_pwr = 2;
                                      int amp = 0;
                                      int prev_amp = 2;
                                      int num = 0;
                                      int prev_num;
                                      int bounce = 10;
                                      int prev_bounce;
                                      int chk = 0;
                                      int chk_S = 0;
                                      unsigned long prevMillis = 0;
                                      unsigned long prevMillis_cnt = 0;
                                      int poll = 5000;
                                      bool error = 0;
                                      String cmd = "";
                                      bool strComplete = false;
                                      char buf [50];
                                      char buffer[100];
                                      char s[16];
                                      ! ////////////////////////////////////////////////////////////////////////////
                                      void callback(char* topic, byte* payload, unsigned int length) {
                                      payload[length] = '\0';
                                      String strTopic = String(topic);
                                      String strPayload = String((char*)payload);
                                      callback_iobroker(strTopic, strPayload);
                                      }
                                      ! EthernetClient ethClient;
                                      PubSubClient client(ethClient);
                                      ! void setup() {
                                      Serial.begin(57600);
                                      //MCUSR = 0;
                                      // wdt_disable();
                                      Serial.println("WDT_disable");
                                      cmd.reserve(100);
                                      delay(10000);

                                      Serial.println("Starting......");

                                      ! if (EEPROM.read(1) != 99) { //Если первый запуск
                                      EEPROM.write(1, 99);
                                      for (int i = 0 ; i < 4; i++) {
                                      EEPROM.write(110 + i, ip[i]);
                                      }
                                      for (int i = 0 ; i < 4; i++) {
                                      EEPROM.write(120 + i, server[i]);
                                      }
                                      } else {
                                      chk = EEPROMReadInt(CHK_ADR);
                                      cnt = EEPROMReadLong(CNT_ADR);
                                      poll = EEPROMReadInt(POLL_ADR);
                                      chk_S = poll - 500;
                                      if (chk != chk_S) {
                                      error = 2;
                                      }
                                      for (int i = 0; i < 4; i++) {
                                      ip[i] = EEPROM.read(110 + i);
                                      }
                                      for (int i = 0; i < 4; i++) {
                                      server[i] = EEPROM.read(120 + i);
                                      }
                                      }
                                      ! pinMode(LED, OUTPUT);
                                      ! client.setServer(server, 1883);
                                      client.setCallback(callback);
                                      Ethernet.begin(mac, ip);

                                      delay(200);
                                      //wdt_enable(WDTO_8S);
                                      Serial.println("WDTO_8S");
                                      if (client.connect("test")){
                                      digitalWrite(LED, LOW);
                                      Public();
                                      }
                                      }

                                      ! void serialEvent() {
                                      while (Serial.available() > 0) {
                                      char inChar = (char)Serial.read();
                                      cmd += inChar;
                                      if (inChar == '\n') {
                                      strComplete = true;
                                      }
                                      }
                                      }
                                      ! void loop() {
                                      // wdt_reset();
                                      Serial.println("WDT_reset");
                                      client.loop();
                                      if (!client.connected()) {
                                      reconnect();
                                      }
                                      ! /if (analogRead(PWR_CTRL) < 1000) {
                                      digitalWrite(LED, LOW);
                                      save();
                                      delay(10000);
                                      }
                                      /
                                      ! if (strComplete) {
                                      digitalWrite(LED, !digitalRead(LED));
                                      cmd.toCharArray(buffer, 100);
                                      cnt = atoi(strtok(buffer, ";"));
                                      pwr = atoi(strtok(NULL, ";"));
                                      amp = atoi(strtok(NULL, ";"));
                                      bounce = atoi(strtok(NULL, ";"));
                                      num = atoi(strtok(NULL, ";"));
                                      error = atoi(strtok(NULL, ";"));
                                      client.publish(topic_raw, StrToChar(cmd));
                                      cmd = "";
                                      strComplete = false;
                                      }
                                      ! if (millis() - prevMillis >= poll) {
                                      // wdt_reset();
                                      Serial.println("WDT_reset-");
                                      prevMillis = millis();
                                      if (cnt != prev_cnt || pwr != prev_pwr || amp != prev_amp) {
                                      prev_cnt = cnt;
                                      prev_pwr = pwr;
                                      prev_amp = amp;
                                      client.publish(topic_cnt, IntToChar(cnt));
                                      client.publish(topic_pwr, IntToChar(pwr));
                                      client.publish(topic_amp, IntToChar(amp));
                                      }
                                      if (num != prev_num || bounce != prev_bounce) {
                                      prev_num = num;
                                      prev_bounce = bounce;
                                      client.publish(topic_num, IntToChar(num));
                                      client.publish(topic_bounce, IntToChar(bounce));
                                      }
                                      if (error > 0) {
                                      client.publish(topic_err, "err");
                                      } else {
                                      client.publish(topic_err, " ");
                                      }
                                      }
                                      }
                                      ! void callback_iobroker(String strTopic, String strPayload) {
                                      if (strTopic == topic_correction) {
                                      cnt = atol((strPayload).c_str());
                                      Serial.print("SC");
                                      Serial.println(cnt);
                                      client.publish(topic_correction, "0");
                                      }
                                      else if (strTopic == topic_save) {
                                      if (strPayload == "true") {
                                      Serial.println("SS");
                                      save();
                                      client.publish(topic_save, "false");
                                      }
                                      }
                                      else if (strTopic == topic_polling) {
                                      poll = strPayload.toInt();
                                      if (poll < 1000) {
                                      poll = 1000;
                                      } else if (poll > 32767) {
                                      poll = 32767;
                                      }
                                      EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации
                                      client.publish(topic_polling, IntToChar(poll));
                                      }
                                      else if (strTopic == topic_reset) {
                                      if (strPayload == "true") {
                                      client.publish(topic_reset, "false");
                                      // reboot();
                                      Serial.println("Reboot");
                                      }
                                      }
                                      else if (strTopic == topic_bounce) {
                                      bounce = strPayload.toInt();
                                      if (bounce < 0) {
                                      bounce = 0;
                                      } else if (bounce > 10000) {
                                      bounce = 10000;
                                      }
                                      Serial.print("SB");
                                      Serial.println(bounce);
                                      client.publish(topic_bounce, IntToChar(bounce));
                                      }
                                      else if (strTopic == topic_num) {
                                      num = strPayload.toInt();
                                      if (num < 0) {
                                      num = 0;
                                      } else if (num > 32767) {
                                      num = 32767;
                                      }
                                      Serial.print("SN");
                                      Serial.println(num);
                                      client.publish(topic_num, IntToChar(num));
                                      }
                                      }
                                      ! void save() {
                                      chk = poll - 500;
                                      EEPROMWriteLong(CNT_ADR, cnt); //Пишем показания счетчика в eeprom из переменной
                                      EEPROMWriteInt(POLL_ADR, poll); //Интервал публикации
                                      EEPROMWriteInt(CHK_ADR, chk); //чек
                                      }
                                      ! void reboot() {
                                      //save();
                                      //delay(500);
                                      // wdt_enable(WDTO_1S);
                                      Serial.println("void reboot");
                                      //for (;;) {}
                                      }
                                      ! char* StrToChar (String str) {
                                      int length = str.length();
                                      str.toCharArray(buf, length + 1);
                                      return buf;
                                      }
                                      ! void EEPROMWriteLong(int p_address, unsigned long p_value) {
                                      byte four = (p_value & 0xFF);
                                      byte three = ((p_value >> 😎 & 0xFF);
                                      byte two = ((p_value >> 16) & 0xFF);
                                      byte one = ((p_value >> 24) & 0xFF);
                                      EEPROM.write(p_address, four);
                                      EEPROM.write(p_address + 1, three);
                                      EEPROM.write(p_address + 2, two);
                                      EEPROM.write(p_address + 3, one);
                                      }
                                      ! unsigned long EEPROMReadLong(int p_address) {
                                      long four = EEPROM.read(p_address);
                                      long three = EEPROM.read(p_address + 1);
                                      long two = EEPROM.read(p_address + 2);
                                      long one = EEPROM.read(p_address + 3);
                                      return ((four << 0) & 0xFF) + ((three << 😎 & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
                                      }
                                      ! void EEPROMWriteInt(int p_address, int p_value) {
                                      byte lowByte = ((p_value >> 0) & 0xFF);
                                      byte highByte = ((p_value >> 😎 & 0xFF);
                                      EEPROM.write(p_address, lowByte);
                                      EEPROM.write(p_address + 1, highByte);
                                      }
                                      unsigned int EEPROMReadInt(int p_address) {
                                      byte lowByte = EEPROM.read(p_address);
                                      byte highByte = EEPROM.read(p_address + 1);
                                      return ((lowByte << 0) & 0xFF) + ((highByte << 😎 & 0xFF00);
                                      }
                                      ! char* IntToChar (unsigned long a) {
                                      sprintf(buf, "%lu", a);
                                      return buf;
                                      }
                                      ! void Public() {
                                      sprintf(s, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
                                      client.publish(topic_err, " ");
                                      client.publish(topic_cnt, IntToChar(cnt));
                                      client.publish(topic_pwr, IntToChar(pwr));
                                      client.publish(topic_amp, IntToChar(amp));
                                      client.publish(topic_save, "false");
                                      client.publish(topic_correction, "0");
                                      client.publish(topic_connection, "true");
                                      client.publish(topic_ip, s);
                                      client.publish(topic_polling, IntToChar(poll));
                                      client.publish(topic_bounce, IntToChar(bounce));
                                      client.publish(topic_num, IntToChar(num));
                                      client.publish(topic_reset, "false");
                                      client.subscribe(subscr);
                                      }
                                      void reconnect() {
                                      int a = 0;
                                      while (!client.connected()) {
                                      a++;
                                      digitalWrite(LED, !digitalRead(LED));
                                      //wdt_reset();
                                      Serial.println("WDT reset");
                                      if (client.connect("test")) {
                                      digitalWrite(LED, LOW);
                                      Public();
                                      } else {
                                      delay(10000);
                                      }
                                      if (a >= 10) {
                                      // wdt_enable(WDTO_1S);
                                      Serial.println("WDTO_1S");
                                      }
                                      }
                                      }</avr></eeprom.h></pubsubclient.h></ethernet.h></spi.h>`
                                      ! Ни пинга, ни данных....[/i][/i][/i][/i][/code][/spoiler][/i][/i]

                                      1 Reply Last reply Reply Quote 0
                                      • I
                                        instalator last edited by

                                        @smoker_vvo:

                                        Начнем с простого…. Какая IDE `
                                        ide 1.8.3

                                        Ethernet 1.1.2

                                        PubSubCliet 2.6.0

                                        1 Reply Last reply Reply Quote 0
                                        • S
                                          smoker_vvo last edited by

                                          IDE 1.8.4, остальное совпадает…...

                                          Хорошо, с программным уровнем разобрались. Теперь аппаратный.... Arduino MEGA 2560+EthernetShield W5100

                                          1 Reply Last reply Reply Quote 0
                                          • I
                                            instalator last edited by

                                            @smoker_vvo:

                                            IDE 1.8.4, остальное совпадает…...

                                            Хорошо, с программным уровнем разобрались. Теперь аппаратный.... Arduino MEGA 2560+EthernetShield W5100 `
                                            Да какая разница какая ардуина, я на УНО и W5100 проверял

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            688
                                            Online

                                            31.7k
                                            Users

                                            79.8k
                                            Topics

                                            1.3m
                                            Posts

                                            3
                                            70
                                            12444
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo