Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. OpenHardware.io
  3. 💬 NodeManager
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

💬 NodeManager

Scheduled Pinned Locked Moved OpenHardware.io
contest2017arduinonewbiemysensorsbattery sensor
196 Posts 42 Posters 67.3k Views 41 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K ksga

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

    U Offline
    U Offline
    user2684
    Contest Winner
    wrote on last edited by
    #30

    @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!

    K 1 Reply Last reply
    0
    • Ivan ZI Ivan Z

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

      U Offline
      U Offline
      user2684
      Contest Winner
      wrote on last edited by
      #31

      @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!

      Ivan ZI 1 Reply Last reply
      0
      • U user2684

        @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!

        Ivan ZI Offline
        Ivan ZI Offline
        Ivan Z
        Hardware Contributor
        wrote on last edited by
        #32

        @user2684
        Function name alt text

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

        U 1 Reply Last reply
        0
        • Ivan ZI Offline
          Ivan ZI Offline
          Ivan Z
          Hardware Contributor
          wrote on last edited by
          #33

          Sorry, not fully read text

          1 Reply Last reply
          0
          • Ivan ZI Offline
            Ivan ZI Offline
            Ivan Z
            Hardware Contributor
            wrote on last edited by
            #34

            What about BMP085 ??

            U 1 Reply Last reply
            0
            • Ivan ZI Ivan Z

              @user2684
              Function name alt text

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

              U Offline
              U Offline
              user2684
              Contest Winner
              wrote on last edited by
              #35

              @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!

              1 Reply Last reply
              0
              • Ivan ZI Ivan Z

                What about BMP085 ??

                U Offline
                U Offline
                user2684
                Contest Winner
                wrote on last edited by
                #36

                @Ivan-Z said in 💬 NodeManager:

                What about BMP085 ??

                I've ordered one and waiting for its delivery :-)

                1 Reply Last reply
                0
                • Ivan ZI Offline
                  Ivan ZI Offline
                  Ivan Z
                  Hardware Contributor
                  wrote on last edited by Ivan Z
                  #37

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

                  REQ - nide to read Relay status

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bilbolodz
                    wrote on last edited by
                    #38

                    It's already requested feature:

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

                    and it will be done.

                    1 Reply Last reply
                    1
                    • core_cC Offline
                      core_cC Offline
                      core_c
                      wrote on last edited by
                      #39

                      very clean coding.. i like it.
                      Well done. :cool:

                      1 Reply Last reply
                      1
                      • U Offline
                        U Offline
                        user2684
                        Contest Winner
                        wrote on last edited by
                        #40

                        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

                        1 Reply Last reply
                        1
                        • U user2684

                          @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!

                          K Offline
                          K Offline
                          ksga
                          wrote on last edited by
                          #41

                          @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;
                          }
                          
                          U 1 Reply Last reply
                          0
                          • K ksga

                            @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;
                            }
                            
                            U Offline
                            U Offline
                            user2684
                            Contest Winner
                            wrote on last edited by
                            #42

                            @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!

                            1 Reply Last reply
                            0
                            • core_cC Offline
                              core_cC Offline
                              core_c
                              wrote on last edited by
                              #43

                              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?

                              U 1 Reply Last reply
                              0
                              • core_cC core_c

                                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?

                                U Offline
                                U Offline
                                user2684
                                Contest Winner
                                wrote on last edited by
                                #44

                                @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

                                U 1 Reply Last reply
                                0
                                • U user2684

                                  @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

                                  U Offline
                                  U Offline
                                  user2684
                                  Contest Winner
                                  wrote on last edited by
                                  #45

                                  @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 :-)

                                  1 Reply Last reply
                                  2
                                  • U Offline
                                    U Offline
                                    user2684
                                    Contest Winner
                                    wrote on last edited by
                                    #46

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

                                    1 Reply Last reply
                                    0
                                    • U Offline
                                      U Offline
                                      user2684
                                      Contest Winner
                                      wrote on last edited by
                                      #47

                                      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.

                                      1 Reply Last reply
                                      0
                                      • D Offline
                                        D Offline
                                        Dencan
                                        wrote on last edited by
                                        #48

                                        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){}
                                        }

                                        U core_cC 3 Replies Last reply
                                        1
                                        • D Dencan

                                          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){}
                                          }

                                          U Offline
                                          U Offline
                                          user2684
                                          Contest Winner
                                          wrote on last edited by
                                          #49

                                          @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!

                                          1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular