Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. smilvert
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by smilvert

    • RE: RFM95 RFM95:SWR:NACK

      @lood29 When I use TTGO LORA as a dummy sensor (Node 10 in the above log) it always works without any nacks.

      The NACK only appears when I connect my own sensor (Node 140 in the log above).

      So Scenario 1
      Dummy sensor (TTGO LORA) <-> MQTT gateway (TTGO LORA) -> Works

      Scenario 2
      My sensor <-> MQTT gateway (TTGO LORA) -> NACK in the Gateway.

      posted in Troubleshooting
      smilvert
      smilvert
    • RFM95 RFM95:SWR:NACK

      Hi

      Im trying to setup a temperature sensor that should be placed at my jetty, 350 meters from my house. So I have chosen RFM95 as my radio, an E-ink display to show the temperature but I have some struggle to this setup. Need some debug help.

      As the controller I have a TTGO LORA.

      I have two of the TTGO LORA, One gateway and one debug sensor, so I can verify that thoose are working with mysensors but when I add my custom sensor I receives a lot of !RFM95:SWR:NACK from the Gateway.

      Sensor code:

      //#define MY_PASSIVE_NODE
      //#define PIN_SERIAL_TX       (8) 
      // Enable debug prints
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_RFM95
      
      //#define   MY_DEBUG_VERBOSE_NRF5_ESB
      #define MY_NODE_ID 140
      //#define MY_GATEWAY_SERIAL
      
      
      #define MY_RFM95_RST_PIN 15
      #define MY_RFM95_IRQ_PIN 16
      #define MY_RFM95_IRQ_NUM MY_RFM95_IRQ_PIN
      #define DEFAULT_RFM95_CS_PIN      (SS)
      
      #define MY_RFM95_FREQUENCY (RFM95_434MHZ)
      // #define MY_RFM95_ATC_MODE_DISABLED
      #define MY_RFM95_ATC_TARGET_RSSI_DBM (-70)  // target RSSI -70dBm
      #define MY_RFM95_MAX_POWER_LEVEL_DBM (10)   // max. TX power 10dBm = 10mW
      
      #define RFM95_RETRY_TIMEOUT_MS 3000ul
      #define MY_TRANSPORT_STATE_TIMEOUT_MS 6*1000ul
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      #define MY_RADIO_RFM95
      
      
      #include <MySensors.h>
      
      #define ENABLE_GxEPD2_GFX 1
      
      #include <GxEPD2_BW.h>
      #include <GxEPD2_3C.h>
      
      #include "Fonts/FreeMonoBold9pt7b.h" 
      #include "Fonts/FreeSerif18pt7b.h" 
      #include "Fonts/FreeSans18pt7b.h" 
      #include "Fonts/FreeSansBold24pt7b.h" 
      
      
      GxEPD2_BW<GxEPD2_154, GxEPD2_154::HEIGHT> display(GxEPD2_154(/*CS=5*/ 22, /*DC=*/ 24, /*RST=*/ -1, /*BUSY=*/ 19));
      
      #include "GxEPD2_boards_added.h"
      #include "bitmaps/Bitmaps200x200.h" // 1.54" b/w
      
      
      #define CHILD_ID_TEMP           (0)  
      #define CHILD_ID_HUM            (1)
      
      // ID of the sensor child
      #define CHILD_ID_UPLINK_QUALITY (2)
      #define CHILD_ID_TX_LEVEL       (3)
      #define CHILD_ID_TX_PERCENT     (4)
      #define CHILD_ID_TX_RSSI        (5)
      #define CHILD_ID_RX_RSSI        (6)
      #define CHILD_ID_TX_SNR         (7)
      #define CHILD_ID_RX_SNR         (8)
      
      
      // Initialize general message
      MyMessage msgTxRSSI(CHILD_ID_TX_RSSI, V_DISTANCE);
      MyMessage msgRxRSSI(CHILD_ID_RX_RSSI, V_DISTANCE);
      MyMessage msgTxSNR(CHILD_ID_TX_SNR, V_DISTANCE);
      MyMessage msgRxSNR(CHILD_ID_RX_SNR, V_DISTANCE);
      MyMessage msgTxLevel(CHILD_ID_TX_LEVEL, V_DISTANCE);
      MyMessage msgTxPercent(CHILD_ID_TX_PERCENT, V_DISTANCE);
      MyMessage msgUplinkQuality(CHILD_ID_UPLINK_QUALITY, V_DISTANCE);
      
      #define ledPin LED_BUILTIN
      // Initialize general message
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      
      float batteryVoltage = 0;
      float temperature = 0;
      int humidity = 0;
      int counter = 0;
      int switch_led = 1;
      
      void setup()
      {
        
        Serial.print("Display init");
        sleep(1000);
        hwPinMode(ledPin, OUTPUT_D0H1);
      
        NRF_CLOCK->INTENSET = B11; //enable interrupts for EVENTS_HFCLKSTARTED and  EVENTS_LFCLKSTARTED
        NRF_CLOCK->TASKS_HFCLKSTART = 1; //start the high frequency crystal oscillator clock
        while (!(NRF_CLOCK->EVENTS_HFCLKSTARTED)) {} //wait until high frequency crystal oscillator clock is up to speed and working
      
        pinMode(ledPin, OUTPUT);
        digitalWrite(ledPin, HIGH);
        display.init(115200);
        clearScreen();
      
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and controller
        sendSketchInfo("Passive node", "1.1");
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_TEMP, S_TEMP, "Temp");
        present(CHILD_ID_HUM, S_HUM, "Hum");
      
        present(CHILD_ID_UPLINK_QUALITY, S_DISTANCE, "UPLINK QUALITY RSSI");
        present(CHILD_ID_TX_LEVEL, S_DISTANCE, "TX LEVEL DBM");
        present(CHILD_ID_TX_PERCENT, S_DISTANCE, "TX LEVEL PERCENT");
        present(CHILD_ID_TX_RSSI, S_DISTANCE, "TX RSSI");
        present(CHILD_ID_RX_RSSI, S_DISTANCE, "RX RSSI");
        present(CHILD_ID_TX_SNR, S_DISTANCE, "TX SNR");
        present(CHILD_ID_RX_SNR, S_DISTANCE, "RX SNR");
      
      }
      
      void loop()
      {
      
        // generate some random data
        counter ++;
        if (counter == 10 ) {
          temperature = 0;
          humidity = 0;
          counter = 0;
        }
        else
        {
          temperature = 25.0 + random(0, 30) / 10.0;
          humidity = 55.0 + random(-20, 20);
        }
        int16_t uplink = transportGetSignalReport(SR_UPLINK_QUALITY);
        int16_t power_link = transportGetSignalReport(SR_TX_POWER_LEVEL);
        int16_t tx_power_percent = transportGetSignalReport(SR_TX_POWER_PERCENT);
        int16_t tx_rssi = transportGetSignalReport(SR_TX_RSSI);
        int16_t rx_rssi = transportGetSignalReport(SR_RX_RSSI);
        int16_t tx_snr = transportGetSignalReport(SR_TX_SNR);
        int16_t rx_snr = transportGetSignalReport(SR_RX_SNR);
      
        send(msgUplinkQuality.set(uplink));
        send(msgTxLevel.set(power_link));
        send(msgTxPercent.set(tx_power_percent));
        // retrieve RSSI / SNR reports from incoming ACK
        send(msgTxRSSI.set(tx_rssi));
        send(msgRxRSSI.set(rx_rssi));
        send(msgTxSNR.set(tx_snr));
        send(msgRxSNR.set(rx_snr));
        // wait a bit
      
        showDisplay(temperature, humidity, counter, uplink, power_link, tx_power_percent, tx_rssi, rx_rssi);
        send(msgTemp.set(temperature, 2));
        send(msgHum.set(humidity, 2));
        wait(5000);
      
        if (switch_led == 1)
        {
          digitalWrite(ledPin, HIGH);
          switch_led = 0;
        } else {
          digitalWrite(ledPin, LOW);
          switch_led = 1;
        }
      
      }
      
      const char temp[] = "Vattentemp:";
      const char hum[] = "Hum: ";
      const char counter_text[] = "Counter: ";
      const char hello[] = "Hello";
      const char clearText[] = "CLEAR";
      const char UPLINK_QUALITYtext[] = "Uplink_qa: ";
      const char TX_POWER_LEVELtext[] = "Tx power level: ";
      const char TX_RSSItext[] = "Tx rssi: ";
      const char RX_RSSItext[] = "RX rssi";
      const char TX_POWER_PERCENT_text[] = "Tx power:";
      
      
      void clearScreen()
      {
        display.setFullWindow();
        display.setTextColor(GxEPD_BLACK);
        display.fillScreen(GxEPD_WHITE);
        display.setCursor(0, 0);
        display.firstPage();
        do
        {
        }
        while (display.nextPage() );
      }
      
      void showDisplay(float temperature, int humidity, int counter,
                      int UPLINK_QUALITY, int TX_POWER_LEVEL, int TX_POWER_PERCENT,
                      int TX_RSSI, int RX_RSSI)
      {
        display.setRotation(1);
        display.setPartialWindow(0, 0, display.width(), display.height());
        display.setTextColor(GxEPD_BLACK);
        //display.setFullWindow();
        display.setCursor(0, 0);
        display.firstPage();
        // display.fillScreen(GxEPD_WHITE);
        uint16_t x = (display.width() ) ;
        uint16_t y = (display.height() ) ;
        display.setCursor(10, 50);
      
        do
        {
          display.setFont(&FreeSans18pt7b);
          display.println(temp);
          display.setFont(&FreeMonoBold9pt7b);
          display.println();
          display.println();
          display.setFont(&FreeSansBold24pt7b);
          display.print(temperature, 1);
          display.setFont(&FreeMonoBold9pt7b);
          display.println();
      
          display.print(counter_text);
          display.println(counter);
      
      
          display.print(TX_RSSItext);
          display.println(TX_RSSI);
      
          display.print(RX_RSSItext);
          display.println(RX_RSSI);
        }
        while (display.nextPage() );
        Serial.println("showDisplay done");
      }
      
      

      Gateway code:

      /*
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2019 Sensnology AB
       * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - tekka
       *
       * DESCRIPTION
       * The ESP32 gateway sends data received from sensors to the WiFi link.
       * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
       *
       * Make sure to fill in your ssid and WiFi password below.
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      #define MY_DEBUG_VERBOSE_RFM95
      #define MY_DEBUG_VERBOSE_TRANSPORT
      #define MY_DEBUG_VERBOSE_GATEWAY
      #define MY_DEBUG_VERBOSE_TRANSPORT_HAL
      
      #define MY_RADIO_RFM95
      
      #define RST     14   // GPIO14 -- SX1278's RESET
      #define DI0     26   // GPIO26 -- SX1278's IRQ(Interrupt Request)
      
      #define MY_RFM95_IRQ_PIN DI0
      #define MY_RFM95_IRQ_NUM MY_RFM95_IRQ_PIN
      #define MY_RFM95_CS_PIN SS
      
      #define MY_RFM95_FREQUENCY (RFM95_434MHZ)
      
      #define MY_GATEWAY_ESP32
      #define MY_GATEWAY_MQTT_CLIENT
      
      // Set this node's subscribe and publish topic prefix
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
      
      // Set MQTT client id
      #define MY_MQTT_CLIENT_ID "mysensors-1"
      
      // Set WIFI SSID and password
      #define MY_WIFI_SSID "xxxxx"
      #define MY_WIFI_PASSWORD "xxxx"
      
      // Set the hostname for the WiFi Client. This is the hostname
      // passed to the DHCP server if not static.
      #define MY_HOSTNAME "ESP32_MQTT_GW"
      
      // MQTT broker ip address.
      #define MY_CONTROLLER_IP_ADDRESS 10, 0, 0, 3
      
      // The MQTT broker port to to open
      #define MY_PORT 1883
      
      #include <MySensors.h>
      
      void setup()
      {
      	Serial.println("Setup");
      }
      
      void presentation()
      {
      	// Present locally attached sensors here
      }
      
      void loop()
      {
      	// Send locally attech sensors data here
      }
      
      

      Debug log from sensor:

      23 MCO:BGN:INIT NODE,CP=RLNNN---,FQ=16,REL=255,VER=2.3.2
      29 TSM:INIT
      30 TSF:WUR:MS=0
      31 RFM95:INIT
      38 RFM95:INIT:PIN,CS=11,IQP=16,IQN=16,RST=15
      52 RFM95:PTX:LEVEL=13
      54 TSM:INIT:TSP OK
      55 TSM:INIT:STATID=140
      58 TSF:SID:OK,ID=140
      60 TSM:FPAR
      61 RFM95:SWR:SEND,TO=255,SEQ=0,RETRY=0
      7064 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=NACK:
      13071 !TSM:FPAR:NO REPLY
      13073 TSM:FPAR
      13074 RFM95:SWR:SEND,TO=255,SEQ=1,RETRY=0
      20078 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=1,st=NACK:
      26085 !TSM:FPAR:NO REPLY
      26087 TSM:FPAR
      26088 RFM95:SWR:SEND,TO=255,SEQ=2,RETRY=0
      33092 ?TSF:MSG:SEND,140-140-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=2,st=NACK:
      39099 !TSM:FPAR:NO REPLY
      39101 TSM:FPAR
      

      Debug from gateway:

      
      1982032 THA:DATA:AVAIL
      1982084 RFM95:SAC:SEND ACK,TO=10,SEQ=27,RSSI=-17,SNR=9
      1982132 THA:RCV:MSG=0A0A0022810D0500FFFFFF
      1982136 THA:RCV:MSG LEN=11
      1982138 TSF:MSG:READ,10-10-0,s=5,c=1,t=13,pt=4,l=4,sg=0:-256
      1982143 GWT:TPS:TOPIC=mygateway1-out/10/5/1/0/13,MSG SENT
      1982782 THA:DATA:AVAIL
      1982834 RFM95:SAC:SEND ACK,TO=10,SEQ=28,RSSI=-17,SNR=10
      1982882 THA:RCV:MSG=0A0A0022810D0609000000
      1982886 THA:RCV:MSG LEN=11
      1982888 TSF:MSG:READ,10-10-0,s=6,c=1,t=13,pt=4,l=4,sg=0:9
      1982893 GWT:TPS:TOPIC=mygateway1-out/10/6/1/0/13,MSG SENT
      1983582 THA:DATA:AVAIL
      1983634 RFM95:SAC:SEND ACK,TO=10,SEQ=29,RSSI=-18,SNR=9
      1983682 THA:RCV:MSG=0A0A002AE100086666CE4102
      1983686 THA:RCV:MSG LEN=12
      1983688 TSF:MSG:READ,10-10-0,s=8,c=1,t=0,pt=7,l=5,sg=0:25.80
      1983694 GWT:TPS:TOPIC=mygateway1-out/10/8/1/0/0,MSG SENT
      1984382 THA:DATA:AVAIL
      1984434 RFM95:SAC:SEND ACK,TO=10,SEQ=30,RSSI=-18,SNR=9
      1984482 THA:RCV:MSG=0A0A002AE101070000544202
      1984486 THA:RCV:MSG LEN=12
      1984488 TSF:MSG:READ,10-10-0,s=7,c=1,t=1,pt=7,l=5,sg=0:53.00
      1984494 GWT:TPS:TOPIC=mygateway1-out/10/7/1/0/1,MSG SENT
      1988912 THA:DATA:AVAIL
      1988914 THA:RCV:MSG=8C8CFF020307FF
      1988917 THA:RCV:MSG LEN=7
      1988919 TSF:MSG:READ,140-140-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
      1988924 TSF:MSG:BC
      1988926 TSF:MSG:FPAR REQ,ID=140
      1988929 TSF:PNG:SEND,TO=0
      1988931 TSF:CKU:OK
      1988933 TSF:MSG:GWL OK
      1989262 THA:SND:MSG=00008C0A2308FF00
      1989265 RFM95:SWR:SEND,TO=140,SEQ=65,RETRY=0
      1989817 !RFM95:SWR:NACK
      1989836 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=1
      1990388 !RFM95:SWR:NACK
      1990478 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=2
      1991030 !RFM95:SWR:NACK
      1991062 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=3
      1991614 !RFM95:SWR:NACK
      1991630 RFM95:SWR:SEND,TO=140,SEQ=66,RETRY=4
      1992182 !RFM95:SWR:NACK
      1992266 THA:SND:MSG LEN=8,RES=0
      1992268 !TSF:MSG:SEND,0-0-140-140,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
      

      And here I can see that the gateway recieves data from sensor 140 but can't ack 😞

      Can someone please help me?

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: GWT:TPC:CONNECTING

      @electrik A ticket is raised quite long time ago, https://github.com/mysensors/MySensors/issues/1376

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: GWT:TPC:CONNECTING

      No I have no idea. For me it seems to work.

      Currently I don't have any sensors conncted so its hard to see if it works.

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: GWT:TPC:CONNECTING

      @DenisJ I have the same problem. Works with

      #define MY_GATEWAY_ESP32
      

      but with

      #define MY_GATEWAY_ESP32
      #define MY_GATEWAY_MQTT_CLIENT
      

      it dosen't. But when I changed the delay to 3000

      bool gatewayTransportConnect(void)
      {
      #if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)
      	if (WiFi.status() != WL_CONNECTED) {
      		GATEWAY_DEBUG(PSTR("GWT:TPC:CONNECTING...\n"));
      		delay(3000); // Was 1000
      		return false;
      	}
      	GATEWAY_DEBUG(PSTR("GWT:TPC:IP=%s\n"), WiFi.localIP().toString().c_str());
      

      in MyGatewayTransportMQTTClient.cpp then it started to work! πŸ™‚

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: Heltec esp32 LoRa oled

      @mrussi I am also interested in using an esp32 with lora as the gateway. Did you make it work?

      I planning to buy, https://www.botnroll.com/en/esp/2979-esp32-wifi-bluetooth-lora-sx1278-433mhz-with-0-96-oled-display.html

      posted in Hardware
      smilvert
      smilvert
    • RE: NRF52 -> Will not wake after sleep

      I have been trying @nagelc code with a lot of debug prints and I think that my device is stuck after

      MyHwNRF5.cpp

      inline void hwSleep(void)
      {	CORE_DEBUG(PSTR("In hwSleep, 345\n"));
      	__WFE();
      	__SEV();
      	__WFE();
      	CORE_DEBUG(PSTR("In hwSleep, 351\n"));
      }
      
      int8_t hwSleep(uint32_t ms)
      {
      	hwSleepPrepare(ms);
      	while (nrf5_rtc_event_triggered == false) {
      		hwSleep();
      	}
      	CORE_DEBUG(PSTR("In hwSleep, 357\n"));
      	hwSleepEnd(ms);
      	return MY_WAKE_UP_BY_TIMER;
      }
      

      And I will not go to hwSleepEnd

      11274 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255
      11280 TSF:TDI:TPD
      11281 After transport Disable
      11284 Before hwSleep
      11286 In hwSleepPrepare, 287
      11289 In hwSleepPrepare,300
      11291 In hwSleep, 345
      
      posted in Troubleshooting
      smilvert
      smilvert
    • RE: NRF52 -> Will not wake after sleep

      @nagelc Thanks will try

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: NRF52 -> Will not wake after sleep

      @nagelc can you use
      MY_DEBUG_VERBOSE_NRF5_ESB

      Do I need to add a bigger capacitor between gnd and +3?

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: NRF52 -> Will not wake after sleep

      I have a feeling that the

      Wait()
      

      Is the problem but haven't had time to investigate.

      posted in Troubleshooting
      smilvert
      smilvert
    • NRF52 -> Will not wake after sleep

      Hi

      Finally I have had time to solder my project, Temp_hum, and started to create the code for it. But I struggle with some bascis

      Code for the sensor:

      
      #define MY_NODE_ID 37
      
      // Enable debug prints
      #define MY_DEBUG
      
      // #define MY_DEBUG_VERBOSE_NRF5_ESB
      #define MY_BAUD_RATE 115200
      
      // Enable and select radio type attached
      //#define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RS485
      #define MY_RADIO_NRF5_ESB
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_VOLT 2
      
      #define IS_NRF52
      // #define IS_NRF51
      
      #define SHORT_WAIT 100
      
      // Sleep time between sensor updates (in milliseconds)
      static const uint64_t UPDATE_INTERVAL = 6000;
      
      static bool metric = true;
      
      float batteryPcnt;
      float oldBatteryPcnt;
      
      #include <MySensors.h>
      #include <SI7021.h>
      
      static SI7021 sensor;
      
      void disableNfc()
      { //only applied to nRF52
      
      #ifdef IS_NRF52
        //Make pins 9 and 10 usable as GPIO pins.
        NRF_NFCT->TASKS_DISABLE = 1; //disable NFC
        NRF_NVMC->CONFIG = 1;        // Write enable the UICR
        NRF_UICR->NFCPINS = 0;       //Make pins 9 and 10 usable as GPIO pins.
        NRF_NVMC->CONFIG = 0;        // Put the UICR back into read-only mode.
      #endif
      }
      
      void turnOffRadio()
      {
        NRF_RADIO->TASKS_DISABLE = 1;
        while (!(NRF_RADIO->EVENTS_DISABLED))
        {
        } //until radio is confirmed disabled
      }
      
      void turnOffAdc()
      {
      #ifndef IS_NRF52
        if (NRF_SAADC->ENABLE)
        { //if enabled, then disable the SAADC
          NRF_SAADC->TASKS_STOP = 1;
          while (NRF_SAADC->EVENTS_STOPPED)
          {
          }                      //wait until stopping of SAADC is confirmed
          NRF_SAADC->ENABLE = 0; //disable the SAADC
          while (NRF_SAADC->ENABLE)
          {
          } //wait until the disable is confirmed
        }
      #endif
      }
      
      void turnOffUarte0()
      {
      #ifndef IS_NRF52
        NRF_UARTE0->TASKS_STOPRX = 1;
        NRF_UARTE0->TASKS_STOPTX = 1;
        NRF_UARTE0->TASKS_SUSPEND = 1;
        NRF_UARTE0->ENABLE = 0; //disable UART0
        while (NRF_UARTE0->ENABLE != 0)
        {
        }; //wait until UART0 is confirmed disabled.
      #endif
      
      #ifdef IS_NRF51
        NRF_UART0->TASKS_STOPRX = 1;
        NRF_UART0->TASKS_STOPTX = 1;
        NRF_UART0->TASKS_SUSPEND = 1;
        NRF_UART0->ENABLE = 0; //disable UART0
        while (NRF_UART0->ENABLE != 0)
        {
        }; //wait until UART0 is confirmed disabled.
      #endif
      }
      
      void turnOffHighFrequencyClock()
      {
        NRF_CLOCK->TASKS_HFCLKSTOP = 1;
        while ((NRF_CLOCK->HFCLKSTAT) & 0x0100)
        {
        } //wait as long as HF clock is still running.
      }
      
      void mySleepPrepare()
      { //turn-off energy drains prior to sleep
        turnOffHighFrequencyClock();
        turnOffRadio();
        //turnOffUarte0();
      }
      
      void presentation()
      {
        Serial.println("Presentation");
        // Send the sketch info to the gateway
        sendSketchInfo("TemperatureAndHumidity", "1.2");
      
        // Present sensors as children to gateway
        present(CHILD_ID_HUM, S_HUM, "Humidity");
        delay(SHORT_WAIT);
        present(CHILD_ID_TEMP, S_TEMP, "Temperature");
        delay(SHORT_WAIT);
        present(CHILD_ID_VOLT, S_MULTIMETER, "Battery");
      
        metric = getControllerConfig().isMetric;
        Serial.println("End presention");
      }
      
      void setup()
      {
        Serial.println("Setup");
        hwInit();
        
        disableNfc(); //remove unnecessary energy drains
        turnOffAdc(); //remove unnecessary energy drains
        while (not sensor.begin())
        {
          Serial.println(F("Sensor not detected!"));
          wait(5000);
        }
        Serial.println("End Setup");
      }
      
      void mySleep(uint32_t ms)
      {
        mySleepPrepare();  //Take steps to reduce drains on battery current prior to sleeping
        sleep(ms);
      }
      
      void loop()
      {
        // Read temperature & humidity from sensor.
        const float temperature = float(metric ? sensor.getCelsiusHundredths() : sensor.getFahrenheitHundredths()) / 100.0;
        const float humidity = float(sensor.getHumidityBasisPoints()) / 100.0;
      
      #ifdef MY_DEBUG
        Serial.print(F("Temp "));
        Serial.print(temperature);
        Serial.print(metric ? 'C' : 'F');
        Serial.print(F("\tHum "));
        Serial.println(humidity);
      #endif
      
        static MyMessage msgHum(CHILD_ID_HUM, V_HUM);
        static MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        static MyMessage msgBattery(CHILD_ID_VOLT, V_VOLTAGE);
      
        send(msgTemp.set(temperature, 2));
      
        wait(SHORT_WAIT);
        send(msgHum.set(humidity, 2));
      
        float batteryVolt = getInternalVoltage();
        batteryPcnt =(batteryVolt / 3.3) * 100;
        if (batteryPcnt > 100)
        {
          batteryPcnt = 100;
        }
      #ifdef MY_DEBUG
        Serial.print(F("Vbat "));
        Serial.print(batteryVolt);
        Serial.print(F(" Battery percent "));
        Serial.println(batteryPcnt);
      #endif
      
        // Battery readout should only go down. So report only when new value is smaller than previous one.
        if (batteryPcnt < oldBatteryPcnt)
        {
      
          wait(SHORT_WAIT);
          send(msgBattery.set(batteryVolt, 3));
          wait(SHORT_WAIT);
          if (batteryPcnt < oldBatteryPcnt)
          {
            sendBatteryLevel(batteryPcnt);
            oldBatteryPcnt = batteryPcnt;
          }
      
          // Sleep until next update to save energy
          // 
          
        }
        //delay(5000);
        mySleep(UPDATE_INTERVAL);
      }
      
      float getInternalVoltage()
      {
        return ((float)hwCPUVoltage()) / 1000.0;
      }
      
      

      Have some problems.

      First and biggest: The sensor will not wake,

      2577 TSF:MSG:SEND,37-37-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:33.34
      Vbat 3.29 Battery percent 99.67
      2587 MCO:SLP:MS=6000,SMS=0,I1=255,M1=255,I2=255,M2=255
      2591 TSF:TDI:TPD
      8593 MCO:SLP:WUP=-1
      8595 TSF:TRI:TPU
      Temp 23.46C	Hum 33.85
      8626 TSF:MSG:SEND,37-37-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:23.46
      8733 TSF:MSG:SEND,37-37-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:33.85
      Vbat 3.29 Battery percent 99.67
      8743 MCO:SLP:MS=6000,SMS=0,I1=255,M1=255,I2=255,M2=255
      8748 TSF:TDI:TPD
      

      (Some times I got stuck at:

      5803 MCO:SLP:MS=6000,SMS=0,I1=255,M1=255,I2=255,M2=255
      5807 TSF:TDI:TPD
      11809 MCO:SLP:WUP=-1
      11811 TSF:TRI:TPU
      Temp 22.69C	Hum 31.08
      11842 TSF:MSG:SEND,37-37-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:22.69
      

      )

      Second when im trying to debug with

      #define MY_DEBUG_VERBOSE_NRF5_ESB
      

      the node will not pass presentation.

      153 NRF5:SND:END=1,ACK=1,RTRY=1,RSSI=-55,WAKE=5
      4158 TSF:MSG:SEND,37-37-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
      4164 NRF5:SND:TO=0,LEN=8,PID=1,NOACK=0
      4169 NRF5:SND:END=1,ACK=1,RTRY=1,RSSI=-55,WAKE=4
      4174 TSF:MSG:SEND,37-37-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      4180 NRF5:RX:LEN=9,NOACK=0,PID=2,RSSI=-74,RX=0
      4184 TSF:MSG:READ,0-0-37,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      4190 NRF5:RX:LEN=8,NOACK=0,PID=1,RSSI=-53,RX=0
      4194 TSF:MSG:READ,0-0-37,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      Presentation
      4200 NRF5:SND:TO=0,LEN=29,PID=2,NOACK=0
      4206 NRF5:SND:END=1,ACK=1,RTRY=1,RSSI=-55,WAKE=5
      4210 TSF:MSG:SEND,37-37-0-0,s=255,c=3,t=11,pt=0,l=22,sg=0,ft=0,st=OK:TemperatureAndHumidity
      4218 NRF5:SND:TO=0,LEN=10,PID=3,NOACK=0
      4223 NRF5:SND:END=1,ACK=1,RTRY=1,RSSI=-55,WAKE=4
      4228 TSF:MSG:SEND,37-37-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.2
      4234 NRF5:SND:TO=0,LEN=15,PID=0,NOACK=0
      4239 NRF5:SND:END=1,ACK=1,RTRY=1,RSSI=-55,WAKE=4
      4244 TSF:MSG:SEND,37-37-0-0,s=0,c=0,t=7,pt=0,l=8,sg=0,ft=0,st=OK:Humidity
      

      Someone that can help me?

      posted in Troubleshooting
      smilvert
      smilvert
    • hwSPI NRF52

      Hi

      I want to understand how the hwSPI works for the NRF52 and a RFM95 module.

      I suppose that I can define more then one SPI interface in the file MyBoardNRF5.h so it looks like
      SodaqMoja/SodaqCore-samd (should be updated to the NRF52 pins)

      #ifdef ENABLE_SPI1
      #define SPI_INTERFACES_COUNT 2
      #else
      #define SPI_INTERFACES_COUNT 1
      #endif
      
      // SPI
      #define PIN_SPI_MISO         (42u)
      #define PIN_SPI_SS           (43u)
      #define PIN_SPI_MOSI         (44u)
      #define PIN_SPI_SCK          (45u)
      
      static const uint8_t MISO = PIN_SPI_MISO;
      static const uint8_t SS   = PIN_SPI_SS ;
      static const uint8_t SS_DFLASH  = PIN_SPI_SS ;
      static const uint8_t MOSI = PIN_SPI_MOSI ;
      static const uint8_t SCK  = PIN_SPI_SCK ;
      
      // SPI1
      #define PIN_SPI1_MISO        (53u)
      #define PIN_SPI1_SS          (54u)
      #define PIN_SPI1_MOSI        (55u)
      #define PIN_SPI1_SCK         (56u)
      
      static const uint8_t MISO1 = PIN_SPI1_MISO;
      static const uint8_t SS1   = PIN_SPI1_SS;
      static const uint8_t MOSI1 = PIN_SPI1_MOSI;
      static const uint8_t SCK1  = PIN_SPI1_SCK;
      

      But I don't get how I will init the second SPI bus and point it to the RFM95 module. Guessing it should be define RFM95_SPI SPI1 or something like that?

      #if !defined(RFM95_SPI)
      #define RFM95_SPI hwSPI //!< default SPI
      #endif
      
      posted in Development
      smilvert
      smilvert
    • RE: nRF5 action!

      @omemanti Well it seems to start working now... Hopefully it works πŸ™‚ Havn't restart the gateway in 2 weeks now

      posted in My Project
      smilvert
      smilvert
    • RE: nRF5 action!

      I have recently installed an Ebyte E73 as my gateway with a DHT22. The problem is that I need to restart the gateway every 2 days and I can't figure out why. Can someone help me?

      /**
         The MySensors Arduino library handles the wireless radio link and protocol
         between your home built sensors/actuators and HA controller of choice.
         The sensors forms a self healing radio network with optional repeaters. Each
         repeater and gateway builds a routing tables in EEPROM which keeps track of the
         network topology allowing messages to be routed to nodes.
      
         Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
         Copyright (C) 2013-2017 Sensnology AB
         Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
      
         Documentation: http://www.mysensors.org
         Support Forum: http://forum.mysensors.org
      
         This program is free software; you can redistribute it and/or
         modify it under the terms of the GNU General Public License
         version 2 as published by the Free Software Foundation.
      
       *******************************
      
         REVISION HISTORY
      
      
      */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      #define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <SPI.h>
      #include <MySensors.h>
      #include "DHT.h"
      
      int switch_led = 1;
      #define ledPin 11
      // Set this to the pin you connected the DHT's data pin to
      #define DHT_DATA_PIN 02
      #define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
      
      
      // Set this offset if the sensor has a permanent small offset to the real temperatures.
      // In Celsius degrees (as measured by the device)
      #define SENSOR_TEMP_OFFSET 0
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      static const uint64_t UPDATE_INTERVAL = 600000;
      
      // Force sending an update of the temperature after n sensor reads, so a controller showing the
      // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
      // the value didn't change since;
      // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
      static const uint8_t FORCE_UPDATE_N_READS = 10;
      
      #define CHILD_ID_HUM 1
      #define CHILD_ID_TEMP 0
      
      float lastTemp;
      float lastHum;
      uint8_t nNoUpdatesTemp;
      uint8_t nNoUpdatesHum;
      bool metric = true;
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht(DHT_DATA_PIN, DHTTYPE);
      
      void setup()
      {
          hwPinMode(LED_BUILTIN,OUTPUT_D0H1);
      
          NRF_CLOCK->INTENSET=B11;  //enable interrupts for EVENTS_HFCLKSTARTED and  EVENTS_LFCLKSTARTED
          NRF_CLOCK->TASKS_HFCLKSTART=1;  //start the high frequency crystal oscillator clock
          while (!(NRF_CLOCK->EVENTS_HFCLKSTARTED)) {} //wait until high frequency crystal oscillator clock is up to speed and working
      
          pinMode(PIN_LED1, OUTPUT);
          digitalWrite(PIN_LED1, HIGH);
      
          dht.begin(); // set data pin of DHT sensor
      }
      
      void presentation()
      {
          // Send the sketch version information to the gateway and controller
          sendSketchInfo("Serial Gateway nrf52", "1.0");
          wait(500);
          // Register all sensors to gw (they will be created as child devices)
          present(CHILD_ID_TEMP, S_TEMP);
          present(CHILD_ID_HUM, S_HUM);
      }
      
      void loop()
      {
      
          // Reading temperature or humidity takes about 250 milliseconds!
          // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
          float h = dht.readHumidity();
          // Read temperature as Celsius (the default)
          float t = dht.readTemperature();
          // Read temperature as Fahrenheit (isFahrenheit = true)
          float f = dht.readTemperature(true);
          Serial.print("Test print");
          // Check if any reads failed and exit early (to try again).
          if (isnan(h) || isnan(t) || isnan(f)) {
          //Serial.println("Failed to read from DHT sensor!");
          return;
          } else {
          send(msgHum.set(h, 1));
          send(msgTemp.set(t, 1));
      
          }
      
          wait(UPDATE_INTERVAL);
      }
      
      
      posted in My Project
      smilvert
      smilvert
    • RE: my first nrf5 ... NRF51/NRF52 which is better for MySensors ?

      I have been able to use platformio for my project quite recently and still have some problems that I haven't had time to solve yet.

      My platformio.ini for a NRF51832

      [env:nrf51_dk]
      platform = nordicnrf51
      framework = arduino
      board = rfduino
      upload_protocol = stlink
      board_build.f_cpu = 16000000L
      build_flags = -DNRF51 -DMYBOARDNRF5 -I{build.path}
      

      the only problem for my is that the flags

      -DMYBOARDNRF5 -I{build.path}
      

      dosen't work so the mynrf5board.h/c isn't read => I need to update the
      vim ~/.platformio/packages/framework-arduinonordicnrf5/variants/Generic/variant.h myself.

      posted in Hardware
      smilvert
      smilvert
    • RE: nRF5 action!

      @neverdie Sorry, im a bit confused.

      If im are going to use the BT832 for a battery sensor do I need to connet a 32 khz crystal like you did on the 10+ years wireless PIR Sensor (on just one set of 3 AA's!) project? But you have also written:
      @neverdie said in nRF5 action!:

      @alowhum IIRC, the crystal oscillator is only required by Bluetooth. For everything else, the internal resonator is sufficient.

      How much more current are used if the crystal is not connected?

      Can I use P00/P01 as a data pin instead of using the crystal?

      posted in My Project
      smilvert
      smilvert
    • RE: nRF5 action!

      @neverdie Im guessing that the BT832 dosen't have the 32.768 khz crystal but the inductors?

      The datasheet says

      Standby current consumption is important for battery-powered product. We suggest adding a 32.768 kHz crystal 
      and 2 capacitors as shown in the upper left corner of the evaluation board schematics. The 32MHz main clock 
      won’t be active at idle state to save power.
      
      Two inductors required for DCDC converter are inside BT832 module. You can enable DCDC to lower
      power consumption.
      
      posted in My Project
      smilvert
      smilvert
    • RE: nRF5 action!

      @NeverDie How do I know which nRF52832 board I should use?

      Does the CFsunbird-nRF52832 has the DC/DC inductors?
      Or can I use nRF51822?

      Want a cheap chip, easy to solder (Have a couple of Ebyte e-73 but they take some time to solder 😞 and if I understand correctly, the DC / DC inductors are missing?)

      posted in My Project
      smilvert
      smilvert
    • RE: nRF5 action!

      @monte But you solve your issue with the WT15822 board? Can you please share your sketch?

      Is the range good of the WT15822 board?

      I have started sketching to create a couple of new simple temp / hum sensors (WT15822, si7021 and cr2032) and want to know if I can use WT15822 before I order a pcb πŸ™‚

      posted in My Project
      smilvert
      smilvert
    • RE: GUIDE - NRF5 / NRF51 / NRF52 for beginners

      Hi.

      I have read https://devzone.nordicsemi.com/b/blog/posts/measuring-lithium-battery-voltage-with-nrf51 but which pin is VBG? p0.01 = adc?

      Need to recalclulate the resistance for 2 aaa batteries.

      @alowhum Can you clearify how to read MyBoardNRF5.h? Is PIN_AIN0 = p0.00?

      What is the benift to use hwPinMode instead of using pinMode()?

      posted in Development
      smilvert
      smilvert
    • RE: nRF5 action!

      I have started to test a NRF51822

      and I can upload to it with Arduino IDE but I want to use vim + platformio. And I think i'm quite close πŸ™‚

      When I ran platformio upload --target upload

      GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-14:56)
      Licensed under GNU GPL v2
      For bug reports, read
      http://openocd.org/doc/doxygen/bugs.html
      0x4000
      Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
      adapter speed: 1000 kHz
      Info : Unable to match requested speed 1000 kHz, using 950 kHz
      Info : Unable to match requested speed 1000 kHz, using 950 kHz
      Info : clock speed 950 kHz
      Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
      Info : using stlink api v2
      Info : Target voltage: 3.225841
      Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
      Info : Listening on port 3333 for gdb connections
      target halted due to debug-request, current mode: Thread
      xPSR: 0xc1000000 pc: 0x000021a4 msp: 0x20004000
      ** Programming Started **
      auto erase enabled
      Warn : Unknown device (HWID 0x000000d1)
      Warn : using fast async flash loader. This is currently supported
      Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
      Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg/nrf52.cfg to disable it
      target halted due to breakpoint, current mode: Thread
      xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
      wrote 33792 bytes from file .pioenvs/nrf51_dk/firmware.hex in 1.594509s (20.696 KiB/s)
      ** Programming Finished **
      ** Verify Started **
      target halted due to breakpoint, current mode: Thread
      xPSR: 0x61000000 pc: 0x2000002e msp: 0x20004000
      verified 32960 bytes in 0.236646s (136.015 KiB/s)
      ** Verified OK **
      ** Resetting Target **
      shutdown command invoked
      

      and the output in Arduino IDE looks like:

      Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-09-12:07)
      Licensed under GNU GPL v2
      For bug reports, read
      	http://openocd.org/doc/doxygen/bugs.html
      debug_level: 0
      0x4000
      adapter speed: 1000 kHz
      nrf51.cpu: target state: halted
      target halted due to debug-request, current mode: Thread 
      xPSR: 0xc1000000 pc: 0x0000251c msp: 0x20004000
      ** Programming Started **
      auto erase enabled
      nrf51.cpu: target state: halted
      target halted due to breakpoint, current mode: Thread 
      xPSR: 0x61000000 pc: 0x2000001e msp: 0x20004000
      wrote 31744 bytes from file /tmp/arduino_build_390477/Si7021_TemperatureNode_v007_voltage__version_7_board_.ino.hex in 1.500105s (20.665 KiB/s)
      ** Programming Finished **
      ** Verify Started **
      nrf51.cpu: target state: halted
      target halted due to breakpoint, current mode: Thread 
      xPSR: 0x61000000 pc: 0x2000002e msp: 0x20004000
      verified 31580 bytes in 0.234860s (131.312 KiB/s)
      ** Verified OK **
      ** Resetting Target **
      shutdown command invoked
      

      and my platfromio.ini looks like:

      [env:nrf51_dk]
      platform = nordicnrf51
      framework = arduino
      board = nrf51_dk
      upload_protocol = stlink 
      

      Should I modify the nrf51_dk.cfg or can anyone see whats the problem is?

      posted in My Project
      smilvert
      smilvert
    • RE: πŸ’¬ Water Meter Pulse Sensor

      @flopp Nice. You don't use a green led? I tried that and it seems to work better but then I struggle with the mounting.

      Need to try this again!

      posted in Announcements
      smilvert
      smilvert
    • RE: Protecting a lock switch securely with MySensors and Domoticz

      @sushukka Sry. Didn't read your first post completely 😞

      Btw I have a plan for building a "IOT"-network (runs on a different VLAN and a different ssid) in my house. That wouldn't help you with the WPA2 security but the key will not be shared with others at least. You can also white list all clients on that subnet in Domoticz.

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: Protecting a lock switch securely with MySensors and Domoticz

      @sushukka According to https://www.domoticz.com/wiki/Application_Settings#Local_Networks

      you can setup your domoticz to be used without protection if your nodes uses a internal network (192.168.. etc)

      Local Networks
      The Local Networks setting lets you define the source networks for which Domoticz will not request a login. Wildcards (*) and multiple networks separated by semicolons (;) may be entered.

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: πŸ’¬ Power Meter Pulse Sensor

      @gohan I think it is a little tricky to update domoticz every minute but try update the sql-file, see the domoticz forum
      https://www.domoticz.com/forum/viewtopic.php?t=10183

      posted in Announcements
      smilvert
      smilvert
    • RE: platformio and mysensors for atmega328p on breadboard?

      @n8henrie

      I have installed the mysensors lib from platformio (platformio lib install xx, or something like that)

      And my platformio.ini file look like this:

      [env:pro8MHzatmega328]
      platform = atmelavr
      framework = arduino
      board = pro8MHzatmega328
      

      I think you could remove the build_flags and the lib_ignore

      posted in Troubleshooting
      smilvert
      smilvert
    • RE: How to add a serial device to use in node-red

      I thought that it should be quite easy to use Node-red but I struggle with it and especially the serial port.

      I have created a passive node:

      // Enable debug prints
      #define MY_DEBUG
      #define MY_GATEWAY_SERIAL
      
      // Enable passive mode
      #define MY_PASSIVE_NODE
      #define MY_REPEATER_FEATURE
      
      // Passive mode requires static node ID
      #define MY_NODE_ID 0
      
      // Enable and select radio type attached
      // #define MY_RADIO_NRF24
      //#define MY_RF24_PA_LEVEL RF24_PA_HIGH
      
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <MySensors.h>
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_BINARY 2
      
      // Initialize general message
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgBinary(CHILD_ID_BINARY, V_STATUS);
      int counter = 0;
      float temperature = 0;
      float humidity = 0;
      int binary = 0;
      void setup()
      {
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and controller
        sendSketchInfo("Passive node", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_TEMP, S_TEMP);
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_BINARY, S_BINARY);
      }
      
      void loop()
      {
        // generate some random data
        counter ++;
        if (counter == 20 ){
          temperature = 0;
          humidity = 0;
          counter = 0;
        }
        else
        {
          temperature = 25.0 + random(0,30)/10.0;
          humidity = 55.0 + random(-20,20);
        }
      /*
        if (binary == 0){
          send(msgBinary.set(binary,2));
          binary = 1;
        }else {
          send(msgBinary.set(binary,2));
          binary = 0;
      
        }
      */
        send(msgTemp.set(temperature,2));
        send(msgHum.set(humidity,2));
        wait(1000);
      }
      

      To generate some data and I get the data in to Node-Red and can send the data to Influx/Grafana but the output to a socat serial port is strange. I have tested and I got the best result when I use a baudrate of 9600.

      When I look to the output data in a terminal a lot of messages are missing or has the format of:

      0;1;1;0;0;26.00^J^M0;0;1;0;1;67.00^J^M0;1;1;0;0;27.40^J^M0
      

      Have the most simple flow at the moment:

      ![](image url)0_1510606542661_Screenshot from 2017-11-13 21-54-42.png

      with this properties 0_1510606605539_Screenshot from 2017-11-13 21-56-13.png

      sudo socat PTY,link=/dev/ttyS81,mode=666,group=dialout,raw PTY,link=/dev/ttyUSB026,mode=666,group=dialouraw
      

      How should I configure the serial output?

      posted in Node-RED
      smilvert
      smilvert
    • RE: Why do "passive nodes" need to set their Node ID manually?

      @NeverDie
      that's the idea but it is not 100 % yet but I working on it.

      posted in General Discussion
      smilvert
      smilvert
    • RE: Why do "passive nodes" need to set their Node ID manually?

      @NeverDie

      Well I wanted to filter noise values and I also want to use influx/grafana as a complement to domoticz

      posted in General Discussion
      smilvert
      smilvert
    • RE: Why do "passive nodes" need to set their Node ID manually?

      @NeverDie

      I have started to test node-red (Which dont work yet...) so I have created a dummy sketch for parse the data to domoticz.

      // Enable debug prints
      #define MY_DEBUG
      #define MY_GATEWAY_SERIAL
      
      // Enable passive mode
      #define MY_PASSIVE_NODE
      #define MY_REPEATER_FEATURE
      
      // Passive mode requires static node ID
      #define MY_NODE_ID 0
      
      // Enable and select radio type attached
      // #define MY_RADIO_NRF24
      //#define MY_RF24_PA_LEVEL RF24_PA_HIGH
      
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <MySensors.h>
      
      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define CHILD_ID_BINARY 2
      
      // Initialize general message
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgBinary(CHILD_ID_BINARY, V_STATUS);
      int counter = 0;
      float temperature = 0;
      float humidity = 0;
      int binary = 0;
      void setup()
      {
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and controller
        sendSketchInfo("Passive node", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_TEMP, S_TEMP);
        present(CHILD_ID_HUM, S_HUM);
        present(CHILD_ID_BINARY, S_BINARY);
      }
      
      void loop()
      {
        // generate some random data
        counter ++;
        if (counter == 20 ){
          temperature = 0;
          humidity = 0;
          counter = 0;
        }
        else
        {
          temperature = 25.0 + random(0,30)/10.0;
          humidity = 55.0 + random(-20,20);
        }
      /*
        if (binary == 0){
          send(msgBinary.set(binary,2));
          binary = 1;
        }else {
          send(msgBinary.set(binary,2));
          binary = 0;
      
        }
      */
        send(msgTemp.set(temperature,2));
        send(msgHum.set(humidity,2));
        wait(1000);
      }
      
      posted in General Discussion
      smilvert
      smilvert
    • RE: πŸ’¬ Water Meter Pulse Sensor

      I having problem to place the tcrt5000 on the correct place. Can anyone please show where to put it? Is it over the black (that spins every 0.5 l)?

      I have this type of water meter alt text

      posted in Announcements
      smilvert
      smilvert
    • RE: Wierd temp/Hum

      Ok.

      I thought I could put a filter in domoticz but maybe it's easier to do that in the sensor instead πŸ™‚

      Just realized that I haven't checked NodeMangager source code. Is there any check of Nan value?
      Or do I need to wake up the node a short time before reading DHT?

      posted in Troubleshooting
      smilvert
      smilvert
    • Wierd temp/Hum

      Hi.

      I updated some temp/hum(DHT22) sensors with nodemanager a month ago. And at the same time I removed the LED and the regulator on the Arduino pro mini. But now I have problems with my sensors. It send some strange values to Domoticz, see attached picture. I have the problem on all sensors but the time between the low value is different and it is also not at the same time on two sensors. Can anyone please give me a hint on what to do?

      0_1507288104279_Hall.png

      #include "config.h"
      #include <MySensors.h>
      #include "NodeManager.h"
      
      NodeManager nodeManager;
      
      void before() {
        Serial.begin(MY_BAUD_RATE);
        nodeManager.setSleep(SLEEP,1,MINUTES);
        nodeManager.setBatteryMin(1.8);
        nodeManager.setBatteryMax(2.4);
        nodeManager.setBatteryInternalVcc(true);
        nodeManager.setBatteryPin(A0);
      
        nodeManager.registerSensor(SENSOR_DHT22, 3);
        nodeManager.before();
      }
      
      void presentation() {
        nodeManager.presentation();
      }
      
      void setup() {
        nodeManager.setup();
      }
      
      void loop() {
        nodeManager.loop();
      }
      
      void receive(const MyMessage &message) {
        nodeManager.receive(message);
      }
      
      void receiveTime(unsigned long ts) {
        nodeManager.receiveTime(ts);
      }
      
      posted in Troubleshooting
      smilvert
      smilvert
    • RE: πŸ’¬ In Wall AC/DC Pcb for MySensors

      @sundberg84 Which housing are you using to this project? Can't find the stl-file. Does the 3dBoxWRelay.stl from the smd-project work here as well?

      posted in OpenHardware.io
      smilvert
      smilvert
    • RE: Best IDE to use for MySensors projects

      @Yveaux I just uploaded the first version on github but currently I lacks sensors so I haven't verify the build_script but it seams to work in the console.

      (I should also add a howto when I get time πŸ™‚ )

      posted in Development
      smilvert
      smilvert
    • RE: Best IDE to use for MySensors projects

      @ivankravets Thanks a lot!! πŸ™‚

      Now I think that it works with the latest commit on github->dev-branch.
      I will try it to night and if I got time I will publish my node code/building structure as well.

      Here was my platformio.ini file that I tested with:

      [env:pro8MHzatmega328]
      platform = atmelavr
      framework = arduino
      board = pro8MHzatmega328
      build_flags = -I/(PATH_TO_MYSENSORS_GITHUB)/libraries/MySensors
      lib_ignore = MySensors
      
      
      posted in Development
      smilvert
      smilvert
    • RE: Best IDE to use for MySensors projects

      Interesting discussion!

      Has just started to try to create some nodes, but find it difficult to put up a decent environment.
      When I test platformio who want to have the following structure:

      MyNode
      β”œβ”€β”€ lib
      β”‚ β”œβ”€β”€ DHT -> /my_arduino_libs/DHT
      β”‚ └── MySensor -> /my_arduino_libs/MySensor
      β”œβ”€β”€ platformio.ini (config file That specifies the platform and settings)
      └── src
          └── MyNode.ino
      
      

      Platformio makes it very easy to build on different platforms, but from version 1.6 of mysensors works platformio bad. It can be solved with a lot of #ifdef but is not easy.

      Also tested with (Have steal it from the jenkins-server πŸ™‚ )

      Arduino --verify -v --board Arduino: AVR pro --pref build.f_cpu = 8000000 --pref build.mcu = ATMEGA328P --pref compiler.warning_level = all --pref sketchbook.path = libraries/mysensors MyNode/MyNode.ino
      

      but then it becomes very inflexible. (Has built a small bashscript for this)

      How do you others to keep track of your code and to build in a smooth way with a nice IDE?

      posted in Development
      smilvert
      smilvert