Weiter zum Inhalt
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Hell
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dunkel
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Русский
  3. ioBroker
  4. Скрипты
  5. ioBroker скрипты
  6. Скрипт для счётчика

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    705

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    18
    1
    5.8k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.5k

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

Geplant Angeheftet Gesperrt Verschoben ioBroker скрипты
70 Beiträge 3 Kommentatoren 15.0k Aufrufe
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • S Offline
    S Offline
    smoker_vvo
    schrieb am zuletzt editiert von
    #50

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

    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 Antwort Letzte Antwort
    0
    • S Offline
      S Offline
      smoker_vvo
      schrieb am zuletzt editiert von
      #51

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

      1 Antwort Letzte Antwort
      0
      • I Offline
        I Offline
        instalator
        schrieb am zuletzt editiert von
        #52

        @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]
        ``` `

        Высокий уровень Децибел вреден для здоровья!

        http://blog.instalator.ru/

        1 Antwort Letzte Antwort
        0
        • S Offline
          S Offline
          smoker_vvo
          schrieb am zuletzt editiert von
          #53

          ок.

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

          1 Antwort Letzte Antwort
          0
          • I Offline
            I Offline
            instalator
            schrieb am zuletzt editiert von
            #54

            @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 >> 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("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]

            Высокий уровень Децибел вреден для здоровья!

            http://blog.instalator.ru/

            1 Antwort Letzte Antwort
            0
            • S Offline
              S Offline
              smoker_vvo
              schrieb am zuletzt editiert von
              #55

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

              1 Antwort Letzte Antwort
              0
              • I Offline
                I Offline
                instalator
                schrieb am zuletzt editiert von
                #56

                @smoker_vvo:

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

                Высокий уровень Децибел вреден для здоровья!

                http://blog.instalator.ru/

                1 Antwort Letzte Antwort
                0
                • S Offline
                  S Offline
                  smoker_vvo
                  schrieb am zuletzt editiert von
                  #57

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

                  1 Antwort Letzte Antwort
                  0
                  • S Offline
                    S Offline
                    smoker_vvo
                    schrieb am zuletzt editiert von
                    #58

                    в 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 Antwort Letzte Antwort
                    0
                    • S Offline
                      S Offline
                      smoker_vvo
                      schrieb am zuletzt editiert von
                      #59

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

                      1 Antwort Letzte Antwort
                      0
                      • S Offline
                        S Offline
                        smoker_vvo
                        schrieb am zuletzt editiert von
                        #60

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

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

                        1 Antwort Letzte Antwort
                        0
                        • S Offline
                          S Offline
                          smoker_vvo
                          schrieb am zuletzt editiert von
                          #61

                          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 >> 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("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 Antwort Letzte Antwort
                          0
                          • I Offline
                            I Offline
                            instalator
                            schrieb am zuletzt editiert von
                            #62

                            @smoker_vvo:

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

                            Ethernet 1.1.2

                            PubSubCliet 2.6.0

                            Высокий уровень Децибел вреден для здоровья!

                            http://blog.instalator.ru/

                            1 Antwort Letzte Antwort
                            0
                            • S Offline
                              S Offline
                              smoker_vvo
                              schrieb am zuletzt editiert von
                              #63

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

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

                              1 Antwort Letzte Antwort
                              0
                              • I Offline
                                I Offline
                                instalator
                                schrieb am zuletzt editiert von
                                #64

                                @smoker_vvo:

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

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

                                Высокий уровень Децибел вреден для здоровья!

                                http://blog.instalator.ru/

                                1 Antwort Letzte Antwort
                                0
                                • S Offline
                                  S Offline
                                  smoker_vvo
                                  schrieb am zuletzt editiert von
                                  #65

                                  Хлебнуфф пивка и выкурив сигаретку, психанул и заменил Arduino MEGA на Arduino NANO- и О ЧУДО!!!! Все заработало…...

                                  Теперь другие вопросы....

                                  в строке RAW получаю такие значения 268494237;4294935483;0;-9325;-120;0, как их разобрать?? Что есть что??

                                  1 Antwort Letzte Antwort
                                  0
                                  • S Offline
                                    S Offline
                                    smoker_vvo
                                    schrieb am zuletzt editiert von
                                    #66

                                    ан все таки есть… Щас сборка выглядит так :

                                    Нано собирает инфу от счетчика - УНО обрабатывает - В5100 - отдает на Брокера

                                    В предыдущем вопле ошибочка, Мега заменил на УНО

                                    1 Antwort Letzte Antwort
                                    0
                                    • I Offline
                                      I Offline
                                      instalator
                                      schrieb am zuletzt editiert von
                                      #67

                                      @smoker_vvo:

                                      Хлебнуфф пивка и выкурив сигаретку, психанул и заменил Arduino MEGA на Arduino NANO- и О ЧУДО!!!! Все заработало…...

                                      Теперь другие вопросы....

                                      в строке RAW получаю такие значения 268494237;4294935483;0;-9325;-120;0, как их разобрать?? Что есть что?? `
                                      https://github.com/instalator/Electro_C … t.ino#L278

                                      https://blog.instalator.ru/archives/711

                                      cnt = atoi(strtok(buffer, ";")); //счетчик

                                      pwr = atoi(strtok(NULL, ";")); //мощность

                                      amp = atoi(strtok(NULL, ";")); //сила тока!

                                      bounce = atoi(strtok(NULL, ";")); //задержка от дребезга

                                      num = atoi(strtok(NULL, ";")); //Значение передаточного числа счетчика. Количество импульсов на 1 кВт*ч

                                      error = atoi(strtok(NULL, ";")); //ошибка

                                      Высокий уровень Децибел вреден для здоровья!

                                      http://blog.instalator.ru/

                                      1 Antwort Letzte Antwort
                                      0
                                      • I Offline
                                        I Offline
                                        instalator
                                        schrieb am zuletzt editiert von
                                        #68

                                        По скрипту для счетчика меркурий вынес в отдельную тему http://forum.iobroker.net/viewtopic.php?f=26&t=8148

                                        Высокий уровень Децибел вреден для здоровья!

                                        http://blog.instalator.ru/

                                        1 Antwort Letzte Antwort
                                        0
                                        • S Offline
                                          S Offline
                                          smoker_vvo
                                          schrieb am zuletzt editiert von
                                          #69

                                          Зенкую! Я так и понял. Но проект заглох… проработав два часа......

                                          и повторно запустить не удалось....

                                          Не могу понять по чему........
                                          1308_counter.png

                                          1 Antwort Letzte Antwort
                                          0

                                          Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.

                                          Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.

                                          Mit deinem Input könnte dieser Beitrag noch besser werden 💗

                                          Registrieren Anmelden
                                          Antworten
                                          • In einem neuen Thema antworten
                                          Anmelden zum Antworten
                                          • Älteste zuerst
                                          • Neuste zuerst
                                          • Meiste Stimmen


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          320

                                          Online

                                          32.7k

                                          Benutzer

                                          82.6k

                                          Themen

                                          1.3m

                                          Beiträge
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Anmelden

                                          • Du hast noch kein Konto? Registrieren

                                          • Anmelden oder registrieren, um zu suchen
                                          • Erster Beitrag
                                            Letzter Beitrag
                                          0
                                          • Home
                                          • Aktuell
                                          • Tags
                                          • Ungelesen 0
                                          • Kategorien
                                          • Unreplied
                                          • Beliebt
                                          • GitHub
                                          • Docu
                                          • Hilfe