💬 NodeManager


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



  • @Sergio-Rius, with RF24_VERBOSE on, the system crashes in 40-50 seconds especially if you're connected to the serial monitor or if your serial gateway has this #DEFINE on.



  • Still more strange, suddenly started to work properly on 2/3 of my testing nodes. That killed me.

    What about the gateways you are using? And the controllers?



  • Hi,

    I'm having trouble with the motion sample code. I have changed the setSleepHours(1) command to setSleepMinutes(1). I understand that the sensor will send a hart beat every 1 min. This is working fine for the hart beat, but evertime the hart beat is send the sensor sends a Trigger messages as well even though the sensor is not triggered. I thought that maybe there is a power dip and that it might cause the PIR (RS501) to send a interrupt, but I have removed the setSleepMinutes command and replaced it with a setBatteryReportHours(1) command. This command is send correctly and the sensor only sends the trigger command when the PIR is triggered. Did anyone have a similar issue?

    Attached is the sensor debug output when the setSleepMinutes command is used:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    40 MCO:BGN:BFR
    REG I=1 P=3 P=1 T=16
    NodeManager v1.6
    LIB V=2.1.1 R=N T=N A=A S=- B=-
    INT P=3 M=1
    INT P=2 M=255
    96 TSM:INIT
    176 TSF:WUR:MS=0
    198 TSM:INIT:TSP OK
    219 TSM:INIT:STATID=3
    243 TSF:SID:OK,ID=3
    264 TSM:FPAR
    313 TSF:MSG:SEND,3-3-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    385 TSF:MSG:READ,0-0-3,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    440 TSF:MSG:FPAR OK,ID=0,D=1
    2387 TSM:FPAR:OK
    2404 TSM:ID
    2418 TSM:ID:OK
    2433 TSM:UPL
    2449 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2521 TSF:MSG:READ,0-0-3,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2578 TSF:MSG:PONG RECV,HP=1
    2607 TSM:UPL:OK
    2625 TSM:READY:ID=3,PAR=0,DIS=1
    2660 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2734 TSF:MSG:READ,0-0-3,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2797 TSF:MSG:SEND,3-3-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2875 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2945 TSF:MSG:READ,0-0-3,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    RADIO OK
    3004 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=11,pt=0,l=11,sg=0,ft=0,st=OK:NodeManager
    3096 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    PRES I=200, T=23
    3170 TSF:MSG:SEND,3-3-0-0,s=200,c=0,t=23,pt=0,l=0,sg=0,ft=0,st=OK:
    PRES I=201, T=30
    3260 TSF:MSG:SEND,3-3-0-0,s=201,c=0,t=30,pt=0,l=0,sg=0,ft=0,st=OK:
    BATT V=3.30 P=100
    SEND D=0 I=201 C=0 T=38 S= I=0 F=3.30
    3418 !MCO:SND:NODE NOT REG
    3506 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:100
    PRES I=1 T=1
    3579 TSF:MSG:SEND,3-3-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
    READY
    
    3659 MCO:REG:REQ
    3688 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    3760 TSF:MSG:READ,0-0-3,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    3817 MCO:PIM:NODE REG=1
    3842 MCO:BGN:STP
    MY I=3 M=1
    3860 MCO:BGN:INIT OK,TSP=1
    SLEEP 60s
    
    3901 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    3971 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:127
    4544 MCO:SLP:TPD
    4560 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=1
    SEND D=0 I=1 C=0 T=16 S= I=1 F=0.00
    4597 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
    SLEEP 60s
    
    4732 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    4800 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:956
    5376 MCO:SLP:TPD
    5392 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=0
    SEND D=0 I=1 C=1 T=16 S= I=0 F=0.00
    5429 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
    SLEEP 60s
    
    5564 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    5632 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:1787
    6207 MCO:SLP:TPD
    6223 MCO:SLP:WUP=-1
    AWAKE
    SLEEP 60s
    
    6246 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    6322 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:2478
    6897 MCO:SLP:TPD
    6914 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=1
    SEND D=0 I=1 C=1 T=16 S= I=1 F=0.00
    6950 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
    SLEEP 60s
    
    7086 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    7153 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:3309
    7729 MCO:SLP:TPD
    7745 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=0
    SEND D=0 I=1 C=1 T=16 S= I=0 F=0.00
    7782 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
    SLEEP 60s
    
    7917 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    7985 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:4141
    8560 MCO:SLP:TPD
    8577 MCO:SLP:WUP=-1
    AWAKE
    SLEEP 60s
    
    8599 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    8675 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:4831
    9252 MCO:SLP:TPD
    9269 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=1
    SEND D=0 I=1 C=1 T=16 S= I=1 F=0.00
    9306 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:1
    SLEEP 60s
    
    9441 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    9508 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:5664
    10084 MCO:SLP:TPD
    10102 MCO:SLP:WUP=1
    INT P=3, M=1
    AWAKE
    SWITCH I=1 P=3 V=0
    SEND D=0 I=1 C=1 T=16 S= I=0 F=0.00
    10139 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=16,pt=2,l=2,sg=0,ft=0,st=OK:0
    SLEEP 60s
    
    10274 MCO:SLP:MS=60000,SMS=1,I1=1,M1=1,I2=255,M2=255
    10344 TSF:MSG:SEND,3-3-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:6500
    10921 MCO:SLP:TPD
    
    

  • Contest Winner

    @FredRoot this is weird, from the logs looks like there is kind of a floating interrupt (alternatively 1 and 0). The strange thing is that the interrupt is coming from the call to mysensors' sleep() function which is returning a positive number corresponding to the interrupt linked to pin 3 instead of a negative value like it should after a sleeping cycle. Anybody else experiencing this behavior with NodeManager v1.6? thanks



  • @user2684 can you add support for the Si7021 sensor as found in sensebender micro?
    https://www.mysensors.org/hardware/micro

    also, 2nd question.
    how do i register a sensor that is onboard?
    you ask for a child id and pin that it's on. but if it's an onboard sensor. how do you make that work? just omit the pin?


  • Contest Winner

    @mvader for question #1, I've added it to the existing issue https://github.com/mysensors/NodeManager/issues/221. For question #2, for sensors using i2c the pin is not required despite within the code nodemanager will set a random pin (have a look at SensorSHT21 for example)



  • @user2684 said in 💬 NodeManager:

    @mvader for question #1, I've added it to the existing issue https://github.com/mysensors/NodeManager/issues/221. For question #2, for sensors using i2c the pin is not required despite within the code nodemanager will set a random pin (have a look at SensorSHT21 for example)

    great.. thank you!


  • Contest Winner

    After a few months working behind the scene, NodeManager got kind of a full review in terms of architecture and usability. The code should be now simpler to understand for new users, the memory utilization has been optimized and the overall user experience has been improved.

    The looooong list of things that have been changed are detailed on https://github.com/mysensors/NodeManager/pull/229.
    Please note this is only available in the development branch (https://github.com/mysensors/NodeManager/tree/development) and will be generally available only when NodeManager's v1.7 will be released (it will take I guess still a few months).

    Since this change was blocking other pending changes, I hope now the development will be faster and feel free to submit your PRs now that the new architecture has been finalized.
    As always, any feedback is more than welcome.
    Thanks


  • Hardware Contributor

    @user2684 Thanks a lot for the architecture change, which makes a lot of sense conceptually.

    Unfortunately, it appears to use more memory than before. I'm working on an air quality board with eight MQ sensors, an MH-Z19 CO2 sensor and a Plantower PMSA003 particulate matter sensor. In previous development versions (1.7-dev, before today), the eight MQ sensors and the MH-Z19 worked fine, but now after your big merge of #229 the sketch appears to run out of memory after adding the child of the sixth MQ sensor. Do you see any chance to optimize for memory?

    Old sketch (using a previous development version of NodeManager, without the PMSA003; 155 bytes left after all nine sensors are fully initialized): https://github.com/open-tools/NodeManager_GasSensor/tree/master/NodeManager_GasSensor

    New sketch (using the latest version of NodeManager, plus a PMSA003): https://github.com/kainhofer/NodeManager/tree/GasSensor
    That sketch runs out of memory with the sixth MQ sensor (I added debug output with free memory at a lot of spots). Of course, I have commented out the PMSA003 completely to have a correct comparison.

    FWIW, the sketch is for this board: https://github.com/open-tools/NodeManager_GasSensor/blob/master/images/IMAG2267.jpg


  • Hardware Contributor

    @reinhold if you have high memory requirement, what about switching to a more modern architecture like stm32f103c8t6 on the famous "blue pill" boards ? It has 20k or RAM (10 times what you have on Arduino) and 64k of flash and it's supported by MySensors, in addition to be very cheap (2$/board). You will need voltage converter between 3.3V of the board and 5V of your sensors but that's not a big deal in exchange of the possibility to expand your board with more sensors in the future.


  • Mod

    @reinhold not sure how much this applies to NodeManager, but there are some recomendations for reducing memory footprint at https://www.mysensors.org/apidocs-beta/group__memorysavings.html


  • Hardware Contributor

    @nca78 Thanks for the suggestion to use the blue pill STM32 boards. I haven't thought of it (I only looked at the ESP8266, but that has only one ADC). I have a few lying around here, but never got around to trying them, as I first need to burn the bootloader. It looks quite promising, but the boards are huge, so I'll need to enlarge my PCB...
    The need for a 5V->3.3V regulator is no issue, as the NRF24 already needs 3.3V. The 5V analog level of the MQ sensors will need some converter (the analog ADC inputs are marked as non-5V-tolerant...), but then in turn I can get rid of the voltage dividers for the PMSA003. The larger issue seems to be the connection of the nrf24, which takes away 4 ADC pins, so there are only 6 ADC pins left, while I have 8 analog sensors 😞

    Still, for now I have the PCBs with the ProMini, so I'll try to strip down the Sensor or SensorMQ classes for my own use.


  • Hardware Contributor

    @nca78 Two more things popped up with the latest development version of NodeManager:

    • In NodeManager.ino: function void before(): The sample code to set the child id of a child is sht.children.get(1)->child_id = 5, but that does not work, because at that point the children are not yet even generated. They are created by the node.before(); call at the very end of the function... So, currently this will not assign any new child ID and the default IDs will be used. I have not checked in detail whether calling node.before() at the beginning of the before() function and then assigning child_id to the children will solve the issue. From a quick look at the code, it might work...
    • I'm trying to implement an OLED display, where the node would wake up every 5 seconds, take a measurement and display it on the OLED. But the report interval to the MySensors gateway should only be 10 minutes. I thought that
      node.setSleepSeconds(5); node.setReportIntervalMinutes(10); would be the correct way to setup NodeManager to take measurements every 5 seconds, but only report it every 10 minutes to the network. Unfortunately, Sensor::loop(MyMessage* message) seems to immediately return without measurement if the reporting timer has not elapsed. Somehow I don't understand that logic. Why have different sleep and reporting intervals when measurements will only be taken at reporting intervals anyway? I would expect measurements to be taken with the sleep intervals (e.g. to calculate an average over the whole reporting interval) and report back to the network using report intervals.

  • Contest Winner

    @reinhold thanks for reporting this issue. One of the main objectives of the new architecture was to reduce the memory footprint so if this is not the case, there is definitely something to fix. I've noticed in your sketch you are using the remote configuration sensor, that one is huge in terms of memory, if not strictly required I'd comment it out (BTW very nice project!). In PR #229 I've also uploaded a spreadsheet with all tests I run for realizing what was using the memory the most. Anyway, there is still a lot of room for improvement looks like 🙂
    Thanks @mfalkvidd , I'll give the directives you pointed out a try!


  • Contest Winner

    @reinhold you're right, assigning the child_id before calling node.before() does not work. The way to go would be to have all the methods being called before node.before() and the child_id assigned just after. Not very intuitive, I probably need to find a completely different and a better way to do so, probably by creating the Child in the constructor instead (reopening https://github.com/mysensors/NodeManager/issues/198 for this).

    Regarding setSleep and setReportInterval, measurement are driven only by setReportInterval. Those are different because there are situations (e.g. relays, motion sensors) when you have nothing to report but you want the capture the heartbeat from sleep(). What you are looking for is something I never considered which is actually a pretty nice idea (taking measurements over a given time period and than reporting at the end). I've created https://github.com/mysensors/NodeManager/issues/243 for this. With the new architecture, since keeping already track of the average within Child, should not be so difficult even if would probably require an additional Timer. Thanks!


  • Hardware Contributor

    @user2684 Thanks for the spreadsheet with your memory footprints. Are these the sketch size and the free memory that the compiler reports? Or do you measure them when running the sketch (i.e. including all dynamically allocated variables in SRAM)?

    Also, one problem you don't seem to have covered is heap fragmentation. Particularly your new List class seems to be prone to heap fragmentation with a large number of sensors: each time a sensor is added, the list needs to re-allocate the memory for its pointers. The old memory will be released, but it will remain as a hole in the memory, where new variables might be allocated. However, the next time you add an element to the list, the new pointer array can probably not re-use some of those freed holes.
    I'll provide a PR (https://github.com/mysensors/NodeManager/pull/247) that adds an allocateBlocks(count) method to the List, which can be used in the sketch and in the sensor's onSetup methods to pre-allocate the required sized. In turn, the _preAllocBlocks member does currently not serve any purpose, and I don't think it's really required functionality. In my eyes, it's more important to ensure that at a certain moment the required memory is allocated. It is not neccessary to keep a minimum nuber of blocks allocated at all times.
    For a node with 10 physical sensors (and maybe one or more built-in sensors), this will save at least 22 bytes (1,1% of total SRAM!) and probably reduce heap fragmentation by quite a bit.

    Another are where >22 bytes can be saved is the power manager. None of my nodes makes use of the power manager, yet each sensor needs to keep a (null) pointer to a power manager. Providing a compiler #define NO_MODULE_POWER_MANAGER can exclude everything PowerManager-related from compilation and save one pointer per sensor and node, i.e. with 10 sensors you'll save another 22 bytes (1,1% of total SRAM!) I'll provide a PR for this, too: https://github.com/mysensors/NodeManager/pull/248

    Apart from that, I simply stripped down the SensorMQ class and removed all configurability for my own use (don't worry, I won't submit this as a pull request... it is simply meant to squeeze the sketch onto the pro mini with the boards that I have already built).
    BTW, the SensorConfiguration is no problem as far as SRAM is concerned (it just adds the normal SRAM footprint of a Sensor instance): It has no class members of its own. Only the flash size is considerable, but for me this is not the issue, I'm running out of SRAM.


  • Contest Winner

    @reinhold I measured only what the compiler reported. Main focus was to reduce the flash size, I honestly ignored any potential SRAM issues which is bad 🙂 Thanks for the hit and for the great contributions and PRs so far. You're right about the List class and especially when the number of items is known, there is not reason why not allocating the blocks beforehand. I will merge your changes as they are and then take it back and adjust something (e.g. make the number of block you are passing to "node" optional, moving child creation into the constructor, always allocating the blocks for children in each sensor, generalizing a bit more the NO_MODULE thing etc.). Thanks again!


  • Contest Winner

    Hi, for those looking for making NodeManager time aware (with and without an attached RTC), this capability has been added to the development branch through https://github.com/mysensors/NodeManager/pull/259 and it is of course transparent to the end user. When this feature is enabled, also, the node resumes the remainder sleep time when woken up by an interrupt and allows SensorPulseMeter and subclasses to support sleep mode. Thanks


  • Plugin Developer

    @user2684 Great news! I will give that a try shortly.



  • The SensorSwitch/Door/Motion all work on interrupt pins only ? Sorry if I've misunderstood the code, thats possible.

    Anyway I've made a few changes so that busywait, if thats what they are called buttons can be also used. I'll see if I can use git somehow to share the changes, or show them at least

    Great library, looking to convert other things to use this.



Suggested Topics

26
Online

11.2k
Users

11.1k
Topics

112.5k
Posts