💬 NodeManager





  • Wow! This seems to make things extremely simple. The documentation is really good but I wish you had a few example sketches to make things even more easy (and help us who can't bother to read all documentation ;D ).


  • Contest Winner

    Thanks for you feedback @Efflon! Good advice to have sample sketches as well, I'll work on it!


  • Contest Winner

    Done! I've updated the documentation with four comprehensive examples including the full sketches


  • Admin

    FYI: Added the NodeManager project under the download/api section on the main site.

    Keep up the good work!


  • Hardware Contributor

    How make not sleep sensor?

    void NodeManager::loop() {
    #if SLEEP_MANAGER == 1
    Only for sleep
    #end
    }

    May be to make wait logic


  • Contest Winner

    @Ivan-Z there should be already something in this direction available. You still need to load the sleep module and set sleep time but you have to set sleep mode like this:

    nodeManager.setSleepMode(WAIT);
    

    And the library will use wait() instead of sleep(). All the rest will stay the same.
    I probably need to double check if there is anythig in the code which will use sleep instead of wait outside loop() so I've opened https://github.com/mysensors/NodeManager/issues/38 for this but you should be ready to go even with the current version.
    Thanks


  • Hardware Contributor

    Please show my sample with DHT22

    Append optimization flag.
    For save battery life, do not send the same values


  • Contest Winner

    @Ivan-Z if you mean an example with DHT22, you need first of all to enable the DHT module in config.h with:

    #define MODULE_DHT 1
    

    Then just register the sensor in before() with:

    nodeManager.registerSensor(SENSOR_DHT22,6);
    

    Where 6 is the pin where the sensor is attached to. NodeManager will then create automatically two child ids, one for temperature and the other for humidity.
    As written in the documentation you need the DHT library from https://github.com/adafruit/DHT-sensor-library (or install it by using the arduino IDE). For some unknown (to me) reasons I had issues in using the library from the mysensors example.

    What do you mean by optimization flag?
    As for avoid sending the same value, this is already available, have a look at setTackLastValue() from the documentation. When set to true, the value will not be send if the same as the previous (default is of course false). I also implemented setForceUpdate(), to force to send an update after the configured number of cycles, as many examples here are using this approach.


  • Contest Winner

    Hi, I've updated the project (including files and documentation) to version 1.4.
    Main changes are:

    • Added support for ML8511 UV intensity sensor
    • Added support for MQ air quality sensor
    • Added ability to manually assign a child id to a sensor
    • Ensured compatibility for non-sleeping nodes
    • Ability to control if waking up from an interrupt counts for a battery level report
    • When power pins are set the sensor is powered on just after
    • Service messages are disabled by default
    • Bug fixes

    Thanks!



  • @openhardware.io Great idea. Can we expect to see support for Sonoff/ESP8266(without SLEEP) in a near future?
    Also, would love to see an example of a custom sensor/HC-SR04 distance sensor, 3-pin implementation.
    Keep up the great work.


  • Contest Winner

    @Straydog said in 💬 NodeManager:

    Great idea. Can we expect to see support for Sonoff/ESP8266(without SLEEP) in a near future?
    Also, would love to see an example of a custom sensor/HC-SR04 distance sensor, 3-pin implementation.
    Keep up the great work.

    Thanks for the advice! I'd be very happy to support any sensor which would be useful for the community! I've opened https://github.com/mysensors/NodeManager/issues/63 and https://github.com/mysensors/NodeManager/issues/62.
    Since I don't have those sensors and delivery is kind of a pain, would you like to give me a hand in testing the code I can put together? If so, please add a comment on git with some sample code and I'll integrate it into NodeManager straight away for your testing.
    Thanks!


  • Admin

    @user2684
    If you send me your paypal email, I'll forward community donations to help you buy a sonoff and HC-SR04 for testing.



  • @user2684 Good work with NodeManager, greatly appreciated by "MySensors noob" like myself! 👍


  • Hardware Contributor

    This version already allows wizard (.php) to generate a sketch


  • Contest Winner

    @Straydog said in 💬 NodeManager:

    Can we expect to see support for Sonoff/ESP8266(without SLEEP) in a near future?

    I spend some time in the forum but still I'm struggling a bit to understand the Sonoff use case to then buy the right piece to test. Is it related to what has been discussed in this thread?
    https://forum.mysensors.org/topic/5858/sonoff-relay-using-mysensors-esp8266-wifi-or-mqtt-gateway
    Thanks!



  • @user2684 I have a sonoff and have posted a few examples here https://www.mysensors.org/build/sonoff, nodeManager would maybe save a few lines of code for the end user but you will have quite a lot to code 😄 I guess if you add esp8266 support, the sonoff is just a relay with a LED and a button which nodeManager already supports.


  • Contest Winner

    @Straydog just to be sure I'm buying the right sensor, I can only see HC-SR04 with 4 pins on aliexpress I guess this is the right sensor but I will use only three of the four pins, is it the case?
    Thanks


  • Contest Winner

    @Efflon said in 💬 NodeManager:

    @user2684 I have a sonoff and have posted a few examples here https://www.mysensors.org/build/sonoff,

    Cool project, I wonder how I've missed it so far! I understand the idea, basically the sonoff runs as a gateway (otherwise would require a radio attached which is not possible/easy) and has a relay type of sensor attached. I think I can make it easily, I'm ordering a sonoff right now so to test the implementation. I need this https://github.com/mysensors/NodeManager/issues/65 first of all and then I can adapt the SENSOR_RELAY which is already available in NodeManager. I'll keep you posted while I will progress.
    Thanks!



  • @user2684 It's the regular HC-SR04, with ECHO & TRIGGER soldered together. I believe you can get them in either 5 or 3.3V
    There are only 3 exposed pins on the SonOff SV, I need the other pins for other sensors.
    Would like to help you test this project, tried to sign up to GIT yesterday but all Usernames came back as in use, will try again.
    Two issues 1) AVR/EEPROM is not found, with PERSIST 0 & board ESP8266. 2) Don't know how to define HC-SR04 as a custom sensor, or can disguise it as another sensor type, with a PulseWidth.

    Great job



  • @user2684 You mean, why use SonOff?!?!
    In my case I want to have sensors I can control over the Internet i.e. SonOff for the garage door opener(RELAY), with a PIR and HC_SR04.
    I also prefer the SonOff/ESP8266 as it has more memory than the Arduino.


  • Contest Winner

    @Straydog said in 💬 NodeManager:

    It's the regular HC-SR04, with ECHO & TRIGGER soldered together.

    Great, so if I order the HC-SR04 with 4 pins I should be ready to go. As for the Sonoff, I'm working on it right now, I need to add a few conditions here and there to have NodeManager running as a gateway but it is not that complicated. I'll let you know when I have something ready to test, can be quicker while I'm waiting my sonoff to be delivered.
    As for the Sonoff use case it took me a while because it was not clear to me why a gateway and not a node but now I can see it clearly. And btw I needed something similar at home so I'll explore it even more 😉



  • Way too cool solution 👯

    I decided to give it a go with my Light/Baro/Hum/Temp node.
    Installed the dependencies from Adafruit, cleared EEPROM, compiled and flashed - no issues 👍

    The node reports the expected sensors to MyController.
    The BH1750 light sensor works like a charm, but I'm not getting anything from the BME280 except from a 0.0°C reading on temperature (which, even though spring is pretty lousy so far is a bit on the low side for my office).

    Output on serial looks like this:

    PWR G=6 V=7
    REG I=1 P=18 P=16 T=37
    REG I=2 P=18 P=6 T=0
    REG I=3 P=18 P=7 T=1
    REG I=4 P=18 P=8 T=4
    NodeManager v1.4
    INT1 M=255
    INT2 M=255
    RADIO OK
    PRES I=200, T=23
    PRES I=201, T=30
    BATT V=3.35 P=94
    SEND D=0 I=201 C=0 T=38 S= I=0 F=3.35
    PRES I=1 T=16
    PRES I=2 T=6
    PRES I=3 T=7
    PRES I=4 T=8
    READY
    
    MY I=1 M=1
    ON P=7
    BH1 I=1 L=2500
    SEND D=0 I=1 C=0 T=37 S= N=2500 F=0.00
    BME I=2 T=0.00
    SEND D=0 I=2 C=0 T=0 S= N=0 F=0.00
    BME I=3 H=69.25
    SEND D=0 I=3 C=0 T=1 S= N=0 F=69.25
    BME I=4 P=0.00
    SEND D=0 I=4 C=0 T=4 S= N=0 F=0.00
    OFF P=7
    SLEEP 300s
    
    AWAKE
    ON P=7
    BH@PWR G=6 V=7
    REG I=1 P=18 P=16 T=37
    REG I=2 P=18 P=6 T=0
    REG I=3 P=18 P=7 T=1
    REG I=4 P=18 P=8 T=4
    NodeManager v1.4
    INT1 M=255
    INT2 M=255
    RADIO OK
    PRES I=200, T=23
    PRES I=201, T=30
    BATT V=3.35 P=94
    SEND D=0 I=201 C=0 T=38 S= I=0 F=3.35
    PRES I=1 T=16
    PRES I=2 T=6
    PRES I=3 T=7
    PRES I=4 T=8
    READY
    
    MY I=1 M=1
    ON P=7
    BH1 I=1 L=9951
    SEND D=0 I=1 C=0 T=37 S= N=9951 F=0.00
    BME I=2 T=0.00
    SEND D=0 I=2 C=0 T=0 S= N=0 F=0.00
    BME I=3 H=69.25
    SEND D=0 I=3 C=0 T=1 S= N=0 F=69.25
    BME I=4 P=0.00
    SEND D=0 I=4 C=0 T=4 S= N=0 F=0.00
    OFF P=7
    SLEEP 300s
    

    The node was running fine for months using the same BH1750 library, but the BME280 library by Tyler Glenn.

    Any ideas?

    Should notice that I'm using this kind of BME280 from Ali


  • Contest Winner

    @ksga I can see from the logs the light sensor correctly returning something but the BME280 apparently only able to get the humidity. I also see the node rebooting itself at a certain point. Was it you resetting it? Because if it was not you, it may be due to the memory almost full and when this happens, the behaviors I've seen are really unpredictable including weird numbers reported. To start with, I'd recommend to disable NodeManager's debug which will save some memory and see on the controller if the data returned is correct. If it is still not correct, do you set any specific i2c channel in the other sketch where both the sensors are working fine? I wonder if there is any difference between the two sketches.
    Also, are the sensors powered by pin 6 and 7? If so I'd power them directly just to take away this variable at least for now.
    Thanks!



  • @user2684 Yeah.. missed that it rebooted... Thanks.

    I cleared EEPROM again, recompiled with and without debug (no usable result without, so decided to add eyes again 🙂 )

    void before() part of the sketch looks like this:

    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);  
      /*
       * Register below your sensors
      */
      nodeManager.setSleep(SLEEP,1,MINUTES);
      nodeManager.registerSensor(SENSOR_BH1750);
      nodeManager.registerSensor(SENSOR_BME280);
      /*
       * Register above your sensors
      */
      nodeManager.before();
    }
    

    and config.h:

    /***********************************
     * NodeManager configuration
     */
    
    // if enabled, enable debug messages on serial port
    #define DEBUG 1
    //#define DEBUG 0
    
    // if enabled, will load the sleep manager library. Sleep mode and sleep interval have to be configured to make the board sleeping/waiting
    #define SLEEP_MANAGER 1
    // if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
    #define POWER_MANAGER 0
    // if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
    #define BATTERY_MANAGER 0
    // if enabled, allow modifying the configuration remotely by interacting with the configuration child id
    #define REMOTE_CONFIGURATION 1
    // if enabled, persist the remote configuration settings on EEPROM
    #define PERSIST 0
    
    // if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
    #define SERVICE_MESSAGES 0
    // if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
    #define BATTERY_SENSOR 0
    
    // Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_MQ, SENSOR_ML8511
    #define MODULE_ANALOG_INPUT 1
    // Enable this module to use one of the following sensors: SENSOR_DIGITAL_INPUT
    #define MODULE_DIGITAL_INPUT 1
    // Enable this module to use one of the following sensors: SENSOR_DIGITAL_OUTPUT, SENSOR_RELAY, SENSOR_LATCHING_RELAY
    #define MODULE_DIGITAL_OUTPUT 1
    // Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22
    #define MODULE_DHT 0
    // Enable this module to use one of the following sensors: SENSOR_SHT21
    #define MODULE_SHT21 0
    // Enable this module to use one of the following sensors: SENSOR_SWITCH, SENSOR_DOOR, SENSOR_MOTION
    #define MODULE_SWITCH 0
    // Enable this module to use one of the following sensors: SENSOR_DS18B20
    #define MODULE_DS18B20 0
    // Enable this module to use one of the following sensors: SENSOR_BH1750
    #define MODULE_BH1750 1
    // Enable this module to use one of the following sensors: SENSOR_MLX90614
    #define MODULE_MLX90614 0
    // Enable this module to use one of the following sensors: SENSOR_BME280
    #define MODULE_BME280 1
    
    #endif
    

    The serial output seems to show no reboot this time ;):

    REG I=1 P=18 P=16 T=37
    REG I=2 P=18 P=6 T=0
    REG I=3 P=18 P=7 T=1
    REG I=4 P=18 P=8 T=4
    NodeManager v1.4
    INT1 M=255
    INT2 M=255
    RADIO OK
    PRES I=200, T=23
    PRES I=1 T=16
    PRES I=2 T=6
    PRES I=3 T=7
    PRES I=4 T=8
    READY
    
    MY I=3 M=1
    BH1 I=1 L=-10924
    BME I=2 T=0.00
    SEND D=0 I=2 C=0 T=0 S= N=0 F=0.00
    BME I=3 H=0.00
    SEND D=0 I=3 C=0 T=1 S= N=0 F=0.00
    BME I=4 P=-793.67
    SLEEP 60s
    
    AWAKE
    BH1 I=1 L=-10924
    BME I=2 T=0.00
    SEND D=0 I=2 C=1 T=0 S= N=0 F=0.00
    BME I=3 H=0.00
    SEND D=0 I=3 C=1 T=1 S= N=0 F=0.00
    BME I=4 P=-793.67
    SLEEP 60s
    

    I would guess there should be enough memory on the arduino:

    Sketch uses 26.024 bytes (80%) of program storage space. Maximum is 32.256 bytes.
    Global variables use 1.262 bytes (61%) of dynamic memory, leaving 786 bytes for local variables. Maximum is 2.048 bytes.
    

    Definately not fixed 😞
    Maybe I could try adding support for the alternative BME library to NodeManager...


  • Contest Winner

    @ksga thanks for running this additional test! I don't like that -10924 for the BH1750 which looks to me like a random value and not impacted by the BME280 library you are using if I've understood correctly. This makes me still think of a memory issue: despite the sketch is not consuming all the memory, both the BME280 and BH1750 objects are allocated dynamically in the code so would not count against that percentage I'm afraid.
    Let's start by disabling MODULE_ANALOG_INPUT, MODULE_DIGITAL_INPUT and MODULE_DIGITAL_OUTPUT to save some more memory. Then I'd still try disabling NodeManager's debug: the serial output would be blank of course but on the controller you should see if the the measures reported will look better. I just want to be sure it is not a memory issue (which typically shows up as random reboots and random values) before moving ahead and troubleshoot the library you are using.
    Thanks!



  • @user2684 Sorry about the delay - but life claimed some time (stupid life claiming time I want to use for stuff 😐 )

    Disabled MODULE_ANALOG_INPUT, MODULE_DIGITAL_INPUT and MODULE_DIGITAL_OUTPUT, and even tried without BH1750 - but still no luck.
    Node registers correctly and fires bogus data on one or two sensors...

    Pretty sure I have to use the other library - tried using Adafruit's examples, and it claims no BME is attached...

    I can make all the logic changes to NodeManager, but have not been able to initialize the sensor - maybe I could upload my edits to Git and someone could help me get the last bits together ???

    Made the changes here.


  • Hardware Contributor

    Double comment in NodeMamaged.h - setBatteryInternalVcc


  • Hardware Contributor

    Please use IFDEF for "Battery procetage"
    I calculate this in the controller (Save battery)


  • Contest Winner

    @ksga said in 💬 NodeManager:

    Pretty sure I have to use the other library - tried using Adafruit's examples, and it claims no BME is attached...

    Thanks for digging into it! I just want to be sure with the Adafruit library I'm using you can get the sensor working before evaluating and integrating the other library. As far as I remember during my tests I got a similar issue and if I'm not wrong this is because the chinese version of the BME sensor is on the 0x76 address instead of the 0x77 Adafruit's. Try if you don't mind with the plain Adafruit example and passing the address to begin() to see if you get better results. Thanks!


  • Contest Winner

    @Ivan-Z said in 💬 NodeManager:

    Please use IFDEF for "Battery procetage"

    Do you mean the formula to calculate the percentage? If so, the issue is that the min and max can be defined in the code by the user so I cannot use the preprocessor to do the job. Am I wrong? Regarding the double comment of setBatteryInternalVcc(), I cannot find it, may you please point me out to the affected line numbers? Thanks!


  • Hardware Contributor

    @user2684
    Function name alt text

    Do you mean the formula to calculate the percentage?
    Append flag IFDEF for not send this information (Only voltage)


  • Hardware Contributor

    Sorry, not fully read text


  • Hardware Contributor

    What about BMP085 ??


  • Contest Winner

    @Ivan-Z oh I see about the comment but they are correct because both setBatteryPin() and setBatteryVoltsPerBit() applies only if setBatteryInternalVcc() is set to false.
    Regarding the ifdef thing, the behavior right now is to send percentage by default with sendBatteryLevel() and optionally the battery voltage through the custom service. I'd prefer to keep it in this way since sendBatteryLevel() is the part of the core MySensors api, I'd rather make it mandatory. Thanks!


  • Contest Winner

    @Ivan-Z said in 💬 NodeManager:

    What about BMP085 ??

    I've ordered one and waiting for its delivery 🙂


  • Hardware Contributor

    Why did you use the REQ type for the relay?
    Please add support for SET too

    REQ - nide to read Relay status



  • It's already requested feature:

    https://github.com/mysensors/NodeManager/issues/73

    and it will be done.



  • very clean coding.. i like it.
    Well done. 🆒


  • Contest Winner

    Hello, I think I was able to implement most of the requests discussed here during the last few weeks in a pre-release v1.5 version. Please consider it still as a dev release which gone through very limited testing but since I had to make quite a few changes to core code, would be great to start collecting some feedback now.

    Is is available here: https://github.com/mysensors/NodeManager/tree/9a485cdcaf8e9856219338553335e2dce7253eb3

    It is complicated to reference each of you who requested something so please whoever is interested the full list of new additions/fixes is available here https://github.com/mysensors/NodeManager/milestone/5?closed=1. I did my best to add verbose comments so you should find all the details there. Please add any comment and report any problem directly to the existing issues on github so I can better understand the context. The documentation has been updated as well.
    Thanks



  • @user2684
    Tried again with adafruits library and got it working changing the address.
    But still can't get any useful data from it using NodeManager.

    Did a bit of copy/paste and got this code working (with adafruit and the alternative library):

    #define MY_RADIO_NRF24
    
    #include <MySensors.h>
    #include <SPI.h>
    #include <BH1750.h>
    #include <Wire.h>
    #include <BME280I2C.h>
    
    #define BARO_CHILD 0
    #define TEMP_CHILD 1
    #define HUM_CHILD 2
    #define CHILD_ID_LIGHT 3
    
    #define R1 687000
    #define R2 222000
    #define VMIN 3.30
    #define VMAX 4.18
    #define ADC_PRECISION 1023
    #define VREF 1.107
    
    unsigned long SLEEP_TIME = 300000;
    const float ALTITUDE = 10;
    
    BME280I2C bme;
    BH1750 lightSensor;
    
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    MyMessage tempMsg(TEMP_CHILD, V_TEMP);
    MyMessage humMsg(HUM_CHILD, V_HUM);
    MyMessage lightMsg(CHILD_ID_LIGHT, V_LEVEL);
    
    float lastbaro = -1;
    float lasttemp = -1;
    float lasthum = -1;
    float lastlux = -1;
    float oldBatteryPcnt = -1;
    int BATTERY_SENSE_PIN = A0;
    
    void setup()
    {
      lightSensor.begin();
      bme.begin();
      analogReference(INTERNAL);
      pinMode(BATTERY_SENSE_PIN, INPUT);
      delay(100);
    }
    
    void presentation()
    {
      sendSketchInfo("BME280_BH1750", "1.1");
      present(BARO_CHILD, S_BARO);
      present(TEMP_CHILD, S_TEMP);
      present(HUM_CHILD, S_HUM);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }
    
    void loop()
    {
      float baro_local = bme.pres() / 100.0;
      float baro = ( baro_local / pow((1.0 - ( ALTITUDE / 44330.0 )), 5.255));
      if (baro != lastbaro) {
          send(pressureMsg.set(baro,2));
          lastbaro = baro;
      }
      
      float temp = bme.temp();
      if (temp != lasttemp) {
          send(tempMsg.set(temp,1));
          lasttemp = temp;
      }
      
      float hum = bme.hum();
      if (hum != lasthum) {
          send(humMsg.set(hum,1));
          lasthum = hum;
      }
      
      float lux = lightSensor.readLightLevel();
      if (lux != lastlux) {
          send(lightMsg.set(lux,0));
          lastlux = lux;
      }
      float batteryPcnt = getBatteryPercentage();
      if (oldBatteryPcnt != batteryPcnt) {
      // Power up radio after sleep
      sendBatteryLevel(batteryPcnt);
      oldBatteryPcnt = batteryPcnt;
      }
      
      sleep(SLEEP_TIME);
      
    }
    
    float getBatteryPercentage()
    {
    delay(500);
    
    int inputValue = analogRead(BATTERY_SENSE_PIN);
    float voltageDividerFactor = (R1 + R2) / R2;
    float maxValue = voltageDividerFactor * VREF;
    float voltsPerBit = maxValue / ADC_PRECISION;
    float batteryVoltage = voltsPerBit * inputValue;
    float batteryPercentage = ((batteryVoltage-VMIN)/(VMAX-VMIN))*100;
    
    return batteryPercentage;
    }
    

  • Contest Winner

    @ksga I have no problem in adding this other alternative library in NodeManager but it is really strange it is working for you with the adafruit library but not in NodeManager which is using the same library 😕 Did you set the same address in NodeManager's as well? Can you share the sketch you got it working with the Adafruit library so I can compare the code and see what I do differently in NodeManager preventing it to work for you? Thanks!



  • I have a BMP280 sensor (as far as i know, they are quite similar). At first it seemed like the sensor was not detected. After inspecting the datasheet, i found out that the address could be selected (one of 2 possibilities).
    Here's the text from the datasheet:

    Connecting SDO to GND results in slave
    address 1110110 (0x76); connection it to VDDIO results in slave address 1110111 (0x77)

    Some people change the library code, but (like in my case), i only needed to connect the SDO pin to +3.3V.

    At first i did not connect the SDO pin at all, and my sensor was not reporting at all. That was because of this:

    The SDO pin cannot be left floating; if left floating, the
    I²C address will be undefined.

    Perhaps those issues can be the cause of your problems ksga?


  • Contest Winner

    @core_c this is what I was thinking of as well. Right now in NodeManager the only way to change the i2c address is to change the core code under registerSensor() in NodeManager.cpp which is not handy. I need to find out how to provide an easy way to set it. The problem is registerSensor() takes a fixed number of parameters (and I want it to stay in this way) and it is responsible to create the bmp/bme object, passing it to the 2-3 child sensors. I can provide a setAddress() function but the user needs just after to retrieve each sensor (temperature, humidity, pressure, etc.) and set it manually which is not not great.
    I've opened https://github.com/mysensors/NodeManager/issues/85 for this which is needed regardless. Thanks


  • Contest Winner

    @core_c found a great way to to let NodeManager identifying automatically which i2c address the sensor is using without the need for the user to change anything in the code. This is done by requesting the chip_id for the two i2c address and comparing it with the expected one to identify the right address. I've implemented it for both the BME280 and BMP085/BMP180 sensors and it is available in 1.5-dev3 (https://github.com/mysensors/NodeManager/tree/702a05c7e2f4425c188d5abf62b4a119fea29bc8). Also, under the hood, I've created a SensorBosch class which is not exposed but helps providing common functionalities to the two sensors without duplicating the code.

    Finally, specifically for your problem @ksga, I found a critical bug in the BME280 class. I wonder how I've missed it so far. For some unknown reasons, the bme object created by registerSensor and passed to the SensorBME280 class, was not stored by the latter. This means it was calling e.g. readTemperature on a null pointer which I even wonder why was not crashing everything. It has been fixed in 1.5-dev3 so if you would like to give it a try, I'm more confident it will work just fine finally 🙂


  • Contest Winner

    Do you think would make any sense to add NodeManager among the Arduino's examples? So that from the IDE one can select Examples, MySensors and NodeManager would show up like MotionSensor and the others. However I'd expect new versions of NM to be released more frequently than updates to the core code so it might happen an outdated version to be available there...


  • Contest Winner

    I've added a rain gauge out-out-the-box sensor for the latest dev release called 1.5-dev5 (https://github.com/mysensors/NodeManager/tree/126812a9d01311640416222be8225fdcca1e7266). This is intended to be the last enhancement for the upcoming v1.5 version but of course I'll wait for some additional days to collect (and fix) any issue all the new sensors might have.

    The implementation of the rain gauge sensor has to be different than the one from the build section for a good number of reasons and limitations. All the details here: https://github.com/mysensors/NodeManager/issues/90.



  • Hi, nice work!
    I have changed the code for REBOOT so there is no need for a reboot-pin.
    like this...

    else if (strcmp(message, "REBOOT") == 0) {
    #if DEBUG == 1
    Serial.println(F("REBOOT"));
    #endif
    // Software reboot with watchdog timer
    // Enter Watchdog Configuration mode:
    WDTCSR |= (1<<WDCE) | (1<<WDE);
    // Reset enable
    WDTCSR= (1<<WDE);
    // Infinite loop until watchdog reset after 16 ms
    while(true){}
    }


  • Contest Winner

    @Dencan interesting thanks! I initially thought there were two use cases, one is to reboot with a remote command and the other is by using a pin (e.g. when having physical access is easier than sending out a message). But I think you're right, if you have physical access, well, hitting the reset button is way easier than connecting the reboot pin to RST 😉
    I'll use this snippet for the version about to be released (https://github.com/mysensors/NodeManager/issues/101). Thanks!



  • @Dencan That is a method i never even thought about Dencan.
    Cool.. You tought me something. Thanks. I have to try it out for myself. 🙂
    My first thought was jumping to the address of the RESET interrupt vector in memory.
    It's located in the very first bytes at address 0.

    __asm__ __volatile__ ("jmp 0");
    

  • Contest Winner

    Version 1.5 of NodeManager is finally available here!
    https://github.com/mysensors/NodeManager

    I've done my best to implement most of the requests received so far since unfortunately I'm expecting starting from June very little spare time to spend here so I tried to hurry up a bit 🙂 The result is a pretty long change log and a total of 26 between ad-hoc and generic out-of-the-box sensors supported up to this release:

    • Added support for ACS712 current sensor
    • Added support for HC-SR04 distance sensor
    • Added support for BMP085/BMP180 temperature and pressure sensor
    • Added support for Sonoff smart switch
    • Added support for Rain Gauge sensor
    • Added support for MCP9808 temperature sensor
    • Added forecast output to all Bosch sensors
    • Added I2C address auto-discovery for all Bosch sensors
    • Added support for running as a gateway
    • Added option to retrieve the latest value of a sensor from outside NodeManager
    • Remote reboot now does not need a reboot pin configured
    • A heartbeat is now sent also when waking up from a wait cycle
    • When waking up for an interrupt, only the code of the sensor expecting that interrupt is executed
    • Added capability to retrieve the time from the controller
    • Optimized battery life for DS18B20 sensors
    • SLEEP_MANAGER has been deprecated (now always enabled) and setMode() replaces setSleepMode()
    • New mode ALWAYS_ON to let the node staying awake and executing each sensors' loop
    • ESP8266WiFi.h has to be included in the main sketch if MY_GATEWAY_ESP8266 is defined
    • Added receiveTime() wrapper in the main sketch
    • Fixed the logic for output sensors
    • Added common gateway settings in config.h

    I've added upgrade instructions as well in the documentation. Generally speaking to upgrade it is safe to just replace the existing NodeManager.h and NodeManager.cpp files but with this release I had to do some minor changes to the main sketch as well, as documented in the release notes.

    Thanks everybody for all the advice and for reporting any issue always in a constructive way 🙂


  • Contest Winner

    Hi, I've added a "How to contribute" section in the documentation of the dev release in case anybody is interested to contribute to this project: https://github.com/mysensors/NodeManager/tree/development#contributing.

    I'm not a git expert so I hope those instructions to have some sense 🙂



  • Very good job @user2684 ! I like it very much.
    Only one thing, how I can create a simple DHT22 node? I activated MODULE_DHT, and registered like this:

      /*
         Register below your sensors
      */
      int sensorDHT_Id = nodeManager.registerSensor(SENSOR_DHT22,4);
      SensorDHT*  sensorDHT = (SensorDHT*)nodeManager.getSensor(sensorDHT_Id);
      sensorDHT->setSamples(5);
      sensorDHT->setTackLastValue(true);
      sensorDHT->setForceUpdate(5);
      /*
         Register above your sensors
      */
    

    But when compiling it throws: 'DHT11' was not declared in this scope

    I have the DHT library installed by the env, and a copy at the projects libraries folder (portable) and also at the same project folder (when opening the sketch also opens the library), but still complains.

    ??


  • Contest Winner

    @Sergio-Rius thanks! Are you sure you are using the DHT library from the arduino IDE ( https://github.com/adafruit/DHT-sensor-library) and not the one from the MySensors example folder? Thanks



  • @user2684
    AH! You're right, you got me. I'll change and test it. Anyways the one I was using was failing frecuently reading the sensor.

    But you could also make your wrapper compatible with the MyS one. The difference between both is that the later places its declarations inside the class. You can make it work by fully qualifying the calls like the example:

    NodeManager.cpp @1949:       int dht_type = sensor_type == SENSOR_DHT11 ? _dht.DHT11 : _dht.DHT22;
    

    It could be interesting if there are anyone really needing the MyS DHT library. And also it seems more memory optimized. The adafruit's are two in one and also needs another library helper in cascade.


  • Contest Winner

    @Sergio-Rius great idea! Will prevent people to get crazy with compile errors, thanks!
    I'll track this with https://github.com/mysensors/NodeManager/issues/144



  • @user2684 Nevermid! I'm still struggling trying to make the TH sensor 😅
    That's the serial output I get and nothing at domoticz.

    REG I=1 P=4 P=6 T=0
    REG I=2 P=4 P=7 T=1
    NodeManager v1.5
    INT1 M=255
    INT2 M=255
    RADIO OK
    PRES I=200, T=23
    PRES I=201, T=30
    BATT V=2.95 P=50
    SEND D=0 I=201 C=0 T=38 S= I=0 F=2.95
    PRES I=1 T=6
    PRES I=2 T=7
    READY
    
    MY I=3 M=1
    

  • Contest Winner

    @Sergio-Rius ok, this is kind of a standard startup with the temperature and humidity sensors presented as child 1 and 2, so far so good.

    PRES I=1 T=6
    PRES I=2 T=7
    

    By default no data is reported unless the node enters in a cycle. You would like to add:

    nodeManager.setSleep(SLEEP, 10, MINUTES);
    

    Or

    nodeManager.setSleep(WAIT, 10, MINUTES);
    

    To start getting periodically the data out. Alternatively you can send a REQ message to the child id with the appropriate V_type



  • @user2684 Mmmmm what if you have a motion sensor in the same node? (I'm trying to migrate my own sketch)



  • @Sergio-Rius said in 💬 NodeManager:

    The difference between both is that the later places its declarations inside the class.

    Please don't waste your time as they are not compatible. In my stupidity didn't make sure that my lib wasn't "personalized".
    What a pity.


  • Contest Winner

    @Sergio-Rius yes, you can have a motion sensor on the same node as far as it is a sleeping node. This is because the interrupt is coming from the MySensors sleep() call. Having this compatibility in a non sleeping node is instead only planned (https://github.com/mysensors/NodeManager/issues/142)



  • Hi, I would like to have smartSleep for my nodes. I read that NodeManager can do that. But I couldn't find an explanation how it is doing it. I use OpenHAB as the controller and MQTT to communicate to the MySensors-Gateway. Is smartSleep working for this scenario? Did you extend the Gateway?


  • Contest Winner

    @strangeoptics NodeManager does use smart sleep by default. The way it works (with or without node manager) is pretty simple: when the node tells the gw/controller is about to go to sleep, it actually wait (by default 500ms I think) for new messages before powering off the radio and going to sleep. Useful if you have a sleeping node and want to communicate with it. Im not familiar with those controllers but I'm sure others are but generally speaking the way it works is the controller usually queue your messages and when the node checks in release the queue.



  • @user2684 If I understand it correct, NodeManager is basically using the smartSleep method of the MySensors library and extended it with a default delay of 500ms after the heart beat message.
    The logic for queuing the messages inbetween the wakeup periods is not implementet from NodeManager and has to come from the controller. In my case OpenHAB hasn't got the logic and smartSleep wouldn't work 😞


  • Contest Winner

    @strangeoptics not really, node manager is not extending smart sleep at all, smart sleep from the core MySensors library by itself is implemented with this delay 🙂



  • @user2684 so which controler are you using?


  • Contest Winner

    https://www.mysensors.org/controller/myhouse but since I wrote it, my opinion would be biased 😛



  • The configuration service is a good ideaal.
    Even better would be if it would allow setting and reading user parameters.



  • Hi
    I have a led ir emitter can i send to my air contiotioner a code like x0284828 by digital output in nodemanager(with irremote library is simple)


  • Contest Winner

    @mar.conte mmm not sure I got the use case. I think we need some sort of "IR" specific output. Btw if you prefer, feel free to open a new thread on https://forum.mysensors.org/category/43/nodemanager


  • Contest Winner

    Hi @Dencan @core_c I'm having trouble with both the solutions you recommended. When the reboot code is triggered, I have my pro mini 3.3v board freezing with the power led blinking continuously (https://github.com/mysensors/NodeManager/issues/133). Do you guys know what the issue could be? Thanks!



  • @user2684 It appears that this problem is caused by a bug in bootloaders used in some Arduino boards.

    The solution suggested is to flash optiboot bootloader to the Arduino Pro Mini. Or not using a bootloader.

    I use mostly barebone atmega328's with optiboot bootloader, working perfectly with reboot function, so I haven't been aware of the problem until now when I used a pro mini.

    Please read this article which explains the cause of the problem and suggested fix.
    https://andreasrohner.at/posts/Electronics/How-to-make-the-Watchdog-Timer-work-on-an-Arduino-Pro-Mini-by-replacing-the-bootloader/

    I will try it on a pro mini when I have time.


  • Contest Winner

    @Dencan thanks, very good information. Based on what you are saying, I'd probably re-introduce the reboot pin as a backup solution just in case somebody doesn't want or can move away from the default bootloader. In this way both the approaches will be available. Thanks!



  • I have a hard time figuring out one simple thing... Is the NodeManager code supposed to be on the sensors? Or is it supposed to be on the Gateway? Or both??



  • @ronnyandre With NodeManager you can build sensors but also configure a gateway. 👍



  • @Sergio-Rius I think I understood it correctly. Code goes on the sensors, not on the gateway itself? That means, the MySensors Serial Gateway I use is only a carrier of the messages that NodeManager receives on the sensors I implement the code?



  • @user2684 Hi, i am trying to get started with NodeManager, and I have a question about dht configuration?
    I would like to set it to not update values if temperature is not changed, something like ((SensorLatchingRelay*)nodeManager.getSensor(1))->setTackLastValue(true);
    But how do I select both sensors, are they numbers 1 and 2 (both temp and humidity)?
    I would also like to add these settings to them.
    ((SensorLatchingRelay*)nodeManager.getSensor(1))->setForceUpdate(4);
    ((SensorLatchingRelay*)nodeManager.getSensor(1))->setFloatPrecision(1);

    Thanks!



  • @ronnyandre NodeManager is a code wrapper. It's a collection of libraries, that has been join with a configuration script that automatically picks and does what is needed for your like.
    You can make a common temperature sensor, but if you look at the documentation and the NodeManager.h code or the ino template itself, you have options for gateway configuration.
    So you should be able to configure a gateway sketch and burn into your hardware.

    I hope this gives some light before the dinner 😉



  • @dakipro said in 💬 NodeManager:

    ((SensorLatchingRelay*)nodeManager.getSensor(1))->setForceUpdate(4);
    ((SensorLatchingRelay*)nodeManager.getSensor(1))->setFloatPrecision(1);

    SensorLatchingRelay is wrong here.
    Try:

      int sensorDHT_Id = nodeManager.registerSensor(SENSOR_DHT22, PIN_DHT);
      SensorDHT* sensorDHT = (SensorDHT*)nodeManager.getSensor(sensorDHT_Id);
      sensorDHT->setSamples(5);
      sensorDHT->setSamplesInterval(2001);
      sensorDHT->setTackLastValue(true);
      sensorDHT->setForceUpdate(3);
    

    Those options refer to the whole device, should be applied also to humidity. There was a bug on this but I think it was already corrected. If not, try with development version.



  • Thanks, right after posting the question, I have found a example on the topic itself (search function on the forum does not search current topic anymore, I had to scroll down to be able to "find in page").
    I am now using this
    int sensorDHT_Id = nodeManager.registerSensor(SENSOR_DHT22,4);
    SensorDHT* sensorDHT = (SensorDHT*)nodeManager.getSensor(sensorDHT_Id);

    Will see how it goes 🙂



  • @Sergio-Rius Thanks man! I will definitely take a closer look. I just one silly last question....

    Trying to use a simple DS18B20 temperature sensor, and I get the following error:

    error: 'SENSOR_DS18B20' was not declared in this scope
    nodeManager.registerSensor(SENSOR_DS18B20,3);

    Seems like it doesn't like me declaring it. I have installed Dallas Temperature and One Wire through Arduino libraries.



  • @ronnyandre you need to uninstall those libraries and install those mentioned in the heading: Installing the dependencies: NodeManager



  • @mickecarlsson Thanks, I will try that later today 😃


  • Contest Winner

    @Sergio-Rius @ronnyandre just to add something on top of what already discussed regarding the gateway thing, yes you can use NodeManager for the gateway as well or alternatively a standard gateway sketch, those are fully compatibile since NodeManager adds very little when running as a gateway, it just relies on the standard MySensors library and directives


  • Contest Winner

    @dakipro in addition to what @Sergio-Rius already pointed out correctly, consider when multiple child IDs are created, you would need to call those functions on EACH id. Have a look at https://github.com/mysensors/NodeManager/issues/176 for more details. Thanks


  • Contest Winner

    @ronnyandre ensure MODULE_DS18B20 is enabled in your config.h otherwise SENSOR_DS18B20 will not be made available. Thanks



  • @user2684 on #176 issue... and the sample I pasted before... then we have to configure Samples, SamplesInterval, TackLastValue and ForceUpdate for Temp and Hum separately?
    It doesn't make sense to me.


  • Contest Winner

    @Sergio-Rius yes, this is the case, since two different and completely independent child IDs are created, you need to call the methods on both. This is true for any sensor creating multiple IDs. And you're right, it doesn't make sense to me either, it is something I've realized recently. I'm tracking it down with https://github.com/mysensors/NodeManager/issues/198 but I do not expect this to be an easy fix. Thanks



  • Hi, what's your calendar for v 1.6.0. I was looking forward to IO-Expander MCP23017 and TTP226/9 support in this release...


  • Contest Winner

    @vikasjee this was the plan, you're right, but I had to postpone a good number of requests supposed to be part of v1.6 since I wanted to allow this https://forum.mysensors.org/topic/6980/browser-based-firmware-generator which is dependent on NodeManager to come to life asap. So unfortunately I had to move those enhancement requiring some effort to v1.7 even if I already acquired the hardware. Sorry for that



  • @user2684 No issues! When are you planning for 1.7.0? Looking forward to an early release especially the IO-Expander MCP23017 support...


  • Contest Winner

    @vikasjee v1.7 will be somewhere after summer since v1.6 should be out by the end of this month I guess. But I can promise to start looking into IO-Expander MCP23017 support as the first thing as v1.7 development will start so to make it available first thing into the development branch 🙂



  • Hi, is it possible to add neopixel in the next version? thank you for your work



  • Hello, is there an option to use the (fantastic) Node Manager in a RS485 wired set-up?


  • Contest Winner

    @MCF I've added https://github.com/mysensors/NodeManager/issues/203 to track this request. Feel free to add any relevant comment or code samples to the issue. Thanks!


  • Contest Winner

    @ArduiSens RS485 should be already there in the development version (https://github.com/mysensors/NodeManager/tree/development). Nothing special, I've just added to config.h some sample directives, commented out by default. Let me know in case this approach can be improved. Thanks!



  • @user2684, found the RS485 settings (thanks), but having problems with disabling the BATTERY_MANAGER option.
    We don't need this option in a RS485 serial wired network (or RS485 serial gateway).

    config.h:
    #define BATTERY_MANAGER 0

    gives following compiling errors:
    sketch\NodeManager.cpp: In member function 'void NodeManager::process(Request&)':
    NodeManager.cpp:3722: error: 'setBatteryReportSeconds' was not declared in this scope
    case 40: setBatteryReportSeconds(request.getValueInt()); break;
    NodeManager.cpp:3723: error: 'setBatteryReportHours' was not declared in this scope
    case 41: setBatteryReportHours(request.getValueInt()); break;
    NodeManager.cpp:3724: error: 'setBatteryReportDays' was not declared in this scope
    case 42: setBatteryReportDays(request.getValueInt()); break;

    exit status 1
    'setBatteryReportSeconds' was not declared in this scope


  • Contest Winner

    @ArduiSens thanks, good catch, this looks like a mistake on my side, keep on eye on https://github.com/mysensors/NodeManager/issues/206 for a fix which should come shortly.



  • @user2684, why does NodeManager take so many sketch memory?
    e.g.
    (#define BATTERY_MANAGER 1; #define DEBUG 1; #define MODULE_DS18B20 1)
    sketch NodeManager RS485 config for DS18B20 --> 28730 bytes (93%) of program storage space. Maximum is 30720 bytes.

    own sketch for RS485 SR04T --> 17078 bytes (55%) of program storage space. Maximum is 30720 bytes.

    OK, DS18B20 and SR04T are not the same but DS18B20 is less complex, so 38% more memory is pretty much.
    Do I miss something?



  • @ArduiSens for curiosity, what board are those numbers from?

    NodeManager is a young project. You can expect changes and optimizations in the future. And also you can do suggestions and pull requests.



Suggested Topics

19
Online

11.4k
Users

11.1k
Topics

112.7k
Posts