💬 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.



  • @Sergio, I know and it's OK. I'm just playing (trying to convert my RS485 projects).
    In the cases above I'm using Nano boards.


  • Contest Winner

    @ArduiSens that's true, many optimizations can be done to save additional storage. With v1.5.1 a design issue eating up 20% of the storage has been fixed but many things for sure can be improved. As for the current version, try lowering down MAX_SENSORS (which by default allocates the pointers for 10 child IDs) and set DEBUG to 0 after your tests. The latter especially should give you another 20% of storage back (static strings of the debug output are consuming most of this storage). Thanks



  • How to add i2c sensor?
    I see that there is a git issue asking about si7021 which I would also like to use as well, but has someone perhaps connected it already by creating a custom sensor?
    How difficult would it be?
    Thanks!


  • Contest Winner

    Hi @dakipro, I've just commented on github for the Si7021. Regarding the custom sensor, have a look at this https://github.com/mysensors/NodeManager#creating-a-custom-sensor (or the same section on the development branch documentation if you are using it). As far as you create an (inline) class inheriting from Sensor or its subclasses and implement the methods listed in the documentation you can invoke registerSensor() providing the instance of your class and NodeManager will take care of it. Just take inspiration from an existing sensor if you want to do so, it should save you some time. Thanks


  • Contest Winner

    Hello All,

    NodeManager v1.6 is finally available! Download and upgrade instructions can be found as always on https://github.com/mysensors/NodeManager

    First of all I want to thank everybody contributing to the project, especially those who have submitted pull requests to the repository.

    In v1.6 we have 36 out-of-the-box sensors as well as a good number fixes and enhancements. The most notable are for sure the capability to customize any sensor remotely through a brand new remote API and a more flexible and effective way to configure reporting intervals and sleep cycles:

    • Introduced new remote API to allow calling almost ALL NodeManager's and its sensors' functions remotely
    • Reporting interval configuration is now indipendent from the sleep cycle
    • Reporting interval can be customized per-sensor
    • All intervals (measure/battery reports) are now time-based
    • Added support for BMP280 temperature and pressure sensor
    • Added support for RS485 serial transport
    • Added support for TSL2561 light sensor
    • Added support for DHT21 temperature/humidity sensor
    • Added support for AM2320 temperature/humidity sensor
    • Added support for PT100 high temperature sensor
    • Added support for MH-Z19 CO2 sensor
    • Added support for analog rain and soil moisture sensors
    • Added support for generic dimmer sensor (PWM output)
    • Added support for power and water meter pulse sensors
    • Radio signal level (RSSI) is now reported automatically like the battery level
    • SensorRainGauge now supports sleep mode
    • SensorSwitch now supports awake mode
    • SensorLatchingRealy now handles automatically both on and off commands
    • SensorMQ now depends on its own module
    • Added safeguard (automatic off) to SensorDigitalOutput
    • Any sensor can now access all NodeManager's functions
    • DHT sensor now using MySensors' DHT library

    For those who have previously forked the repository, please ensure to merge the updated development branch first before submitting any new PR.

    Thanks!



  • This post is deleted!


  • Hi, obviously a lot of work gone into NodeManager thanks, I'm quite new to MySensors but have started working on.a few sensors around my home.

    I was just looking through the code (NodeManager.cpp) and an apparent issue jumped out at me (I write C++ for a living on very large boxes but still worry about performance!)
    The two functions NodeManager::_saveConfig and NodeManager::_loadConfig are used to save the _sleep_time value to EEPROM. The code splits the long value into 3 parts by dividing by successively 255 . On loading the value is reconstructed by multiplying by 255.
    I'm pretty sure that you meant to use 256 to split the long value into three independent bytes to store.
    Dividing or multiplying by 255 is potentially expensive whereas dividing or multiplying by 256 is much faster simply requiring shifts.
    The normal code for splitting a long value into individual bytes would be something like
    uint8_t byte0 = _sleep_time & 0xff; // compiler should generate a simple byte load
    uint8_t byte1 = (_sleep_time >> 8 ) & 0xff; // compiler should still generate a simple byte load from the second byte of _sleep_time
    uint8_t byte2 = (_sleep_time >> 16) & 0xff; // as before should still be a byte load.
    I'm not sure how good the gcc optimiser is for the AVR code but, putting the shift&mask operations directly into the calls of saveSave(...) may avoid having to allocate local variables as in
    // save the 3 bits
    saveState(EEPROM_SLEEP_SAVED,1);
    saveState(EEPROM_SLEEP_1,_sleep_time & 0xff);
    saveState(EEPROM_SLEEP_2,(_sleep_time >> 8 ) & 0xff);
    saveState(EEPROM_SLEEP_3, (_sleep_time >> 16) & 0xff);

    I am not an expert in in the AVR architecture or instruction set so maybe there is a good reason why you are using 255 instead of 256 - it just seems strange!

    Regards

    Graham



  • Hi,
    I have started to play with nodemanager and I have registered a SENSOR_DS18B20. Nodemanager handles all the heavy lifting and the sensor is reporting the temperature 100%. I can change the sleep and report intervals with “setReportIntervalSeconds and setSleepSeconds”.

    Question 1:
    According to the MySensors documentation (https://www.mysensors.org/download/serial_api_20#variable-types) a S_TEMP sensor can report the V_TEMP value and a V_ID value. Nodemanager populates the V_TEMP variable, but how can I populate and send the V_ID value?
    Question2:
    If I want to add an additional sensor I must register it with “registerSensor” and I would set the report interval for this sensor by getting a pointer to this sensor with “getSensor”, but how do I add custom code for this sensor in Loop()? How do I ensure that the custom code is only executed for this sensor and not for the other sensor?



  • @user2684, Will you like to consider adding a #DEFINE to let user configure PowerOn function to select "GND-On" or "Vcc-On" (5V0)?

    With this GND-On PowerOn, a single GND wire controlled by a digital pin can control the power instead of 2 wire poweron control. [so many control words :)]

    For devices that require more than ~10mA current (~Arduino pin current) this GND-On configuration can help externally supplied higher powered V+ current to switch the devices! Thus, will also help 3V3 devices to be controlled by PowerOn, of course, with external 3V3!



  • I just started using NodeManager, mainly for the ability to send settings to the node.
    I started with a plain analog (Voltage) sensor, and it works just fine. But I cannot make a DS18B20 sensor to send any temperature data. It registers on the gateway, and that's it.
    I have enabled the DS18B20 module in the config.h.
    This is the code in the sketch:

      /*
       * Register below your sensors
      */
      nodeManager.setSleepSeconds(10);
      nodeManager.setReportIntervalSeconds(10);
      int temp = nodeManager.registerSensor(SENSOR_DS18B20);
       /*
       * Register above your sensors
      */
    

    Am I missing something?


  • Contest Winner

    @graham86 there was no special reason why I used 255 apart from my lack of c++ knowledge 😛 Thanks for the hit, I'll fix it with https://github.com/mysensors/NodeManager/issues/215


  • Contest Winner

    Hi @FredRoot, V_ID has not been used so far by NodeManager, thanks for noticing it! I've added https://github.com/mysensors/NodeManager/issues/216 for this

    Regarding the other question you have two ways: 1) add your custom code to onLoop() in NodeManager.cpp (this will not survive to an upgrade) 2) create a custom sensor inheriting from Sensor or other subclasses and call registerSensor() by providing an instance of this class (https://github.com/mysensors/NodeManager#creating-a-custom-sensor)
    Thanks


  • Contest Winner

    @vikasjee sorry my bad, I think I couldn't understand your suggestion 🙂 Do you have an example to let me understand better? thanks and sorry again, I'm sure I'm missing something somewhere 🙂


  • Contest Winner

    @kted I think you forgot the pin to which the sensor is attached to. e.g.

    nodeManager.registerSensor(SENSOR_DS18B20,6);
    


  • @user2684 Actually, you are right. Thank you.
    But shouldn't the compiler throw an error?

    Now to the hard part: How to send the actual command from Domoticz, for example to change the sleep duration...



  • @kted Such functionality it's supposed to be hard-coded in the node sketch. But if you want to make it modificable from Domoticz, perhaps you can make use of the V_VAR1-3 variables and modify them in domoticz, receive them in the node and pass to NodeManager.


  • Contest Winner

    @kted the compiler doesn't complain because for some sensors (e.g. those using i2c), the pin is not required so I made it not mandatory. As for Domoticz, I'll let others to address your question since I don't know that controller enough. Thanks



  • @user2684 I have looked at the changes in https://github.com/mysensors/NodeManager/pull/174 which incorporates an alternative improved implementation for the _LoadConfig/_SaveConfig functions (interesting that using an intermediate union requires less code than my shifting version- presumably due to differences in the way the GCC optimiser works for an AVR target).
    I spotted a coupld of minor points and was also able to further reduce the code size.
    Firstly as we are writing C++ rather than C the declaration of the union should just be
    // Local union used to split _sleep_time into bytes
    union tLongByteArrayCombo{
    long long_value;
    uint8_t byte_array[4];
    } ;
    (The typedef systax, although valid C++ is unnecessary - a simple union declaration is sufficient.)
    There is also a typo - the original had a member called byte_arrray instead of byte_array.

    You can also save 24 bytes of code by avoiding the use of a local union variable and simply aliasing _sleep_time as the union type. So instead of _load_config doing -
    tLongByteArrayCombo c;
    c.byte_array[0] = loadState(EEPROM_SLEEP_1);
    c.byte_array[1] = loadState(EEPROM_SLEEP_2);
    c.byte_array[2] = loadState(EEPROM_SLEEP_3);
    c.byte_array[3] = 0;
    _sleep_time = c.long_value;
    You can do
    (((tLongByteArrayCombo&)_sleep_time).byte_array )[0] = loadState(EEPROM_SLEEP_1);
    (((tLongByteArrayCombo&)_sleep_time).byte_array )[1] = loadState(EEPROM_SLEEP_2);
    (((tLongByteArrayCombo&)_sleep_time).byte_array )[2] = loadState(EEPROM_SLEEP_3);
    (((tLongByteArrayCombo&)_sleep_time).byte_array )[3] = 0;
    And in _save_config instead of
    tLongByteArrayCombo c;
    c.long_value = _sleep_time;
    saveState(EEPROM_SLEEP_1, c.byte_array[0]);
    saveState(EEPROM_SLEEP_2, c.byte_array[1]);
    saveState(EEPROM_SLEEP_3, c.byte_array[2]);
    you can use
    saveState(EEPROM_SLEEP_1, (((tLongByteArrayCombo&)_sleep_time).byte_array )[0] );
    saveState(EEPROM_SLEEP_2, (((tLongByteArrayCombo&)_sleep_time).byte_array )[1] );
    saveState(EEPROM_SLEEP_3, (((tLongByteArrayCombo&)_sleep_time).byte_array )[2] );

    In my specific sample sketch I had the following code sizes

    Original NodeManager.cpp 28242 Bytes
    NodeManager with patch from pull rq 174 - 28154 Bytes (saving of 88 Bytes of code(
    Patched NodeManager with additional changes above - 28130 Bytes ( saving another 24 Bytes of code)


  • Contest Winner

    @graham86 I guess you are referring to https://github.com/mysensors/NodeManager/pull/217, not 174, am I wrong? Anyway, any contribution that would help saving bytes is more than welcome: NodeManager is becoming more and more complex and the situations where we are out of storage start increasing so we definitely need to save whatever wherever we can 🙂 Regarding what you are proposing above, keep on eye on PR #217; once a new one dedicated to this part of the code will be created as discussed there, feel free to add your own PR to that branch or just let me know and I'll do it for you. Thanks!



  • @user2684, Sorry, couldn't revert to your query earlier as i was away building a small library.

    Expanding onto my earlier post on the requested Power Management feature -
    A simple switch will complete a circuit whenever its switched ON. This allows for placing the switch on the ground return wire too. So only a single GND-ON (Switched ON) will complete the circuit (without requiring an additional Vcc-ON switch).

    Now, with a developer configured #DEFINE GND_ON_POWER =1 may be checked in NodeManager's PowerManagement functions to DigitalWrite(Digital_GND_ON_Pin, LOW)
    for a switchON effect.

    Additionally, To provide an extra current to a sensor (i.e. more than a ~10mA-20mA, a max safe current provided by an Arduino pin) an external power source (other than Arduino +5V0 OR +3V3) may be provided by that external power source (of course with with a common ground wire between Arduino and that powersource to complete the circuit.)

    Also, with the current 2Wire PowerOn methodology, the VccPowerOn switch can provide only one positive voltage (that provided by Arduino Vcc, say +5V0) but not +3V3 (say) to the sensors. If some attached sensors require the other voltage (+3V3), then, this 2Wire PowerOn method will not help. Whereas, a single GND_On power methodology will still switch the circuit thus managing the Power to those sensors too.
    [PS: Signal Voltage Levels will still need to be managed by the developer attaching those sensors to the node]

    I think this simple feature will add on to the power of the PowerManagement functions.

    Hope this clears some air ? Open to suggestions...


  • Contest Winner

    @vikasjee thanks all clear now! I'll track this with https://github.com/mysensors/NodeManager/issues/224. Thanks again for the detailed explanation!


  • Contest Winner

    Hello all, just to let you know when compiling against the latest version of the mysensors 2.2.0-beta library, NodeManager will crash on startup, just after presenting the mysensors logo. Thanks @gohan for pointing this out! Root cause is still unknown but when MY_DEBUG is defined, the crash doesn't take place (https://github.com/mysensors/NodeManager/issues/223)



  • @user2684, Can we have a quick hot fix?


  • Contest Winner

    @vikasjee sure, as soon as I'll be able to understand the reason why it crashes when MY_DEBUG is not defined 😞 if somebody from the core team has any hit, would be really appreciated!
    Thanks



  • I'm afraid that issue 223 is not a NodeManager failure. I can reproduce it in a new sketch without using NodeManager.
    Other issue with MySensors are, NRF24 doesn't link with controller.
    If MY_DEBUG_VERBOSE_RF24 is defined, it automagically works.



Suggested Topics

  • 2
  • 13
  • 4
  • 1
  • 19
  • 2
  • 11

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts