Navigation

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

    Posts made by mrhutchinsonmn

    • RE: Relay device not showing up in HA but does in .json

      @cabat Thank you! Apparently, the MySensors sketch supplied in the Build section is not written to work with HA. I did take a stab at it and pop some code in the loop section, and the sensor now shows up but is not functional. I will have to dig more and determine what should be added to the sketch for it to work.

      Thanks much for the pointer.

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • Relay device not showing up in HA but does in .json

      I have the following relay device that shows up in the .json file of HA, but will not appear on the dashboard as an available device. Guessing it doesn't like something about the sketch, but not sure what that might be.

      Sketch:

      /*
       * 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      #define MY_NODE_ID 100
      #include <MySensors.h>
      
      #define RELAY_PIN 2  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      
      void before()
      {
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);
          // Set relay to last known state (using eeprom storage)
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup()
      {
      
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay", "1.0");
      
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_BINARY);
        }
      }
      
      
      void loop()
      {
      
      }
      
      void receive(const MyMessage &message)
      {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.getType()==V_STATUS) {
          // Change relay state
          digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          saveState(message.getSensor(), message.getBool());
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.getSensor());
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        }
      }
      

      .json file:

      {
          "0": {
              "sensor_id": 0,
              "children": {},
              "type": 18,
              "sketch_name": null,
              "sketch_version": null,
              "battery_level": 0,
              "protocol_version": "2.3.2",
              "heartbeat": 0
          },
          "100": {
              "sensor_id": 100,
              "children": {
                  "1": {
                      "id": 1,
                      "type": 3,
                      "description": "",
                      "values": {}
                  }
              },
              "type": 18,
              "sketch_name": "Relay",
              "sketch_version": "1.0",
              "battery_level": 0,
              "protocol_version": "2.3.2",
              "heartbeat": 0
          }
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • make erring out on raspberry pi 2 b

      I am attempting to set up homeassistant with a mysensors ethernet gateway on the same raspberry pi 2 b. However, make is erring out. Do I need an older mysensors library?

      [SECTION] Detecting target machine.
        [OK] machine detected: SoC=BCM2835, Type=rpi1, CPU=armv7l.
      [SECTION] Detecting SPI driver.
        [OK] SPI driver detected:BCM.
      [SECTION] Gateway configuration.
        [OK] Type: ethernet.
        [OK] Transport: rf24.
        [OK] Signing: Disabled.
        [OK] Encryption: Disabled.
        [OK] CPPFLAGS: -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_RF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_PORT=5003 
        [OK] CXXFLAGS:  -std=c++11
      [SECTION] Detecting init system.
        [OK] Init system detected: systemd.
      [SECTION] Saving configuration.
        [OK] Saved.
      [SECTION] Cleaning previous builds.
        [OK] Finished.
      root@rpi2-20230102:~/MySensors# ^C
      
      
      root@rpi2-20230102:~/MySensors# ^C
      root@rpi2-20230102:~/MySensors# make
      gcc -MT build/hal/architecture/Linux/drivers/core/config.o -MMD -MP -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -DMY_RADIO_RF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -DLINUX_SPI_BCM -DLINUX_ARCH_RASPBERRYPI -DMY_PORT=5003  -Ofast -g -Wall -Wextra  -I. -I./core -I./hal/architecture/Linux/drivers/core -I./hal/architecture/Linux/drivers/BCM -c hal/architecture/Linux/drivers/core/config.c -o build/hal/architecture/Linux/drivers/core/config.o
      In file included from /usr/include/stdio.h:864,
                       from hal/architecture/Linux/drivers/core/config.c:23:
      /usr/include/arm-linux-gnueabihf/bits/stdio.h: In function 'vprintf':
      /usr/include/arm-linux-gnueabihf/bits/stdio.h:40:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
         40 | {
            | ^
      make: *** [Makefile:103: build/hal/architecture/Linux/drivers/core/config.o] Error 1
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Possible to have an external power source for moisture sensors??

      @mfalkvidd I was looking at it through the perspective of my 8 channel relay which needs an external power source to work reliably. Seems 6 moisture sensors will work fine.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Possible to have an external power source for moisture sensors??

      @mrhutchinsonmn Did some more research. It seems it is possible to run all 6 sensors on a single board without a 2nd power source since readings are not taken simultaneously. Is that a correct assertation?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Possible to have an external power source for moisture sensors??

      I want to run 6 analog moisture sensors on a single arduino nano(if possible). I am guessing that may cause erratic behavior from power issues. Is there a way to use an external power source and still provide a connection to the nano, like is done with a jd-vcc pin on my 8 channel relay, so the sensor will work correctly?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Contributions

      Is there a way to contribute to mysensors tutorials, example sketches, etc? In my experience, I have found some tutorials to be limited, vague, or missing information that would be helpful to a novice, such as myself. For example: currently, I am learning RS485 and have a working moisture sensor sketch I would like to contribute that may be helpful to someone else. Is there a corner for such contributions?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      @electrik Yes... that worked!!! Moved node and child id above mysensors.h

      Thank you!!!!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      @rejoe2 In research, some stated it needed to be there if the sensor did not present itself. Followed @electrik advice and it now works. Thank you for your feedback!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      Thank you for the advice!

      I started over, just to be sure I didn't have anymore mix ups, but still have not been able to get the RS485 motion sensor and RS485 gateway to talk.

      Hardware: Arduino Nanos+ RS485 modules.

      Wiring:
      RO = Pin 8 of Arduino
      DI = Pin 9 of Arduino
      A = A on other Nano
      B = B on other Nano
      DI= Pin 9 of Nano
      RO = Pin 8 of Nano
      DE & RE = Pin 2 of Nano
      VCC = External power source
      GND = External power source

      Current Gateway Sketch:

      /**
      * 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.
      *
      *******************************
      *
      * DESCRIPTION
      * The RS485 Gateway prints data received from sensors on the serial link.
      * The gateway accepts input on seral which will be sent out on
      * the RS485 link.
      *
      * Wire connections (OPTIONAL):
      * - Inclusion button should be connected between digital pin 3 and GND
      * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
      *
      * LEDs (OPTIONAL):
      * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or receive crc error
      *
      * If your Arduino board has additional serial ports
      * you can use to connect the RS485 module.
      * Otherwise, the gateway uses AltSoftSerial to handle two serial
      * links on one Arduino. Use the following pins for RS485 link
      *
      *  Board          Transmit  Receive   PWM Unusable
      * -----          --------  -------   ------------
      * Teensy 3.0 & 3.1  21        20         22
      * Teensy 2.0         9        10       (none)
      * Teensy++ 2.0      25         4       26, 27
      * Arduino Uno        9         8         10
      * Arduino Leonardo   5        13       (none)
      * Arduino Mega      46        48       44, 45
      * Wiring-S           5         6          4
      * Sanguino          13        14         12
      *
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 9600
      
      // Enable this if RS485 is connected to a hardware serial port
      //#define MY_RS485_HWSERIAL Serial
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      #define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      //Digital pin used for inclusion mode button
      #define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      #define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      #define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
      #define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
        // Setup locally attached sensors
      }
      
      void presentation()
      {
        // Present locally attached sensors
      }
      
      void loop()
      {
        // Send locally attached sensor data here
      }
      
      

      Current Motion Detector Sketch:

      /*
       * 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * This is an example of sensors using RS485 as transport layer
       *
       * Motion Sensor example using HC-SR501
       * http://www.mysensors.org/build/motion
       *
       * If your Arduino board has additional serial ports
       * you can use to connect the RS485 module.
       * Otherwise, the transport uses AltSoftSerial to handle two serial
       * links on one Arduino. Use the following pins for RS485 link
       *
       *  Board          Transmit  Receive   PWM Unusable
       * -----          --------  -------   ------------
       * Teensy 3.0 & 3.1  21        20         22
       * Teensy 2.0         9        10       (none)
       * Teensy++ 2.0      25         4       26, 27
       * Arduino Uno        9         8         10
       * Arduino Leonardo   5        13       (none)
       * Arduino Mega      46        48       44, 45
       * Wiring-S           5         6          4
       * Sanguino          13        14         12 *
       *
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 9600
      
      // Enable this if RS485 is connected to a hardware serial port
      //#define MY_RS485_HWSERIAL Serial1
      
      #include <MySensors.h>
      
      uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define MY_NODE_ID 12
      #define CHILD_ID 1   // Id of the sensor child
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
        // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
        Serial.println(tripped);
        send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      

      Commented the following out on the gateway, as per other forum users recommendations ( but made no difference)

      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      //Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      

      Serial Monitor info:

      21257 TSM:FAIL:CNT=7
      321259 TSM:FAIL:DIS
      321261 TSF:TDI:TSL
      381263 TSM:FAIL:RE-INIT
      381265 TSM:INIT
      381266 TSM:INIT:TSP OK
      381268 TSM:FPAR
      381287 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      383295 !TSM:FPAR:NO REPLY
      383297 TSM:FPAR
      383315 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      385324 !TSM:FPAR:NO REPLY
      385326 TSM:FPAR
      385344 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      387352 !TSM:FPAR:NO REPLY
      387354 TSM:FPAR
      387373 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      389381 !TSM:FPAR:FAIL
      

      Ideas?

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      @mfalkvidd Ugh!!! Too many versions of the sketch :)... Had to switch between my laptop and pc because of sketch upload issues.... Must have grabbed an old sketch.. I HAD commented hwserial out earlier... Getting communication now but not a valid message, not enough values to unpack errors. I will dig into that tomorrow. Thank you!!!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      @mrhutchinsonmn Might have confused the issue with my reply.. Neither 115200 nor 9600 baud rates resolve the communication issue.

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      @mrhutchinsonmn said in Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY:

      9600

      Good catch.. That was an old version... both are set to 115200 after 9600 did not work

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • Motion Sensor not presenting to RS485 Gateway / TSM:FPAR:NO REPLY

      Hardware: Arduino nano boards+ RS485 devices with separate 5 volt power supply

      I am trying to set up my 1st Rs485 gateway motion sensor on Home Assistant, per the following tutorial:
      https://www.mysensors.org/build/rs485

      The motion sensor is not presenting itself to the gateway, so I did some digging and found this thread on the subject:

      https://forum.mysensors.org/topic/11048/mqtt-ethernet-gateway-with-wired-rs485-network.

      I have things wired up as per this pic provided in the tutorial

      Although I am not using mqtt, everything seemed to be pertinent but I was still unable to get communication between the sensor and gateway.

      Ha logs show the gateway seems to be happy:

      [mysensors] Connected to Serial<id=0x7f2fd0c2f518, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=0, xonxoff=False, rtscts=False, dsrdtr=False)
      2020-10-05 13:17:05 INFO (MainThread) [mysensors] Connected to <_SelectorSocketTransport fd=25 read=idle write=<idle, bufsize=0>>
      p:Gateway startup complete.
      

      However serial monitor for the motion sensor shows the following:

      
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT NODE,CP=RSNNA---,FQ=16,REL=255,VER=2.3.2
      26 TSM:INIT
      28 TSF:WUR:MS=0
      29 TSM:INIT:TSP OK
      31 TSM:FPAR
      33 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2041 !TSM:FPAR:NO REPLY
      2043 TSM:FPAR
      2045 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      4054 !TSM:FPAR:NO REPLY
      4056 TSM:FPAR
      4058 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      6066 !TSM:FPAR:NO REPLY
      6068 TSM:FPAR
      6070 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      8078 !TSM:FPAR:FAIL
      8079 TSM:FAIL:CNT=1
      8081 TSM:FAIL:DIS
      8083 TSF:TDI:TSL
      18085 TSM:FAIL:RE-INIT
      18087 TSM:INIT
      18088 TSM:INIT:TSP OK
      

      Gateway sketch:

      /**
      * 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.
      *
      *******************************
      *
      * DESCRIPTION
      * The RS485 Gateway prints data received from sensors on the serial link.
      * The gateway accepts input on seral which will be sent out on
      * the RS485 link.
      *
      * Wire connections (OPTIONAL):
      * - Inclusion button should be connected between digital pin 3 and GND
      * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
      *
      * LEDs (OPTIONAL):
      * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or receive crc error
      *
      * If your Arduino board has additional serial ports
      * you can use to connect the RS485 module.
      * Otherwise, the gateway uses AltSoftSerial to handle two serial
      * links on one Arduino. Use the following pins for RS485 link
      *
      *  Board          Transmit  Receive   PWM Unusable
      * -----          --------  -------   ------------
      * Teensy 3.0 & 3.1  21        20         22
      * Teensy 2.0         9        10       (none)
      * Teensy++ 2.0      25         4       26, 27
      * Arduino Uno        9         8         10
      * Arduino Leonardo   5        13       (none)
      * Arduino Mega      46        48       44, 45
      * Wiring-S           5         6          4
      * Sanguino          13        14         12
      *
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 115200
      
      // Enable this if RS485 is connected to a hardware serial port
      #define MY_RS485_HWSERIAL Serial
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      
      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      #define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      #define MY_DEFAULT_RX_LED_PIN  5  // Receive led pin
      #define MY_DEFAULT_TX_LED_PIN  6  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
        // Setup locally attached sensors
      }
      
      void presentation()
      {
        // Present locally attached sensors
      }
      
      void loop()
      {
        // Send locally attached sensor data here
      }
      
      

      Motion detector Sketch:

      /*
       * 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * This is an example of sensors using RS485 as transport layer
       *
       * Motion Sensor example using HC-SR501
       * http://www.mysensors.org/build/motion
       *
       * If your Arduino board has additional serial ports
       * you can use to connect the RS485 module.
       * Otherwise, the transport uses AltSoftSerial to handle two serial
       * links on one Arduino. Use the following pins for RS485 link
       *
       *  Board          Transmit  Receive   PWM Unusable
       * -----          --------  -------   ------------
       * Teensy 3.0 & 3.1  21        20         22
       * Teensy 2.0         9        10       (none)
       * Teensy++ 2.0      25         4       26, 27
       * Arduino Uno        9         8         10
       * Arduino Leonardo   5        13       (none)
       * Arduino Mega      46        48       44, 45
       * Wiring-S           5         6          4
       * Sanguino          13        14         12 *
       *
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable RS485 transport layer
      #define MY_RS485
      
      // Define this to enables DE-pin management on defined pin
      #define MY_RS485_DE_PIN 2
      
      // Set RS485 baud rate to use
      #define MY_RS485_BAUD_RATE 115200
      
      // Enable this if RS485 is connected to a hardware serial port
      //#define MY_RS485_HWSERIAL Serial
      
      #include <MySensors.h>
      
      uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define MY_NODE_ID 123
      #define CHILD_ID 1   // Id of the sensor child
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
        // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
        Serial.println(tripped);
        send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      
      
      

      To rule out hardware failure, I followed this tutorial, and all works as expected:
      https://naylampmechatronics.com/blog/37_Comunicación-RS485-con-Arduino.html

      Transmitter sketch:

      const int ledPin =  13;  // Built-in LED
      const int EnTxPin =  2;  // HIGH:Transmitter, LOW:Receiver
      void setup() 
      { 
        Serial.begin(9600);
        Serial.setTimeout(100);  
        pinMode(ledPin, OUTPUT);
        pinMode(EnTxPin, OUTPUT);
        digitalWrite(ledPin, LOW); 
        digitalWrite(EnTxPin, HIGH); 
      } 
       
      void loop() 
      {   
        int rdata = analogRead(0); //data from potentiometer 
        int angle= map(rdata, 0, 1023, 0, 180); 
        
        //transmitter data packet
        Serial.print("I"); //initiate data packet
        Serial.print("S"); //code for servo
        Serial.print(angle); //servo angle data
        Serial.print("F"); //finish data packet
        delay(50); 
      
        //receiver data packet
        Serial.print("I"); //initiate data packet
        Serial.print("L"); //code for sensor
        Serial.print("F"); //finish data packet
        Serial.flush();    
        
        digitalWrite(EnTxPin, LOW); //RS485 as receiver
      
        if(Serial.find("i"))
        {
            int data=Serial.parseInt(); 
            if(Serial.read()=='f') //finish reading
             {
               onLED(data);            
            }
            
        }
        digitalWrite(EnTxPin, HIGH); //RS485 as transmitter
        
      } 
      
      void onLED(int data)
      {
        if(data>500)
           digitalWrite(ledPin, HIGH); 
        else
           digitalWrite(ledPin, LOW); 
      }
      

      Reciever sketch:

      #include <Servo.h>
      Servo myservo; 
      const int EnTxPin = 2;
      void setup () {
        Serial.begin (9600);
        myservo.attach (9); 
        pinMode(EnTxPin, OUTPUT );
        digitalWrite (EnTxPin, LOW );
      }
      
      void loop (){
        if ( Serial.available ()){
          if ( Serial.read () == 'I' ){
            char function = Serial.read ();
            if (function == 'S' ){
              int angle = Serial.parseInt ();
              if ( Serial.read () == 'F' ){
                if (angle <= 180) {
                  myservo.write (angle);
                }
              }
            }
            else if (function == 'L' ){
              if ( Serial.read () == 'F' ){
                int val = analogRead (0);
                digitalWrite (EnTxPin, HIGH ); //enable to transmit
                Serial.print ( "i" ); 
                Serial.print (val); 
                Serial.println ( "f" ); 
                Serial.flush (); 
                digitalWrite (EnTxPin, LOW ); //enable to receive
              }
            }
          }
        }
        delay (10);
      }
      
      

      Any ideas about what might be causing the issue?

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RS485 & 8 Channel Relay

      I am considering moving away from using nrf24l01 for my garden automation system and implementing an RS485 solution instead. However, I am not clear if I can run my 8 channel relay via a single RS485 module as I currently do with nrf24l01, or if each channel needs a single RS485 module. (have not worked with RS485 yet)..

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Help modifying sketch for rf-nano

      That worked for me. Thank you!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Help modifying sketch for rf-nano

      @Michiel-van-der-Wulp

      The sketch looks like this now but does not work with gateway sketch (below). Is that related to code in the mysensors.h library, or do I need to make a change in the serial gateway sketch?

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      #define MY_NODE_ID 35
      // Enable debug prints
       #define MY_DEBUG
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CE_PIN   10
      #define CSN_PIN 9
      #define CHILD_ID_A0 0
      //#define CHILD_ID_A1 1
      //#define CHILD_ID_A2 2
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      //MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      //MyMessage msg3(CHILD_ID_A2, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
       // present(CHILD_ID_A1, S_MOISTURE);
       // present(CHILD_ID_A2, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
       int sensorValue = analogRead(A0);
       //int sensorValueA1 = analogRead(A1);
       //int sensorValueA2 = analogRead(A2);
        // print out the value you read:
        Serial.println(sensorValue);
        // Serial.println(sensorValueA1);
        //Serial.println(sensorValueA2);
        send(msg.set(sensorValue));
        // send(msg2.set(sensorValueA1));
       // send(msg3.set(sensorValueA2));
        delay(10000);        // delay in between reads for stability
      }
      

      Gateway Sketch:

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      #define MY_NODE_ID 35
      // Enable debug prints
       #define MY_DEBUG
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CE_PIN   10
      #define CSN_PIN 9
      #define CHILD_ID_A0 0
      //#define CHILD_ID_A1 1
      //#define CHILD_ID_A2 2
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      //MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      //MyMessage msg3(CHILD_ID_A2, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
       // present(CHILD_ID_A1, S_MOISTURE);
       // present(CHILD_ID_A2, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
       int sensorValue = analogRead(A0);
       //int sensorValueA1 = analogRead(A1);
       //int sensorValueA2 = analogRead(A2);
        // print out the value you read:
        Serial.println(sensorValue);
        // Serial.println(sensorValueA1);
        //Serial.println(sensorValueA2);
        send(msg.set(sensorValue));
        // send(msg2.set(sensorValueA1));
       // send(msg3.set(sensorValueA2));
        delay(10000);        // delay in between reads for stability
      }
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Help modifying sketch for rf-nano

      I have set all my sensors up using a nano and nrf24l01 wireless modules. Just received some rf-nanos I ordered but they are not working with my current sketches. I could use some advice on what to change in my moisture sensor sketch to get it to send data to my gateway. I verified the new rf-nanos work with the following 2 sketches.

      rf-nano send sketch:

      /*
          
         RF Nano Send Example
         
         Hey guys! This example code is designed to send one random 
         integer from one RF Nano to a second RF Nano, to show just how 
         simple the code can be. This code is also compatible with an RF Nano 
         (Arduino Nano with integrated NRF24L01)
      
         - Matt (ACBR 2020)
         
         Pins for Radio
         1 - GND 
         2 - VCC 5v
         3 - CE - Arduino pin 9
         4 - CSN - Arduino pin 10
         5 - SCK - Arduino pin 13
         6 - MOSI - Arduino pin 11
         7 - MISO - Arduino pin 12
         8 - UNUSED
       */
       
      #include <SPI.h>
      #include <nRF24L01.h>
      #include <RF24.h>
      #define CE_PIN   10
      #define CSN_PIN 9
      
      const uint64_t pipe = 0x1; // This is the transmit pipeline
      int sendData[1];  // One element array holding our random number
      
      RF24 radio(CE_PIN, CSN_PIN); // Activate the Radio
      
      void setup()   
      {
        Serial.begin(9600);
        radio.begin();
        radio.openWritingPipe(pipe);
        randomSeed(analogRead(A0));
      }
      
      
      void loop()   
      {
        radio.write( sendData, sizeof(sendData));
        sendData[0] = random(10);
        Serial.println(sendData[0]);
      }
      

      rf-nano receive sketch:

      /* 
        
         RF Nano Receive Example
       
         Hey guys! This example code is designed to send one random integer 
         from one RF Nano to a second RF Nano, to show just how simple the 
         code can be. This code is also compatible with an RF Nano (Arduino 
         Nano with integrated NRF24L01)
      
         - Matt (ACBR 2020)
         
         1 - GND 
         2 - VCC 3.3V 
         3 - CE - Arduino pin 9
         4 - CSN - Arduino pin 10
         5 - SCK - Arduino pin 13
         6 - MOSI - Arduino pin 11
         7 - MISO - Arduino pin 12
         8 - UNUSED 
      */
      
      #include <SPI.h>
      #include <nRF24L01.h>
      #include <RF24.h>
      #define CE_PIN   10
      #define CSN_PIN 9
      
      const uint64_t pipe = 0x1;  // This is the transmit pipe
      int sendData[1];  // One element array holding our random number
      
      RF24 radio(CE_PIN, CSN_PIN);
      
      void setup()  
      {
        Serial.begin(9600); 
        delay(1000);
        Serial.println("Nrf24L01 Receiver Starting");
        radio.begin();
        radio.openReadingPipe(1,pipe);
        radio.startListening();
      }
      
      
      void loop()   
      {
        if ( radio.available() )
        {
          bool done = false;
          while (!done)
          {
            radio.read(sendData, sizeof(sendData));
            Serial.print("Random Number: ");
            Serial.println(sendData[0]);
            delay(50);
          }
        }
        else
        {    
            Serial.println("Darn, not working yet!");
        }
      }
      

      sensor sketch needing modification:

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      #define MY_NODE_ID 35
      // Enable debug prints
       #define MY_DEBUG
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID_A0 0
      //#define CHILD_ID_A1 1
      //#define CHILD_ID_A2 2
      #include <MySensors.h>
      #include #include <RF24.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      //MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      //MyMessage msg3(CHILD_ID_A2, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
       // present(CHILD_ID_A1, S_MOISTURE);
       // present(CHILD_ID_A2, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
       int sensorValue = analogRead(A0);
       //int sensorValueA1 = analogRead(A1);
       //int sensorValueA2 = analogRead(A2);
        // print out the value you read:
        Serial.println(sensorValue);
        // Serial.println(sensorValueA1);
        //Serial.println(sensorValueA2);
        send(msg.set(sensorValue));
        // send(msg2.set(sensorValueA1));
       // send(msg3.set(sensorValueA2));
        delay(10000);        // delay in between reads for stability
      }
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Looking for esp8266 moisture sensor sketch that works with current libraries

      @mfalkvidd was part of the sketch. I could see right away that sleep did not work 🙂

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Looking for esp8266 moisture sensor sketch that works with current libraries

      Fixed it with the following changes: .(Still interested in finding more esp8266 sketches)

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
      #define MY_BAUD_RATE 9600
      
      // Enables and select radio type (non attached at the moment)
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #define MY_GATEWAY_ESP8266
      
      
      #define MY_WIFI_SSID ""
      #define MY_WIFI_PASSWORD ""
      
      // Enable UDP communication
      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
      
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      #define MY_HOSTNAME "test-sensor-gateway"
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,178,87
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // The port to keep open on node server mode
      #define MY_PORT 5003
      
      // How many clients should be able to connect to this gateway (default 1)
      #define MY_GATEWAY_MAX_CLIENTS 2
      
      // Controller ip address. Enables client mode (default is "server" mode).
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
      
      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      //#define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      // Led pins used if blinking feature is enabled above
      //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
      
      #if defined(MY_USE_UDP)
      #include <WiFiUdp.h>
      #endif
      
      #include <ESP8266WiFi.h>
      #include <MySensors.h>
      
      #define CHILD_ID 0
      
      int AirValue = 694;
      int WaterValue = 344;
      int intervals = (AirValue - WaterValue)/3; 
      int soilMoistureValue = 0;
      
      MyMessage msg(CHILD_ID, V_LEVEL);
      unsigned long SLEEP_TIME = 30000;
      int sensorPin = A0;
        
      void setup()
      {
        // Setup locally attached sensors
      }
      
      void presentation()
      {
        // Present locally attached sensors here
        sendSketchInfo("Soil Moisture Sensor Capacitive", "1.0");
        present(CHILD_ID, S_MOISTURE);
      
      }
      
      void loop()
      {
        // Send locally attached sensors data here
        int soilMoistureValue;
        soilMoistureValue = analogRead(sensorPin);
       
      
        if(soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
          {
            send(msg.set(100));
          
          }
          else if(soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
            {
              send(msg.set(50));
           
            }
          else if(soilMoistureValue < AirValue && soilMoistureValue > (AirValue - intervals))
          {
             send(msg.set(0));
              
          
           }
          
      sleep(SLEEP_TIME);
      // note-to-self: search for possible wait() alternative or deep-sleep
      }
      
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Looking for esp8266 moisture sensor sketch that works with current libraries

      I am trying my hand at setting up my first esp8266 gateway with attached moisture sensor but continue to have compilation errors that others have experienced. The fix seemed to be to find the right mysensors libraries but I am not having any luck (tried 2.00-2.32)..

      Would love to work with a sketch that is known to work with 2.3.1-2.3.2

      Errors:

      /root/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:28:22: error: 'MY_ESP8266_SSID' was not declared in this scope
       #define MY_WIFI_SSID MY_ESP8266_SSID
                            ^
      /root/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:163:19: note: in expansion of macro 'MY_WIFI_SSID'
        (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID);
                         ^
      /root/Arduino/libraries/MySensors/core/MyGatewayTransportEthernet.cpp:34:26: error: 'MY_ESP8266_PASSWORD' was not declared in this scope
       #define MY_WIFI_PASSWORD MY_ESP8266_PASSWORD
      

      Sketch:

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
      #define MY_BAUD_RATE 9600
      
      // Enables and select radio type (non attached at the moment)
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #define MY_GATEWAY_ESP8266
      
      #define MY_ESP8266_SSID "****"
      #define MY_ESP8266_PASSWORD "****"
      
      // Enable UDP communication
      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below
      
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      #define MY_ESP8266_HOSTNAME "test-sensor-gateway"
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,178,87
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // The port to keep open on node server mode
      #define MY_PORT 5003
      
      // How many clients should be able to connect to this gateway (default 1)
      #define MY_GATEWAY_MAX_CLIENTS 2
      
      // Controller ip address. Enables client mode (default is "server" mode).
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
      
      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      //#define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      // Led pins used if blinking feature is enabled above
      //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
      
      #if defined(MY_USE_UDP)
      #include <WiFiUdp.h>
      #endif
      
      #include <ESP8266WiFi.h>
      #include <MySensors.h>
      
      #define CHILD_ID 0
      
      int AirValue = 694;
      int WaterValue = 344;
      int intervals = (AirValue - WaterValue)/3; 
      int soilMoistureValue = 0;
      
      MyMessage msg(CHILD_ID, V_LEVEL);
      unsigned long SLEEP_TIME = 30000;
      int sensorPin = A0;
        
      void setup()
      {
        // Setup locally attached sensors
      }
      
      void presentation()
      {
        // Present locally attached sensors here
        sendSketchInfo("Soil Moisture Sensor Capacitive", "1.0");
        present(CHILD_ID, S_MOISTURE);
      
      }
      
      void loop()
      {
        // Send locally attached sensors data here
        int soilMoistureValue;
        soilMoistureValue = analogRead(sensorPin);
       
      
        if(soilMoistureValue > WaterValue && soilMoistureValue < (WaterValue + intervals))
          {
            send(msg.set(100));
          
          }
          else if(soilMoistureValue > (WaterValue + intervals) && soilMoistureValue < (AirValue - intervals))
            {
              send(msg.set(50));
           
            }
          else if(soilMoistureValue < AirValue && soilMoistureValue > (AirValue - intervals))
          {
             send(msg.set(0));
              
          
           }
          
      sleep(SLEEP_TIME);
      // note-to-self: search for possible wait() alternative or deep-sleep
      }
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: [SOLVED] Error compiling ESP8266 Gateway sketch

      Yes, that was it. Thought it was handled under preferences with the url.
      Thank you!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • [SOLVED] Error compiling ESP8266 Gateway sketch

      I am attempting to setup an esp8266 gateway but getting errors in compilation, using the sketch below (arduino ide 1.8.9 and http://arduino.esp8266.com/stable/package_esp8266com_index.json in board manager, with mysensors 2.3.2 library)

      Error:

      d/root/Arduino/libraries/MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp: At global scope:
      /root/Arduino/libraries/MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:140:27: error: expected initializer before 'ets_intr_lock'
       extern "C" void IRAM_ATTR ets_intr_lock()
                                 ^
      Using library MySensors at version 2.3.2 in folder: /root/Arduino/libraries/MySensors 
      Using library SPI at version 1.0 in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/SPI 
      Using library ESP8266WiFi at version 1.0 in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/ESP8266WiFi 
      Using library EEPROM at version 1.0 in folder: /root/.arduino15/packages/esp8266/hardware/esp8266/2.5.0/libraries/EEPROM 
      exit status 1
      Error compiling for board NodeMCU 1.0 (ESP-12E Module).```
      
      
      
      /*
       * 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 - Henrik Ekblad
       * Contribution by a-lurker and Anticimex,
       * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
       * Contribution by Ivo Pullens (ESP8266 support)
       *
       * DESCRIPTION
       * The EthernetGateway 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.
       *
       * VERA CONFIGURATION:
       * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
       * E.g. If you want to use the default values in this sketch enter: 192.168.178.66:5003
       *
       * LED purposes:
       * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch, only the LEDs that is defined is used.
       * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
       * - ERR (red) - fast blink on error during transmission error or receive crc error
       *
       * See https://www.mysensors.org/build/connect_radio for wiring instructions.
       *
       * If you are using a "barebone" ESP8266, see
       * https://www.mysensors.org/build/esp8266_gateway#wiring-for-barebone-esp8266
       *
       * Inclusion mode button:
       * - Connect GPIO5 (=D1) via switch to GND ('inclusion switch')
       *
       * Hardware SHA204 signing is currently not supported!
       *
       * Make sure to fill in your ssid and WiFi password below for ssid & pass.
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
      #define MY_BAUD_RATE 9600
      
      // Enables and select radio type (if attached)
      #define MY_RADIO_RF24
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #define MY_GATEWAY_ESP8266
      
      #define MY_WIFI_SSID "MySSID"
      #define MY_WIFI_PASSWORD "MyVerySecretPassword"
      
      // Enable UDP communication
      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
      
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      #define MY_HOSTNAME "ESP8266_GW"
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,178,87
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // The port to keep open on node server mode
      #define MY_PORT 5003
      
      // How many clients should be able to connect to this gateway (default 1)
      #define MY_GATEWAY_MAX_CLIENTS 2
      
      // Controller ip address. Enables client mode (default is "server" mode).
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
      //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
      
      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN D1
      
      // Set blinking period
      //#define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      // Led pins used if blinking feature is enabled above
      //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
        // Setup locally attached sensors
      }
      
      void presentation()
      {
        // Present locally attached sensors here
      }
      
      void loop()
      {
        // Send locally attached sensors data here
      }
      
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Modifying A0 value to Percentage

      @mfalkvidd In this particular case, the sensor is monitoring the rain barrel of my garden irrigation system and is used to govern whether or not to fire off an automation calling to water a raised bed. The water does have a lot of iron in it, so not sure if that plays a part in what seems to be an unusual reading. I am expecting to see a number around 275-300 when completely immersed in water, but I am getting a reading of around 400+, which is strange to me. I felt using percentages would allow me to customize each sensor sketch for the environment it is being used in.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Modifying A0 value to Percentage

      @rvendrame That is what I was looking for.. Nice!...Thank you

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Modifying A0 value to Percentage

      @alowhum I did ding around with the sketch you shared, which is really well done and full-featured. I get a reading of 50% when the sensor is immersed and 95% when it is dry. What I would like is to see 100% when immersed and near 0% when it is dry. Can the code be changed to meet that need?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Modifying A0 value to Percentage

      @alowhum Thank you.. I may try that code. I have found that when a sensor goes bad it either drops to a "0" reading or "1023". Currently, I use those numbers (below 175 and above 700) to tell Home Assistant to shut off the relay going to that zone, so automations do not keep calling for water.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Modifying A0 value to Percentage

      @rvendrame That worked! I did need to change "float moisture_percentage" to init "moisture_percentage" to get passed the "Call of overloaded function is ambiguous" error. Not sure if that is the correct approach but I was able to compile and upload. Not sure how I missed the send msg but I did. Thanks again!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Modifying A0 value to Percentage

      Hardware: Arduino Nano + Capacitive Moisture Sensor

      I have a nice garden irrigation project I will soon share and want the option to move from analog values to percentages for my capacitive moisture sensor. I tried my hand at it but am not getting percentages to display in HA. Below is my current sketch, followed by what I want to accomplish:

      Sketch I am using:

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      #define MY_NODE_ID 3
      // Enable debug prints
      // #define MY_DEBUG
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID_A0 0
      //#define CHILD_ID_A1 1
      //#define CHILD_ID_A2 2
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      //MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      //MyMessage msg3(CHILD_ID_A2, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
       // present(CHILD_ID_A1, S_MOISTURE);
       // present(CHILD_ID_A2, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
         int sensorValue = analogRead(A0);
         Serial.println(sensorValue);
          send(msg.set(sensorValue));
         delay(10000);
      }
      

      Sketch I would like to use (serial.print portion)

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      #define MY_NODE_ID 3
      // Enable debug prints
      // #define MY_DEBUG
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID_A0 0
      
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
       }
      // the loop routine runs over and over again forever:
      void loop() {
        float moisture_percentage;
        int sensorValue;
        sensorValue = analogRead(A0);
        moisture_percentage = ( 100 - ( (sensorValue/1023.00) * 100 ) );
        Serial.print("Moisture Percentage = ");
        Serial.print(moisture_percentage);
        Serial.print("%\n\n");
        delay(1000);
      }
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: New ethernet gateway errors out on Home Assistant

      Much appreciated!

      This is what I ended up with for a working config:

      automation: !include 'automations.yaml'
      default_config: ~
      group: !include 'groups.yaml'
      scene:  !include 'scenes.yaml'
      script: !include 'scripts.yaml'
      mysensors:
        gateways:
          - device: '/dev/ttyUSB0'
            persistence_file: 'mysensors1.pickle'
          - device: '10.10.1.69'
            persistence_file: 'mysensors2.pickle'
            tcp_port: 5003
        optimistic: false
        persistence: true
        retain: true
        version: '2.3'
      
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: New ethernet gateway errors out on Home Assistant

      Thank you for pointing me in the right direction. I working on figuring that out via the home assistant mysensors gateway doc but getting errors. Will follow-up if I can't figure it out.

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • New ethernet gateway errors out on Home Assistant

      Hardware: Arduino Nano + HR91105A Ethernet shield

      I am taking a stab at setting up a new ethernet gateway via the following sketch (build tutorial). I pick up an IP and can ping but HA displays errors (below the sketch) and does not complete setup (as my wireless only gateway does). Ideas where to look?

      * 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 - Henrik Ekblad
      * Contribution by a-lurker and Anticimex
      * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
      * Contribution by Tomas Hozza <thozza@gmail.com>
      *
      *
      * DESCRIPTION
      * The EthernetGateway sends data received from sensors to the ethernet link.
      * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
      *
      * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
      *
      * LED purposes:
      * - To use the feature, uncomment MY_DEFAULT_xxx_LED_PIN in the sketch below
      * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or receive crc error
      *
      * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
      *
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable gateway ethernet module type
      #define MY_GATEWAY_W5100
      
      // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
      //#define MY_W5100_SPI_EN 4
      
      // Enable Soft SPI for NRF radio (note different radio wiring is required)
      // The W5100 ethernet module seems to have a hard time co-operate with
      // radio on the same spi bus.
      #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
      #define MY_SOFTSPI
      #define MY_SOFT_SPI_SCK_PIN 14
      #define MY_SOFT_SPI_MISO_PIN 16
      #define MY_SOFT_SPI_MOSI_PIN 15
      #endif
      
      // When W5100 is connected we have to move CE/CSN pins for NRF radio
      #ifndef MY_RF24_CE_PIN
      #define MY_RF24_CE_PIN 5
      #endif
      #ifndef MY_RF24_CS_PIN
      #define MY_RF24_CS_PIN 6
      #endif
      
      // Enable UDP communication
      //#define MY_USE_UDP  // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      //#define MY_IP_ADDRESS 192,168,178,66
      
      // If using static ip you can define Gateway and Subnet address as well
      //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
      //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
      
      // Renewal period if using DHCP
      //#define MY_IP_RENEWAL_INTERVAL 60000
      
      // The port to keep open on node server mode / or port to contact in client mode
      #define MY_PORT 5003
      
      // Controller ip address. Enables client mode (default is "server" mode).
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
      //#define MY_CONTROLLER_URL_ADDRESS "my.controller.org"
      
      // The MAC address can be anything you want but should be unique on your network.
      // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
      // Note that most of the Arduino examples use  "DEAD BEEF FEED" for the MAC address.
      #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
      
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  9  // Transmit led pin
      
      #if defined(MY_USE_UDP)
      #include <EthernetUdp.h>
      #endif
      #include <Ethernet.h>
      #include <MySensors.h>
      
      void setup()
      {
         // Setup locally attached sensors
      }
      
      void presentation()
      {
         // Present locally attached sensors here
      }
      
      void loop()
      {
         // Send locally attached sensors data here
      }
      

      Error Logs:

      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 0 MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 4 TSM:INIT
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 5 TSF:WUR:MS=0
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 11 TSM:INIT:TSP OK
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 13 TSM:INIT:GW MODE
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 15 TSM:READY:ID=0,PAR=0,DIS=0
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors.message] Error decoding message from gateway, bad data received: 17 MCO:REG:NOT NEEDED
      2020-07-28 11:22:02 WARNING (MainThread) [mysensors] Not a valid message: not enough values to unpack (expected 5, got 0)
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • Recommended hardware for medical alert

      Last year, I requested input on an alert system for my ailing father. His health degraded rapidly and he passed away before I could develop the project. Unfortunately, my mother is now facing her own health challenges and I want to help her by putting together a system that best suites her needs.

      She currently subscribes to a medical alert service but it does not function as she would prefer. (calls go out to medical personal, by design, and not nearby family members).

      She is mentally sharp but weak, so she is asking if I could put something like this together:

      Press wrist button once (hold for 5-10 seconds) = text message or recorded message sent to my sister.

      Press wrist button a second time (hold for 5-10 seconds)= message another nearby family member.

      Press wrist button a 3rd time(hold for 5-10 seconds) = send pre-constructed message to 911.

      Obviously, the unit she wears must be small and have long battery life (rechargeable).I can do everything via an arduino nano and wireless but that is not practical for wearing and battery size/life, etc...

      I am not familiar with all the hardware options out there. Any ideas of how I can approach this? It is only for her home, where she has wifi.

      Thank you in advance for sharing your ideas and knowledge.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Need help making pin D1 available for 8 relay module

      @mfalkvidd Got it! Had to put on top of sketch to get it to work.. Thank you!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Need help making pin D1 available for 8 relay module

      Will this mess with data sent to my home assistant controller, or only disable serial monitor and usb?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Need help making pin D1 available for 8 relay module

      Ardunio Nano

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Need help making pin D1 available for 8 relay module

      Is there a way to utilize pin D1 for my 8 relay module with this or a modified sketch? I understand from research that the serial commands are getting in the way but I am not sure how to work around this and need pins 8-13 for my radio. (Powering via vin)

      // Override Setting for Manual Node ID to 2
      #define MY_NODE_ID 51
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      
      #define RELAY_1  1          // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 8 // Total number of attached relays: 4
      
      // Opto Relay Module I was using Active Low - Low (0):ON, High (1): OFF
      #define RELAY_ON 0          // GPIO value to write to turn on attached relay
      #define RELAY_OFF 1         // GPIO value to write to turn off attached relay
      
      bool initialValueSent = false;
      
      //Init MyMessage for Each Child ID
      MyMessage msg1(1, V_LIGHT);
      MyMessage msg2(2, V_LIGHT);
      MyMessage msg3(3, V_LIGHT);
      MyMessage msg4(4, V_LIGHT);
      MyMessage msg5(5, V_LIGHT);
      MyMessage msg6(6, V_LIGHT);
      MyMessage msg7(7, V_LIGHT);
      MyMessage msg8(8, V_LIGHT);
      
      void before() { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup() {
        
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Multiple Relay", "1c.0");
      
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_LIGHT);
        }
      }
      
      
      void loop() 
      {
        if (!initialValueSent) {
          Serial.println("Sending initial value");
          send(msg1.set(loadState(1)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg2.set(loadState(2)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg3.set(loadState(3)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg4.set(loadState(4)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
           send(msg5.set(loadState(5)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg6.set(loadState(6)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg7.set(loadState(7)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg8.set(loadState(8)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          Serial.println("Sending initial value: Completed");
          wait(5000);
        }
      }
      
      void receive(const MyMessage &message) {
        Serial.println("=============== Receive Start =======================");
        if (message.isAck()) {
           Serial.println(">>>>> ACK <<<<<");
           Serial.println("This is an ack from gateway");
           Serial.println("<<<<<< ACK >>>>>>");
        }
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
          Serial.println(">>>>> V_LIGHT <<<<<");
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
           // Update relay state to HA
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           switch (message.sensor) {
              case 1:
                Serial.print("Incoming change for sensor 1");
                send(msg1.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 2:
                Serial.print("Incoming change for sensor 2");
                send(msg2.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 3:
                Serial.print("Incoming change for sensor 3");
                send(msg3.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 4:
                Serial.print("Incoming change for sensor 4");
                send(msg4.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 5:
                Serial.print("Incoming change for sensor 5");
                send(msg5.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 6:
                Serial.print("Incoming change for sensor 6");
                send(msg6.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 7:
                Serial.print("Incoming change for sensor 7");
                send(msg7.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 8:
                Serial.print("Incoming change for sensor 8");
                send(msg8.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;                               
              default: 
                Serial.println("Default Case: Receiving Other Sensor Child ID");
              break;
           }
           // Store state in Arduino eeprom
           saveState(message.sensor, message.getBool());
           Serial.print("Saved State for sensor: ");
           Serial.print( message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
           Serial.println("<<<<<< V_LIGHT >>>>>>");
         } 
         Serial.println("=============== Receive END =======================");
      }
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: NRF24L01 antenna needs

      @BearWithBeard if I use the radio you recommend, will it simply replace what I have without any change to sketches and wiring?

      posted in Hardware
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: NRF24L01 antenna needs

      Thank you! I will check your recommendation out and run some field tests.

      posted in Hardware
      mrhutchinsonmn
      mrhutchinsonmn
    • NRF24L01 antenna needs

      I will be assembling my auto-watering garden project soon. My gardens are about 250-300' (90m) from my house and over an embankment that drops about 10', so I don't have actual line of site. I am not sure how the signal waves work, or if this causes me any concern. I am using HiLetgo 2pcs NRF24L01+PA+LNA Wireless Transceiver RF Transceiver Module with SMA Antenna 2.4G 1100m for my HA serial gateway and my sensors are using the standard built in antenna for the NRF24L01 radio. I would like to assemble my sensors prior to the install and want to be sure my sensors and controller have solid connectivity. Does this seem workable, in general, or is it possible I need to have long range antennas on the sensors too?

      posted in Hardware
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: 2nd sensor in sketch not showing up in HA

      @BearWithBeard said in 2nd sensor in sketch not showing up in HA:

      send(msg2.set(sensorValueA1));

      Yes, that was it!! Thank you!!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • 2nd sensor in sketch not showing up in HA

      I am trying to modify my working moisture sensor sketch to present 2 child Ids instead of one. Arduino serial monitor shows the data from both sensors and HA sees it but the 2nd sensor does not show up in unused entities. I am confident I am erring in my sketch somehow but not sure where.

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      
      // Enable debug prints
      // #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID_A0 0
      #define CHILD_ID_A1 1
      #include <MySensors.h>
      MyMessage msg(CHILD_ID_A0, V_LEVEL);
      MyMessage msg2(CHILD_ID_A1, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensor", "1c.0");
        present(CHILD_ID_A0, S_MOISTURE);
        present(CHILD_ID_A1, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        int sensorValueA1 = analogRead(A1);
        // print out the value you read:
        Serial.println(sensorValue);
        Serial.println(sensorValueA1);
        send(msg.set(sensorValue));
        send(msg.set(sensorValueA1));
        delay(10000);        // delay in between reads for stability
      }
      

      HA logs:

      2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 0 already exists in children of node 105, cannot add child
      2020-03-16 15:56:04 WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 105, cannot add child
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Can I run multiple Analog capacitive moisture sensors per nano

      Thanks for the replies. I think I will just go with 3 sensors per raised bed, per nano. That will keep the runs under 10'

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Can I run multiple Analog capacitive moisture sensors per nano

      @mrhutchinsonmn Thank you. Do you think 25' leads to the sensor will skew the readings?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Can I run multiple Analog capacitive moisture sensors per nano

      The capacitive sensor I have has VCC, Gnd, AOut... I am glad to use something else if I can run multiples on one nano

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Can I run multiple Analog capacitive moisture sensors per nano

      Excited to have my square foot garden watering automation almost worked out on paper. I am curious if there is a way to run multiple (3-4) capactive moisture sensors per arduino nano? I will be using HA to control the watering, based on moisture levels of all sensors. If this cannot be done, what sensors should I use that will not degrade?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: [Solved] Getting Arduino IDE error with Relay Actuator sketch

      @tekka I moved the library and reinstalled. The sketch works now. Thank you for pointing me in the right direction!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: [Solved] Getting Arduino IDE error with Relay Actuator sketch

      @tekka Looks up to date to me.

      Screenshot from 2020-03-09 07-44-29.png

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • [Solved] Getting Arduino IDE error with Relay Actuator sketch

      https://www.mysensors.org/build/relay

      I am attempting to use the following sketch for a relay setup but getting the error below:

      /*
       * 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      
      void before()
      {
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);
          // Set relay to last known state (using eeprom storage)
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup()
      {
      
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay", "1.0");
      
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_BINARY);
        }
      }
      
      
      void loop()
      {
      
      }
      
      void receive(const MyMessage &message)
      {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.getType()==V_STATUS) {
          // Change relay state
          digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          saveState(message.getSensor(), message.getBool());
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.getSensor());
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        }
      }
      
      
      wifi-enabled-relay:89:23: error: 'const class MyMessage' has no member named 'getSensor'; did you mean 'setSensor'?
           saveState(message.getSensor(), message.getBool());
                             ^~~~~~~~~
                             setSensor
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Need guidance in creating sketch for Analog Moisture sensor

      Ha!! That worked!
      That is so cool! I am going to be automating watering of my garden based on individual plant needs and can easily do that now!
      Thank you!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • Need guidance in creating sketch for Analog Moisture sensor

      I am taking my 1st stab at creating a sketch to present to HA. I have very little understanding on how to do that and would like assistance correcting my understanding and successfully sending data from my analog moisture sensor to HA. What I have so far does attempt to present itself but HA complains about child ids (no matter what I use. Tried 0,10,20,100). I am certain I have other issues with sending the correct data but my first goal is to get the sensor to present itself and become available to work with in HA.

      [mysensors.sensor] child_id 0 already exists in children of node 105, cannot add child
      
      

      Here is the sketch I am working with, followed by the sketch I am referencing.

      /*
        AnalogReadSerial
      
        Reads an analog input on pin 0, prints the result to the Serial Monitor.
        Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
        Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
      
        This example code is in the public domain.
      
        http://www.arduino.cc/en/Tutorial/AnalogReadSerial
      */
      
      // Enable debug prints
      // #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      #define CHILD_ID 0
      #include <MySensors.h>
      MyMessage msg(CHILD_ID, V_LEVEL);
      // the setup routine runs once when you press reset:
      void setup() {
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
      }
      void presentation()
      {
        sendSketchInfo("Analog Soil Moisture Sensor", "1.0");
        present(CHILD_ID, S_MOISTURE);
      }
      // the loop routine runs over and over again forever:
      void loop() {
        // read the input on analog pin 0:
        int sensorValue = analogRead(A0);
        // print out the value you read:
        Serial.println(sensorValue);
        delay(10000);        // delay in between reads for stability
      }
      
      /*
       * 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Arduino soil moisture based on gypsum sensor/resistive sensor to avoid electric catalyse in soil
       *  Required to interface the sensor: 2 * 4.7kOhm + 2 * 1N4148
       *
       * Gypsum sensor and calibration:
       *  DIY: See http://vanderleevineyard.com/1/category/vinduino/1.html
       *  Built: Davis / Watermark 200SS
       *    http://www.cooking-hacks.com/watermark-soil-moisture-sensor?_bksrc=item2item&_bkloc=product
       *    http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
       *    cb (centibar) http://www.irrometer.com/basics.html
       *      0-10 Saturated Soil. Occurs for a day or two after irrigation
       *      10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
       *      30-60 Usual range to irrigate or water (except heavy clay soils).
       *      60-100 Usual range to irrigate heavy clay soils
       *      100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
       *
       * Connection:
       * D6, D7: alternative powering to avoid sensor degradation
       * A0, A1: alternative resistance measuring
       *
       *  Based on:
       *  "Vinduino" portable soil moisture sensor code V3.00
       *   Date December 31, 2012
       *   Reinier van der Lee and Theodore Kaskalis
       *   www.vanderleevineyard.com
       * Contributor: epierre
       */
      
      // Copyright (C) 2015, Reinier van der Lee
      // www.vanderleevineyard.com
      
      // This program is free software: you can redistribute it and/or modify
      // it under the terms of the GNU General Public License as published by
      // the Free Software Foundation, either version 3 of the License, or
      // any later version.
      
      // This program is distributed in the hope that it will be useful,
      // but WITHOUT ANY WARRANTY; without even the implied warranty of
      // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      // GNU General Public License for more details.
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <math.h>       // Conversion equation from resistance to %
      #include <MySensors.h>
      
      // Setting up format for reading 3 soil sensors
      #define NUM_READS (int)10    // Number of sensor reads for filtering
      #define CHILD_ID 0
      
      MyMessage msg(CHILD_ID, V_LEVEL);
      uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      long buffer[NUM_READS];
      int idx;
      
      /// @brief Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
      typedef struct {
        int moisture; //!< Moisture
        long resistance; //!< Resistance
      } values;
      
      const long knownResistor = 4700;  // Constant value of known resistor in Ohms
      
      int supplyVoltage;                // Measured supply voltage
      int sensorVoltage;                // Measured sensor voltage
      
      values valueOf[NUM_READS];        // Calculated moisture percentages and resistances to be sorted and filtered
      
      int i;                            // Simple index variable
      
      void setup()
      {
        // initialize the digital pins as an output.
        // Pin 6,7 is for sensor 1
        // initialize the digital pin as an output.
        // Pin 6 is sense resistor voltage supply 1
        pinMode(6, OUTPUT);
      
        // initialize the digital pin as an output.
        // Pin 7 is sense resistor voltage supply 2
        pinMode(7, OUTPUT);
      }
      
      void presentation()
      {
        sendSketchInfo("Soil Moisture Sensor Reverse Polarity", "1.0");
        present(CHILD_ID, S_MOISTURE);
      }
      
      void loop()
      {
      
        measure(6,7,1);
        Serial.print ("\t");
        Serial.println (average());
        long read1 = average();
      
        measure(7,6,0);
        Serial.print ("\t");
        Serial.println (average());
        long read2= average();
      
        long sensor1 = (read1 + read2)/2;
      
        Serial.print ("resistance bias =" );
        Serial.println (read1-read2);
        Serial.print ("sensor bias compensated value = ");
        Serial.println (sensor1);
        Serial.println ();
      
        //send back the values
        send(msg.set((int32_t)ceil(sensor1)));
        // delay until next measurement (msec)
        sleep(SLEEP_TIME);
      }
      
      void measure (int phase_b, int phase_a, int analog_input)
      {
        // read sensor, filter, and calculate resistance value
        // Noise filter: median filter
      
        for (i=0; i<NUM_READS; i++) {
      
          // Read 1 pair of voltage values
          digitalWrite(phase_a, HIGH);                 // set the voltage supply on
          delayMicroseconds(25);
          supplyVoltage = analogRead(analog_input);   // read the supply voltage
          delayMicroseconds(25);
          digitalWrite(phase_a, LOW);                  // set the voltage supply off
          delay(1);
      
          digitalWrite(phase_b, HIGH);                 // set the voltage supply on
          delayMicroseconds(25);
          sensorVoltage = analogRead(analog_input);   // read the sensor voltage
          delayMicroseconds(25);
          digitalWrite(phase_b, LOW);                  // set the voltage supply off
      
          // Calculate resistance
          // the 0.5 add-term is used to round to the nearest integer
          // Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
          long resistance = (knownResistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
      
          delay(1);
          addReading(resistance);
          Serial.print (resistance);
          Serial.print ("\t");
        }
      }
      
      
      
      // Averaging algorithm
      void addReading(long resistance)
      {
        buffer[idx] = resistance;
        idx++;
        if (idx >= NUM_READS) {
          idx = 0;
        }
      }
      
      long average()
      {
        long sum = 0;
        for (int cnt = 0; cnt < NUM_READS; cnt++) {
          sum += buffer[cnt];
        }
        return (long)(sum / NUM_READS);
      }
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Need clarification on soil-moisture build

      That is the direction I am going but this is the only tutorial I could find that used the NRF24L01+ radios to send data to Home Assistant. For now, I am just trying to get it to send accurate measurements and move to capacitive sensors as soon as I figure out how to send the data via NRF24L01+

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Need clarification on soil-moisture build

      Now that I have my soil moisture properly presented to HA, I would like to ask for a little clarity on the build itself: https://www.mysensors.org/build/moisture

      Instructions indicate D0 of the shown moisture sensor (which I am using) should be connected to D3 of the arduino board, yet the sketch indicates a person should be using pins D6 and D7 for outputs. It also says A0 and A1 can be used. The moisture sensor only has an A0 and D0 pin. If I follow what seems to be the instruction in the sketch, I connect A0 and D0 of the sensor to D6 and D7 of the arduino but this only gives me very low readings-from 0-2. (never rising above 2) when in moist soil and 0 when removed from the soil. The sketch indicates the following:

       0-10 Saturated Soil. Occurs for a day or two after irrigation
       *      10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
       *      30-60 Usual range to irrigate or water (except heavy clay soils).
       *      60-100 Usual range to irrigate heavy clay soils
       *      100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
       *
      

      My readings seem to be the opposite of what is stated

      If I connect to A0 and A1, instead my readings jump all over the place.

      Would love to hear how others have this working properly and appreciate if the documentation could be updated to reflect a working solution.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: HA: moisture sensor ValueError: could not convert string to float: '2.1.1'

      Yes!! That worked for me!
      Thank you!

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: HA: moisture sensor ValueError: could not convert string to float: '2.1.1'

      That particular error went away with a new HA install 0.103.6. However, I continue to get data type and child unknown errors:

      020-02-26 07:47:33 WARNING (MainThread) [mysensors] Not a valid message: Not valid message sub-type: 35 for dictionary value @ data['sub_type']
      2020-02-26 07:47:34 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-26 07:48:05 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-26 07:48:36 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-26 07:49:07 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-26 07:49:30 WARNING (MainThread) [mysensors] Not a valid message: Not valid message sub-type: 21 for dictionary value @ data['sub_type']
      2020-02-26 07:49:38 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-26 07:50:09 WARNING (MainThread) [mysensors] Child 0 is unknown
      

      Corresponding serial monitor info:

      5235 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:-2
      5244 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      5250 TSF:TDI:TSL
      5252 MCO:SLP:WUP=-1
      5253 TSF:TRI:TSB
      10	0	10	10	0	10	0	0	0	0		4
      0	0	0	0	0	-10	0	0	0	0		-1
      resistance bias =5
      sensor bias compensated value = 1
      
      5307 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:1
      5316 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      5321 TSF:TDI:TSL
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: HA: moisture sensor ValueError: could not convert string to float: '2.1.1'

      Yes, I removed mysensors.json and restarted. I just finished doing a new install of HA in case it was simply a version issue. I have more info now from the logs. What do you make of this output?:```

      2020-02-25 11:45:07 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 105 child 255
      2020-02-25 11:45:07 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,105-105-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
      2020-02-25 11:45:07 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 105 child 255
      2020-02-25 11:45:07 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,105-105-0,s=0,c=0,t=35,pt=0,l=0,sg=0:
      2020-02-25 11:45:07 WARNING (MainThread) [mysensors] Not a valid message: Not valid message sub-type: 35 for dictionary value @ data['sub_type']
      2020-02-25 11:45:07 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,105-105-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
      2020-02-25 11:45:07 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-105-105,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
      2020-02-25 11:45:07 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,105-105-0,s=0,c=1,t=37,pt=4,l=4,sg=0:1
      2020-02-25 11:45:07 WARNING (MainThread) [mysensors] Child 0 is unknown
      2020-02-25 11:45:07 DEBUG (SyncWorker_1) [mysensors.persistence] Saving sensors to persistence file /home/raymond/.homeassistant/mysensors1.pickle
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: HA: moisture sensor ValueError: could not convert string to float: '2.1.1'

      @mrhutchinsonmn I am revisiting this issue, attempting to get a mysensors wifi moisture sensor device working in my Homeassistant install. No one from my sensors or homeassistant was able to assist when I first created this topic. The setup and errors are the same. I am hoping someone has learned what the issue is that is causing the error and preventing the moisture sensor from appearing in the homeassistant gui. I am open to a different approach, if there is a better solution.

      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Mini lightshow project ideas

      Looks like I will need to tone things down a bit because of time limitations and complexities. I will revisit my original concept after the upcoming concert, when I will not be under time restraints.

      I have decided I will use the following lights: WS2812B LED Strip DC 5V Black White PCB Smart Addressable Pixel WS2812 IC 30, controlled wirelessly.

      My plan would be to create a single control unit (rather than a sensor triggered by frequencies) that will send a wireless signal (numeric value 1-30) back to my Homeassistant control box which in-turn will signal each sensor device to execute a corresponding light show event. Homeassistant would be configured to execute code commands similar to what I have below.

      Code
      void startShow(int i) {
        switch(i){
          case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
                  break;
          case 1: colorWipe(strip.Color(0, 43, 0), 50);  // Green
                  break;
          case 2: colorWipe(strip.Color(34, 34, 0), 50);  // Yellow
                  break;
          case 3: colorWipe(strip.Color(43, 0, 0), 50);  // Red
                  break;
          case 4:
                theaterChase(strip.Color(127,   0,   0), 450); // Red
                break;
      

      That all seems doable, correct? Couple questions: I need to run this all by 9 volt (needs to last 2 hr). What would be the best board to use (Still a nano?) ? Is the NRF24L01+ 2.4GHz radio the best wireless solution to use in this case? We will be lighting up 25 violin bows as per the pic
      Pic link

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      Apologies!! I kept getting errors when using that board, so used another. I am on a new worksation and it turns out python was not installed. The error ceased after I installed. The sketch works fine now.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      Those are the ports I am using on my ESP8266 NodeMCU

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      I'm confused. That is from my sketch. Do I add another reference?

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      Isn't that what this is for?

      // Select SDA and SCL pins for I2C communication
      const uint8_t scl = D6;
      const uint8_t sda = D7;

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      Are you speaking of a comment made on the tutorial? I don't see that instruction in the sketch. I did try to change to numerical values for D1 & D2 but the error followed.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      I am starting to ding around with my project, using the following tutorial sketch but getting an error and not finding how to fix it. Is it just a coding error?

      exit status 1
      'D6' was not declared in this scope```

      #include <Wire.h>
      
      // MPU6050 Slave Device Address
      const uint8_t MPU6050SlaveAddress = 0x68;
      
      // Select SDA and SCL pins for I2C communication 
      const uint8_t scl = D6;
      const uint8_t sda = D7;
      
      // sensitivity scale factor respective to full scale setting provided in datasheet 
      const uint16_t AccelScaleFactor = 16384;
      const uint16_t GyroScaleFactor = 131;
      
      // MPU6050 few configuration register addresses
      const uint8_t MPU6050_REGISTER_SMPLRT_DIV   =  0x19;
      const uint8_t MPU6050_REGISTER_USER_CTRL    =  0x6A;
      const uint8_t MPU6050_REGISTER_PWR_MGMT_1   =  0x6B;
      const uint8_t MPU6050_REGISTER_PWR_MGMT_2   =  0x6C;
      const uint8_t MPU6050_REGISTER_CONFIG       =  0x1A;
      const uint8_t MPU6050_REGISTER_GYRO_CONFIG  =  0x1B;
      const uint8_t MPU6050_REGISTER_ACCEL_CONFIG =  0x1C;
      const uint8_t MPU6050_REGISTER_FIFO_EN      =  0x23;
      const uint8_t MPU6050_REGISTER_INT_ENABLE   =  0x38;
      const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H =  0x3B;
      const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET  = 0x68;
      
      int16_t AccelX, AccelY, AccelZ, Temperature, GyroX, GyroY, GyroZ;
      
      void setup() {
        Serial.begin(9600);
        Wire.begin(sda, scl);
        MPU6050_Init();
      }
      
      void loop() {
        double Ax, Ay, Az, T, Gx, Gy, Gz;
        
        Read_RawValue(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H);
        
        //divide each with their sensitivity scale factor
        Ax = (double)AccelX/AccelScaleFactor;
        Ay = (double)AccelY/AccelScaleFactor;
        Az = (double)AccelZ/AccelScaleFactor;
        T = (double)Temperature/340+36.53; //temperature formula
        Gx = (double)GyroX/GyroScaleFactor;
        Gy = (double)GyroY/GyroScaleFactor;
        Gz = (double)GyroZ/GyroScaleFactor;
      
        Serial.print("Ax: "); Serial.print(Ax);
        Serial.print(" Ay: "); Serial.print(Ay);
        Serial.print(" Az: "); Serial.print(Az);
        Serial.print(" T: "); Serial.print(T);
        Serial.print(" Gx: "); Serial.print(Gx);
        Serial.print(" Gy: "); Serial.print(Gy);
        Serial.print(" Gz: "); Serial.println(Gz);
      
        delay(100);
      }
      
      void I2C_Write(uint8_t deviceAddress, uint8_t regAddress, uint8_t data){
        Wire.beginTransmission(deviceAddress);
        Wire.write(regAddress);
        Wire.write(data);
        Wire.endTransmission();
      }
      
      // read all 14 register
      void Read_RawValue(uint8_t deviceAddress, uint8_t regAddress){
        Wire.beginTransmission(deviceAddress);
        Wire.write(regAddress);
        Wire.endTransmission();
        Wire.requestFrom(deviceAddress, (uint8_t)14);
        AccelX = (((int16_t)Wire.read()<<8) | Wire.read());
        AccelY = (((int16_t)Wire.read()<<8) | Wire.read());
        AccelZ = (((int16_t)Wire.read()<<8) | Wire.read());
        Temperature = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroX = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroY = (((int16_t)Wire.read()<<8) | Wire.read());
        GyroZ = (((int16_t)Wire.read()<<8) | Wire.read());
      }
      
      //configure MPU6050
      void MPU6050_Init(){
        delay(150);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00);//set +/-250 degree/second full scale
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00);// set +/- 2g full scale
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00);
        I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00);
      }
      
      
      
      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • Mini lightshow project ideas

      My violin instructor leads a strings group of mostly kids and some adults. They put on an annual concert for the community, which is always well attended. I have been speaking with him about possibly creating a small light show for their next concert and he is very interested in the idea. In the past he has strung small lights on the bows of the instruments (Violins and Cellos), which the audience really enjoyed. I would like to do something a little more advanced and either use sensors on the bows with programmable rgb lights (along the lines of a neopixal led light), that would change colors base on the frequency of the note being played by a single violin, cello, or base. (A=440hz, B=493hz, C=523hz, etc...), or I would like to use the same approach to create an LED fiber, ceiling light show. I would like to make it appear as if the lights are flowing or dancing with the music. In my mind, I imagine using a controller sending out commands to the individual sensors, based on the readings of a single sensor picking up on the note being played.
      of course, there is no budget for this but I do have a HomeAssistant controller box I can use. What other sensor solutions would be required to produce this project? I do know we will want to control the intensity of the lights as well as color.
      Thank you for sharing your ideas!

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      My sensors arrived in the mail the other day. For simplicity, I will be using the following devices:
      ESP8266 microcontroller NodeMCU Lua V3 WiFi with CH340G
      Wit-fancy Arduino GY-521 MPU-6050 Module 3 Axis analog gyro sensors 3 Axis Accelerometer Module

      Since my dad is not very mobile and will always be with my mom when they leave the house, I have the luxury of using their home wifi to send out alert messages and do not need to be concerned about sending alerts when they are away from the house.

      Hope to get started working through things in the next few days.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      @bjacobse In the case of a google box, you would need something throughout the house, as well as in the garage and shop. A unit strapped to his belt that can reach wifi should work well. He does not leave the house without my mom, so she would be aware of his state while they are away from the house.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      At this point, nothing he does is quick, outside of falling. That should help reduce the possibility of false/positives. He also cannot lay flat on his back, so it may be as simple as finding that reading and creating a trigger. Thank you for your find. I am sure I can get that to work.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: What parts would be needed for timer with light panel indicator
      Package: YesUse: SwitchUse: Automated curtainsUse: UniversalUse: Electric DoorUse: TVUse: LightingChannel: 4Wireless Communication: RFBrand Name: QIACHIPFrequency: 433 MHzSupport APP: NoModel Number: KT16+480E*4Working Voltage: DC 3.3~5VEncoding Type: Learning EV1527Application example 1: Mandos a Distancia De Puertas De GarageApplication example 3: Garage Doors Access Control SsystemWorking Temperature: -25~75Use: Automated curtains,Universal,Switch,Electric DoReceiving Sensitivity: -108dBQuiescent Current: <5mAApplication example 2: Electronic Gates Access Control SystemApplication example 4: Electrical Appliances Control```
      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Best sensor for falling alert

      @bjacobse That seems to be the ticket! I will update the project as I learn more and develop a prototype.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: What parts would be needed for timer with light panel indicator

      I like that! before your reply, I found something else that would work. I like it because a nano could power the neopxial and rf receiver, reducing complexity
      https://tinyurl.com/y3tmvpnx

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: What parts would be needed for timer with light panel indicator

      Here is my first prototype of a working solution for a timing light: ( neopixal timing light):https://youtu.be/b3TDGKUS05I

      Thank you for direction @mfalkvidd !

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • Best sensor for falling alert

      My dad is having health issues and frequently falls. A number of times this has occurred without anyone's knowledge. I am going to build a sensor box to clip on his belt that will alert my mom by sms . It will send an email to the sms address of her phone, using their home wifi. I am considering the KY-020 TILT SWITCH but I am concerned about false alarms and wonder if it wouldn't be better to use an ultrasonic sensor that could be triggered by how fast the distance to a fixed object changes?? Ideas?

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: best solution to monitor and log power usage

      I have given my project idea some thought and believe this non-invasive current sensor is what I am looking for: https://tinyurl.com/y4w7nkon. I would like to capture the data from multiple devices in my home and log/graph it on my home assistant controller or something like ubidots or thingspeak. Is there a current project available that can be modified to fit , or a recommended project, elsewhere? The logging/graphing feature is what I am most interested in. I found many other solutions that only display real-time info.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: What parts would be needed for timer with light panel indicator

      @mfalkvidd I have one of these sitting around for another project you posted that I will be making soon (Parking Sensor). This should work with a lens over it: https://tinyurl.com/y6p7e3p9, correct?

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: What parts would be needed for timer with light panel indicator

      I think what I would like is a Light Panel that would be about 7 or 8 cm square. I'm not sure if I would get the clean look that I want with the LEDs you mentioned but maybe you could point me in the right direction so I could consider those also.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • What parts would be needed for timer with light panel indicator

      I want to put together a little project that would be a timer with a light indicator panel (much like a mini LCD screen)
      It will have 4 buttons.
      Button 1 would turn the light panel green, button 2, yellow, button 3, red, button 4 would flash the light panel green, yellow, red.

      What hardware would be needed for this, outside of an arduino nano and momentary push buttons? Not sure what light or screen would be called that would be used.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • best solution to monitor and log power usage

      My wife and I have many conversations about how much power each device in our home consumes. I would like to take the guess work out of it and monitor/log each device plugged into outlets throughout our home, using Home Assistant as the controller. What hardware (and project, if available) would provide the best solution?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: New project theory for Ag feed industry

      @yveaux My only experience with prepaid is it must be updated, monthly, regardless of usage.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: New project theory for Ag feed industry

      A bit off-topic, yet part of the project. I need to associate the GSM module with a phone service. Verizon indicates they can add the device as a second line for their customers-about $20.00 per month. Are there other options available that would not require a monthly charge? I am guessing the GSM will, at most make 3-4 calls, annually.

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • New project theory for Ag feed industry

      I was visiting with a friend in the ag feed industry. He explained a real problem they incur is farmers who fail to monitor feed grain bins and then request special blended feed with zero notice because they are out of feed, which is almost impossible to satisfy in such short notice. In our conversation I concluded the perfect project scenario would include the following for a 3 grain bin solution:

      (This solution is based on nanos communicating with each other without a parent gateway. Not sure if that is possible)

      1. 3 arduino nanos
      2. 3 Ultrasonic Module HC-SR04 Distance Measuring Transducer Sensor
      3. 3 NRF24L01+ 2.4GHz Wireless Transceiver
      4. 1 SIM800L GPRS GSM Breakout Module
      5. 3 Batteries (bins are often in remote locations, without power)
        (add Rasberry Pi and nrf24lo1+2 (running home assistant) if parent gateway is needed)

      In short, when an ultrasonic sensor reports the bin is near empty, a cell phone call is triggered to announce the alert.

      with battery power being used the boards would power up once or twice a day and report the status when grain levels were low.

      Thoughts?

      posted in My Project
      mrhutchinsonmn
      mrhutchinsonmn
    • HA: moisture sensor ValueError: could not convert string to float: '2.1.1'

      I am attempting to incorporate a moisture sensor into HA but getting could not convert to float errors in the logs. The sensor does show up in mysensors.json but not in the gui.

      Home Assistant 0.94.4

      I am using a simple FC-28 moisture sensor: VCC, Gnd, D0 connected to D6 of the UNO and A0 connected to D7.

      SoilMoistSensor Sketch:

      /*
       * 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-2018 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.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Arduino soil moisture based on gypsum sensor/resistive sensor to avoid electric catalyse in soil
       *  Required to interface the sensor: 2 * 4.7kOhm + 2 * 1N4148
       *
       * Gypsum sensor and calibration:
       *	DIY: See http://vanderleevineyard.com/1/category/vinduino/1.html
       *	Built: Davis / Watermark 200SS
       *		http://www.cooking-hacks.com/watermark-soil-moisture-sensor?_bksrc=item2item&_bkloc=product
       *		http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
       *		cb (centibar) http://www.irrometer.com/basics.html
       *			0-10 Saturated Soil. Occurs for a day or two after irrigation
       *			10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
       *			30-60 Usual range to irrigate or water (except heavy clay soils).
       *			60-100 Usual range to irrigate heavy clay soils
       *			100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
       *
       * Connection:
       * D6, D7: alternative powering to avoid sensor degradation
       * A0, A1: alternative resistance measuring
       *
       *  Based on:
       *  "Vinduino" portable soil moisture sensor code V3.00
       *   Date December 31, 2012
       *   Reinier van der Lee and Theodore Kaskalis
       *   www.vanderleevineyard.com
       * Contributor: epierre
       */
      
      // Copyright (C) 2015, Reinier van der Lee
      // www.vanderleevineyard.com
      
      // This program is free software: you can redistribute it and/or modify
      // it under the terms of the GNU General Public License as published by
      // the Free Software Foundation, either version 3 of the License, or
      // any later version.
      
      // This program is distributed in the hope that it will be useful,
      // but WITHOUT ANY WARRANTY; without even the implied warranty of
      // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      // GNU General Public License for more details.
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <math.h>       // Conversion equation from resistance to %
      #include <MySensors.h>
      
      // Setting up format for reading 3 soil sensors
      #define NUM_READS (int)10    // Number of sensor reads for filtering
      #define CHILD_ID 0
      
      MyMessage msg(CHILD_ID, V_LEVEL);
      uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      
      long buffer[NUM_READS];
      int idx;
      
      /// @brief Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
      typedef struct {
      	int moisture; //!< Moisture
      	long resistance; //!< Resistance
      } values;
      
      const long knownResistor = 4700;  // Constant value of known resistor in Ohms
      
      int supplyVoltage;                // Measured supply voltage
      int sensorVoltage;                // Measured sensor voltage
      
      values valueOf[NUM_READS];        // Calculated moisture percentages and resistances to be sorted and filtered
      
      int i;                            // Simple index variable
      
      void setup()
      {
      	// initialize the digital pins as an output.
      	// Pin 6,7 is for sensor 1
      	// initialize the digital pin as an output.
      	// Pin 6 is sense resistor voltage supply 1
      	pinMode(6, OUTPUT);
      
      	// initialize the digital pin as an output.
      	// Pin 7 is sense resistor voltage supply 2
      	pinMode(7, OUTPUT);
      }
      
      void presentation()
      {
      	sendSketchInfo("Soil Moisture Sensor Reverse Polarity", "1.0");
      	present(CHILD_ID, S_MOISTURE);
      }
      
      void loop()
      {
      
      	measure(6,7,1);
      	Serial.print ("\t");
      	Serial.println (average());
      	long read1 = average();
      
      	measure(7,6,0);
      	Serial.print ("\t");
      	Serial.println (average());
      	long read2= average();
      
      	long sensor1 = (read1 + read2)/2;
      
      	Serial.print ("resistance bias =" );
      	Serial.println (read1-read2);
      	Serial.print ("sensor bias compensated value = ");
      	Serial.println (sensor1);
      	Serial.println ();
      
      	//send back the values
      	send(msg.set((int32_t)ceil(sensor1)));
      	// delay until next measurement (msec)
      	sleep(SLEEP_TIME);
      }
      
      
      
      void measure (int phase_b, int phase_a, int analog_input)
      {
      	// read sensor, filter, and calculate resistance value
      	// Noise filter: median filter
      
      	for (i=0; i<NUM_READS; i++) {
      
      		// Read 1 pair of voltage values
      		digitalWrite(phase_a, HIGH);                 // set the voltage supply on
      		delayMicroseconds(25);
      		supplyVoltage = analogRead(analog_input);   // read the supply voltage
      		delayMicroseconds(25);
      		digitalWrite(phase_a, LOW);                  // set the voltage supply off
      		delay(1);
      
      		digitalWrite(phase_b, HIGH);                 // set the voltage supply on
      		delayMicroseconds(25);
      		sensorVoltage = analogRead(analog_input);   // read the sensor voltage
      		delayMicroseconds(25);
      		digitalWrite(phase_b, LOW);                  // set the voltage supply off
      
      		// Calculate resistance
      		// the 0.5 add-term is used to round to the nearest integer
      		// Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
      		long resistance = (knownResistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
      
      		delay(1);
      		addReading(resistance);
      		Serial.print (resistance);
      		Serial.print ("\t");
      	}
      }
      

      Arduino Serial Monitor:

      11679 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:2
      11687 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      11693 TSF:TDI:TSL
      11695 MCO:SLP:WUP=-1
      11697 TSF:TRI:TSB
      34	11	0	-11	0	11	23	23	11	0		10
      -21	-10	10	11	0	-11	-22	-11	-10	11		-5
      resistance bias =15
      sensor bias compensated value = 2
      
      11756 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:2
      11765 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      11770 TSF:TDI:TSL
      11772 MCO:SLP:WUP=-1
      11773 TSF:TRI:TSB
      11	22	23	11	-11	-11	0	11	23	11		9
      -11	-11	-11	0	11	11	0	-11	-22	-11		-5
      resistance bias =14
      sensor bias compensated value = 2
      
      11833 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:2
      11842 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      11847 TSF:TDI:TSL
      11849 MCO:SLP:WUP=-1
      11851 TSF:TRI:TSB
      23	0	0	-11	11	23	23	23	0	-11		8
      -10	0	10	22	0	-22	-22	-10	11	11		-1
      resistance bias =9
      sensor bias compensated value = 3
      
      11911 TSF:MSG:SEND,105-105-0-0,s=0,c=1,t=37,pt=4,l=4,sg=0,ft=0,st=OK:3
      11919 MCO:SLP:MS=30000,SMS=0,I1=255,M1=255,I2=255,M2=255
      11924 TSF:TDI:TSL
      // Averaging algorithm
      void addReading(long resistance)
      {
      	buffer[idx] = resistance;
      	idx++;
      	if (idx >= NUM_READS) {
      		idx = 0;
      	}
      }
      
      long average()
      {
      	long sum = 0;
      	for (int i = 0; i < NUM_READS; i++) {
      		sum += buffer[i];
      	}
      	return (long)(sum / NUM_READS);
      }
      

      Mysensors.json Moisture Sensor:
      "105": {
      "sensor_id": 105,
      "children": {
      "0": {
      "id": 0,
      "type": 35,
      "description": "",
      "values": {
      "37": "3"
      }
      }
      },
      "type": 17,
      "sketch_name": "Soil Moisture Sensor Reve",
      "sketch_version": "1.0",
      "battery_level": 0,
      "protocol_version": "2.3.1",
      "heartbeat": 0
      }

      HA Logs:

      ValueError: could not convert string to float: '2.1.1'
      2019-07-03 12:35:20 DEBUG (SyncWorker_2) [mysensors.persistence] Saving sensors to persistence file /home/homeassistant/.homeassistant/mysensors.json
      2019-07-03 12:35:47 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,105-105-0,s=0,c=1,t=37,pt=4,l=4,sg=0:1
      2019-07-03 12:35:47 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 105 child 0
      2019-07-03 12:35:47 DEBUG (MainThread) [homeassistant.components.mysensors.device] Entity update: Soil Moisture Sensor Reve 105 0: value_type 37, value = 1
      2019-07-03 12:35:47 ERROR (MainThread) [homeassistant.components.mysensors.device] Error updating Soil Moisture Sensor Reve 105 0
      Traceback (most recent call last):
        File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/mysensors/device.py", line 103, in update
          await self._async_update_callback()
        File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/mysensors/device.py", line 129, in _async_update_callback
          await self.async_update_ha_state(True)
        File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 225, in async_update_ha_state
          self._async_write_ha_state()
        File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 258, in _async_write_ha_state
          unit_of_measurement = self.unit_of_measurement
        File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/mysensors/sensor.py", line 75, in unit_of_measurement
          if (float(self.gateway.protocol_version) >= 1.5
      ValueError: could not convert string to float: '2.1.1'
      2019-07-03 12:35:50 DEBUG (SyncWorker_8) [mysensors.persistence] Saving sensors to persistence file /home/homeassistant/.homeassistant/mysensors.json
      
      posted in Home Assistant
      mrhutchinsonmn
      mrhutchinsonmn
    • Is the moisture sensor build doc accurate

      I am attempting to set up a moisture sensor, using the diagram and included sketch (https://www.mysensors.org/build/moisture). The diagram shows pin 3 for data but the sketch references d6 and d7. I don't see any reference to pin 3 there. I am not clear why there are references to d6 and d7 when my sensor only has a single data pin.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      This script will be more helpful for beginners. The previous script turns on/off all relays. This one controls only the specified relay.

      - id: '1562092064918'
        alias: Power Up Relay_2.1
        trigger:
        - entity_id: switch.relay_4_2
          from: 'off'
          platform: state
          to: 'on'
        condition: []
        action:
        - alias: ''
          data:
            entity_id: switch.relay_2_1
          service: switch.turn_on
      - id: '1562093186484'
        alias: Power Down Relay_2.1
        trigger:
        - entity_id: switch.relay_4_2
          from: 'on'
          platform: state
          to: 'off'
        condition: []
        action:
        - data:
            entity_id: switch.relay_2_1
          service: switch.turn_off
      
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      @skywatch What fun!! I figured out how to turn the pump relay on and off, based on the state of the water solenoid relay. This automation.yaml script works :

      - id: '1562092064918'
        alias: Relay UP
        trigger:
        - entity_id: switch.relay_4_2
          from: 'off'
          platform: state
          to: 'on'
        condition:
        - condition: state
          entity_id: switch.relay_4_2
          state: 'on'
        - condition: state
          entity_id: switch.relay_2_1
          state: 'off'
        action:
        - alias: ''
          data: {}
          service: switch.turn_on
      - id: '1562093186484'
        alias: Relay Down
        trigger:
        - entity_id: switch.relay_4_2
          from: 'on'
          platform: state
          to: 'off'
        condition:
        - condition: state
          entity_id: switch.relay_2_1
          state: 'on'
        action:
        - service: switch.turn_off```
      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Relay shows up in mysensors.json but not in gui [homeassistant]

      Version 0.94.4

      Thank you for the recommendation. I learned to look there through trial-and-error but the relay does not show up.

      However, everything works as expected (4 relays show up in Unused Entities) when I use the following sketch:

      Copy to clipboard
      // Override Setting for Manual Node ID to 2
      #define MY_NODE_ID 2
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <SPI.h>
      #include <MySensors.h>
      
      #define RELAY_1  3          // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 4  // Total number of attached relays: 4
      
      // Opto Relay Module I was using Active Low - Low (0):ON, High (1): OFF
      #define RELAY_ON 0          // GPIO value to write to turn on attached relay
      #define RELAY_OFF 1         // GPIO value to write to turn off attached relay
      
      bool initialValueSent = false;
      
      //Init MyMessage for Each Child ID
      MyMessage msg1(1, V_LIGHT);
      MyMessage msg2(2, V_LIGHT);
      MyMessage msg3(3, V_LIGHT);
      MyMessage msg4(4, V_LIGHT);
      
      void before() { 
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);   
          // Set relay to last known state (using eeprom storage) 
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup() {
        
      }
      
      void presentation()  
      {   
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay", "1.0");
      
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_LIGHT);
        }
      }
      
      
      void loop() 
      {
        if (!initialValueSent) {
          Serial.println("Sending initial value");
          send(msg1.set(loadState(1)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg2.set(loadState(2)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg3.set(loadState(3)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          send(msg4.set(loadState(4)?RELAY_OFF:RELAY_ON),true);
          wait(1000);
          Serial.println("Sending initial value: Completed");
          wait(5000);
        }
      }
      
      void receive(const MyMessage &message) {
        Serial.println("=============== Receive Start =======================");
        if (message.isAck()) {
           Serial.println(">>>>> ACK <<<<<");
           Serial.println("This is an ack from gateway");
           Serial.println("<<<<<< ACK >>>>>>");
        }
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_LIGHT) {
          Serial.println(">>>>> V_LIGHT <<<<<");
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
           // Update relay state to HA
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           switch (message.sensor) {
              case 1:
                Serial.print("Incoming change for sensor 1");
                send(msg1.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 2:
                Serial.print("Incoming change for sensor 2");
                send(msg2.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 3:
                Serial.print("Incoming change for sensor 3");
                send(msg3.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;
              case 4:
                Serial.print("Incoming change for sensor 4");
                send(msg4.set(message.getBool()?RELAY_OFF:RELAY_ON));
                break;                    
              default: 
                Serial.println("Default Case: Receiving Other Sensor Child ID");
              break;
           }
           // Store state in Arduino eeprom
           saveState(message.sensor, message.getBool());
           Serial.print("Saved State for sensor: ");
           Serial.print( message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getBool());
           Serial.println("<<<<<< V_LIGHT >>>>>>");
         } 
         Serial.println("=============== Receive END =======================");
      }```
      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • Relay shows up in mysensors.json but not in gui [homeassistant]

      I had multiple sensors on my homeassistant controller, all working fine. I then attempted to attach another relay (RelayAcuator project and sketch). The relay showed up in mysensors.json but not the gui. I eliminated all other sensors and attempted a new sketch upload, with the same results. I ran across other posts on this subject and the common opinion was that an initial value was not sent to Home Assistant. Ideas???

      Sketch:

      /*
       * 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-2018 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Enable repeater functionality for this node
      #define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      #define RELAY_PIN 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      
      void before()
      {
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Then set relay pins in output mode
          pinMode(pin, OUTPUT);
          // Set relay to last known state (using eeprom storage)
          digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
        }
      }
      
      void setup()
      {
      
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Relay", "1.0");
      
        for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
          // Register all sensors to gw (they will be created as child devices)
          present(sensor, S_BINARY);
        }
      }
      
      
      void loop()
      {
      
      }
      
      void receive(const MyMessage &message)
      {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_STATUS) {
          // Change relay state
          digitalWrite(message.sensor-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
          // Store state in eeprom
          saveState(message.sensor, message.getBool());
          // Write some debug info
          Serial.print("Incoming change for sensor:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
        }
      }
      
      

      Home assistant logs:

      2019-07-01 15:26:03 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 255
      2019-07-01 15:26:03 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
      2019-07-01 15:26:03 DEBUG (MainThread) [homeassistant.components.mysensors.gateway] Node update: node 2 child 255
      2019-07-01 15:26:03 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,2-2-0,s=1,c=0,t=3,pt=0,l=0,sg=0:
      2019-07-01 15:26:03 WARNING (MainThread) [mysensors.sensor] child_id 1 already exists in children of node 2, cannot add child
      2019-07-01 15:26:03 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
      2019-07-01 15:26:03 DEBUG (MainThread) [mysensors.handler] n:0 c:255 t:3 s:9 p:TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
      2019-07-01 15:26:13 DEBUG (SyncWorker_1) [mysensors.persistence] Saving sensors to persistence file /home/homeassistant/.homeassistant/mysensors.json```
      
      Mysensors.json
      
      {
          "0": {
              "sensor_id": 0,
              "children": {},
              "type": 18,
              "sketch_name": null,
              "sketch_version": null,
              "battery_level": 0,
              "protocol_version": "2.1.1",
              "heartbeat": 0
          },
          "2": {
              "sensor_id": 2,
              "children": {
                  "1": {
                      "id": 1,
                      "type": 3,
                      "description": "",
                      "values": {}
                  }
              },
              "type": 18,
              "sketch_name": "Relay",
              "sketch_version": "1.0",
              "battery_level": 0,
              "protocol_version": "2.3.1",
              "heartbeat": 0
          }
      
      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      I decided to look at things from the Home Assistant side and found what I was looking for under "automations". This simple script triggers my relay when motion is detected. Obviously, that would be a bad idea for watering a garden but now I understand how to trigger an action based on the state of a sensor.

      - id: '1561653332262'
        alias: New Automation
        trigger:
        - entity_id: binary_sensor.relay_motion_105_0
          platform: state
        condition:
        - condition: state
          entity_id: binary_sensor.relay_motion_105_0
          state: 'on'
        action:
        - service: script.1561137758707
      

      Thank you for your assistance!!

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      I am ready to start dinging around with one sensor state controlling a 2nd sensor, using Home Assistant as the controller but I am not finding what I am looking for. I need the state (on/off) of sensor 1 to signal sensor 2 to turn on/off (turn relays on/off) . I am assuming that will require a script setup on Home Assistant to do this.

      Just need some examples (sketches) and supporting docs. It was mentioned this could be accomplished with the irrigation project build (which I plan on implementing) but for now, I just want a pinout high on relay-1 to trigger a 2nd relay to also go high (via wireless) .

      Maybe this question is for Home Assistant? Not sure.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      I need to trigger the relay on/off (via wireless) that is connected to the power of the pump via an arduino nano.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: Hypothetical Project question

      Very cool! I will dig into things and see if I can figure it out.

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • Hypothetical Project question

      I am using Home Assistant as a controller, with a serial gateway. My garden irrigation project required I place my garden water pump directly off of my rain barrel, a full 100' away from the garden and water manifold that is controlled by my arduino nano and 12v solenoids. Is it possible to connect the pump to a nano, relay & NRF24L01 and trigger it (via wireless) to power up when a solenoid is activated on the mainifold and power off again when the solenoid turns off?

      posted in General Discussion
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: MySensors_Sprinkler:174: error: 'POSITIVE' was not declared in this scope

      Yes, that worked... I downloaded master.zip and replaced the current Liquid Crystal folder with the new one. Restarted IDE and was able to compile and upload the sketch. Thank you!

      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: MySensors_Sprinkler:174: error: 'POSITIVE' was not declared in this scope

      My apologies... I should have mentioned that I am using your sketch from the Irrigation controller project. Nothing has been changed (just copy and paste) (https://www.mysensors.org/build/irrigation). Renamed it for my garden sprinkler project. I am not near my Desktop PC till Monday, so I am not sure where I found the library. Is there a specific library version I should use? Where will I find it? From reviewing other questions on this subject, it seemed you felt everything needed would be found in the mysensors library. Maybe I misunderstood.

      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • MySensors_Sprinkler:174: error: 'POSITIVE' was not declared in this scope

      I have researched this error on the forum but I am not clear how to resolve. From other answers Positive is supposed to be declared. I have the mysensors library installed (2.3.1) and using Arduino IDE 1.8.5

      "/home/raymond/Downloads/arduino-1.8.5/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_PRO -DARDUINO_ARCH_AVR   "-I/home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/cores/arduino" "-I/home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/variants/eightanaloginputs" "-I/home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/Wire/src" "-I/home/raymond/Arduino/libraries/Time-master" "-I/home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SPI/src" "-I/home/raymond/Arduino/libraries/MySensors" "-I/home/raymond/Arduino/libraries/LiquidCrystal/src" "-I/home/raymond/Arduino/libraries/LiquidCrystal_I2C-1.1.2" "/tmp/arduino_build_167561/sketch/MySensors_Sprinkler.ino.cpp" -o "/tmp/arduino_build_167561/sketch/MySensors_Sprinkler.ino.cpp.o"
      MySensors_Sprinkler:174: error: 'POSITIVE' was not declared in this scope
       LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address to 0x27
                                                           ^
      Using library Wire at version 1.0 in folder: /home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/Wire 
      Using library Time-master at version 1.5 in folder: /home/raymond/Arduino/libraries/Time-master 
      Using library SPI at version 1.0 in folder: /home/raymond/Downloads/arduino-1.8.5/hardware/arduino/avr/libraries/SPI 
      Using library MySensors at version 2.3.1 in folder: /home/raymond/Arduino/libraries/MySensors 
      Using library LiquidCrystal at version 1.0.7 in folder: /home/raymond/Arduino/libraries/LiquidCrystal 
      Using library LiquidCrystal_I2C-1.1.2 at version 1.1.2 in folder: /home/raymond/Arduino/libraries/LiquidCrystal_I2C-1.1.2 
      exit status 1
      'POSITIVE' was not declared in this scope```
      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • RE: [SOLVED] NRF24L01 Radio Fails connecting to Gateway

      Thank you for your reply. I did resolve the problem and wanted to share what I did, in hopes of helping other newbies.
      Firstly, I double checked the wiring, compared it to the working gateway and it seemed to be fine but still did not work.

      I ran across this post and it turned out to be ideal for my situation:
      https://forum.arduino.cc/index.php?topic=421081.0

      Got the two radios communicating in a simplistic configuration and once working, uploaded mysensors sketches and the radios continued to work correctly. Maybe dismantling and reconnecting was the fix. Not sure, but things are working now. Thank you for a great resource of information and projects!

      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn
    • [SOLVED] NRF24L01 Radio Fails connecting to Gateway

      I am attempting to set up my first sensor (motion) on Homeassistant but could not see that the gateway was picking up on it, so I enabled debug on Arduino IDE.

      (Both radios are NRF24L01)

      Serial monitor displays the following:

      10040 TSM:FAIL:RE-INIT
      10042 TSM:INIT
      10048 !TSM:INIT:TSP FAIL
      10050 TSM:FAIL:CNT=2
      10052 TSM:FAIL:DIS
      10054 TSF:TDI:TSL

      Serial Monitor on the gateway shows the following:
      0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA---,REL=255,VER=2.3.1
      0;255;3;0;9;5 TSM:INIT
      0;255;3;0;9;7 TSF:WUR:MS=0
      0;255;3;0;9;14 TSM:INIT:TSP OK
      0;255;3;0;9;17 TSM:INIT:GW MODE
      0;255;3;0;9;20 TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;24 MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.3.1
      0;255;3;0;9;28 MCO:BGN:STP
      0;255;3;0;9;34 MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;37 TSM:READY:NWD REQ

      Gateway sketch:

      /**
      * 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-2018 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.
      *
      *******************************
      *
      * DESCRIPTION
      * The ArduinoGateway prints data received from sensors on the serial link.
      * The gateway accepts input on serial which will be sent out on radio network.
      *
      * The GW code is designed for Arduino Nano 328p / 16MHz
      *
      * Wire connections (OPTIONAL):
      * - Inclusion button should be connected between digital pin 3 and GND
      * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
      *
      * LEDs (OPTIONAL):
      * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
      * - RX (green) - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or receive crc error
      *
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level.
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      
      // Inverses behavior of inclusion button (if using external pullup)
      //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
      
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
      	// Setup locally attached sensors
      }
      
      void presentation()
      {
      	// Present locally attached sensors
      }
      
      void loop()
      {
      	// Send locally attached sensor data here
      }
      

      Motion Sensor sketch:

      /*
       * 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-2018 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 - Henrik Ekblad
       *
       * DESCRIPTION
       * Motion Sensor example using HC-SR501
       * http://www.mysensors.org/build/motion
       *
       */
      
      // Enable debug prints
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #include <MySensors.h>
      
      uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define CHILD_ID 1   // Id of the sensor child
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor", "1.0");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
        // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
        Serial.println(tripped);
        send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      
      
      
      posted in Troubleshooting
      mrhutchinsonmn
      mrhutchinsonmn