Skip to content
  • MySensors
  • 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
karl261K

karl261

@karl261
About
Posts
135
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Node / sketch with Dallas and Relay starts behaving weird after one day
    karl261K karl261

    How would you do this?Like this? I tried to move it to the setup function.
    This is also a version I found using non blocking (millis()) code.

    // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool.
    //#define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
    // #define MY_RF24_PA_LEVEL RF24_PA_MIN           // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
    // #define MY_RADIO_RFM69                         // 433Mhz transmitter and reveiver.
    
    // Choose if you want this sensor to also be a repeater.
    // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
    
    // Are you using this sensor on battery power?
    // #define BATTERY_POWERED                        // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater!
    
    //#define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_PARENT_NODE_ID 99
    #define MY_PARENT_NODE_IS_STATIC
    #define MY_NODE_ID 8
    #define MY_BAUD_RATE 9600
    
    // LIBRARIES (in the Arduino IDE go to Sketch -> Include Library -> Manage Libraries to add these if you don't have them installed yet.)
    #include <SPI.h>
    #include <MySensors.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    //Added this nteger to avoid stupid collect2.exe: error: ld returned 5 exit status.
    //It seems adding one or removing one (or plenty) solves the error.
    //int stupidinteger=0;
    //int stupidintegertwo=0;
    //int stupidintegerthree=0;
    
    // VARIABLES YOU CAN CHANGE
    #define COMPARE_TEMP 1                            // Send temperature only if changed? 1 = Yes 0 = No. Can save battery.
    #define ONE_WIRE_BUS 7                            // Digital pin where Dallas sensor(s) is/are connected.
    #define maxAttachedDS18B20 16                     // Maximum amount of teperature sensors you can connect to this arduino (16).
    const long measurementInterval = 10000;        // Time to wait between reads (in milliseconds).
    float tempThreshold = 0.1;                        // How big a temperature difference has to be before an update is sent. Makes the sensor less precise, but also less jittery, and can save battery.
    
    
    //VARIABLES YOU PROBABLY SHOULDN'T CHANGE
    #define TEMP_CHILD_ID 0                           // for MySensors. Within this node each sensortype should have its own ID number.
    OneWire oneWire(ONE_WIRE_BUS);                    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire);              // Pass the oneWire reference to Dallas Temperature.
    float lastTemperature[maxAttachedDS18B20];        // creates an array to hold the previous temperature measurements for each possible sensor.
    int numSensors = 0;                               // variable to contain the number of found attached sensors.
    unsigned long measurementSleepTime = 0;           // variable to store the calculated Sleep time if the node is battery powered.
    bool metric = true;                               // Variable that stores if the sensor will output the temperature in Fahrenheit of Celsius. The gateway sends this preference to the node.
    bool receivedConfig = false;                      // This is not used in the code, but perhaps MySensors requires this?
    
    
    // Mysensors settings
    MyMessage msg(TEMP_CHILD_ID,V_TEMP);              // Sets up the message format that we'l be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
    
    
    void before()
    {
       sensors.begin();                               // Startup up the OneWire library. It allows multiple sensors to talk over one wire (one pin).
    
    for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
     
    }
    }
    
    
    void setup()
    {
      metric = getControllerConfig().isMetric;
       for(int i=0; i<maxAttachedDS18B20; i++) 
       {
          lastTemperature[i] = 0;  //Pre-filling array with 0's.
       }
       sensors.setWaitForConversion(false); // requestTemperatures() will not block current thread
    
    #ifdef BATTERY_POWERED // If the node is batter ypowered, we'll let Sleep take over the scheduling.
       measurementSleepTime = measurementInterval;
       measurementInterval = 0; // When the Arduino is asleep, millis doesn't increment anymore (time stops as it were). To fix this, we'll set the measurement interval time to 1, so that when the arduino wakes up it will immediately try to measure again.
    #endif
    
       //Serial.begin(115200); // for serial debugging.
       //Serial.println("Hello world, I am a sensor node.");
    }
    
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Maischen relay and Dallas non blocking", "1.0");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
      }
    
       numSensors = sensors.getDeviceCount();          // Fetch the number of attached temperature sensors
       for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++) {
          present(i, S_TEMP);     
       }
    }
    
    
    
    void loop()
    {
    
       // You should not change these variables:
       static boolean dallasIsMeasuring = true;                        // Used to indicate when the time is right for a new measurement to be made.
       static boolean dallasIsCalculating = false;                     // Used to bridge the time that is needed to calculate the temperature values by the Dallas library.
       unsigned long currentMillis = 0;                          // The millisecond clock in the main loop.
       static unsigned long previousMeasurementMillis = 0;       // Used to remember the time of the last temperature measurement.
       static int16_t conversionTime = 0;                        // Used to store the time needed to calculate the temperature from measurements.
    
       currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
    
       // Let's measure the temperature
       if(dallasIsMeasuring == true && currentMillis - previousMeasurementMillis >= measurementInterval) { // If we're not calculating, and enough time has passed, we'll start again.
          dallasIsMeasuring = false; // We're measuring, so let's take it off our to-do list.
          //Serial.println("Starting new measurement(s)");
          previousMeasurementMillis = currentMillis; // Mark the time of the initialiation of this measurement.
    
          // Fetch temperatures from Dallas sensors
          sensors.requestTemperatures();
    
          // query conversion time. Apparently it takes a while to calculate.
          //conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          conversionTime = millisToWaitForConversion(sensors.getResolution()); // This is a modified version of the line above, to deal with the problem in the current Dallas library.
          dallasIsCalculating = true; //Next step is to re-calculate the temperature again.
       }
    
    
       // Next, let's calculate and send the temperature
       if(dallasIsCalculating == true && currentMillis - conversionTime > previousMeasurementMillis) {
          dallasIsCalculating = false; // We're doing this now, so check calculating off the to-do list too.
          for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++){  // Loop through all the attached temperature sensors.   
            //float temperature = getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i); // Fetch the temperature form the current sensor
            float temperature = static_cast<float>(static_cast<int>((metric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
             //Serial.print("Sensor #");
             //Serial.print(i);
             //Serial.print(" says it is ");
             //Serial.print(temperature);
             //Serial.println(" degrees");
             if(temperature != -127.00 && temperature != 85.00) { // Avoids working with measurement errors.
                if (COMPARE_TEMP == 1 && abs(temperature - lastTemperature[i]) < tempThreshold) { // is the temperature difference bigger than the threshold?
                   //Serial.print(temperature - lastTemperature[i]);
                   //Serial.print("- difference too small, so not sending the new measurement to the gateway.\n");
                } else {
                   //Serial.print(temperature - lastTemperature[i]);
                   //Serial.print("Sending the new temperature to the gateway.\n");
                   send(msg.setSensor(i).set(temperature,1));
                   lastTemperature[i] = temperature; // Save new temperatures to be able to compare in the next round.
                }
             }
          }
    
          // Both tasks are done. Time to wait until we should measure again.
          //Serial.print("zzzzZZZZzzzzZZZZzzzz\n");
    
    #ifdef BATTERY_POWERED
          unsigned long quicktimecheck = millis(); // check how much time has passed during the measurement (can be up to 750 milliseconds), and then calculate from that how long to sleep until the next intended measuring time.
          unsigned long sleeptime = measurementSleepTime - (quicktimecheck - previousMeasurementMillis); //How much time has passed already during the calculating? Subtract that from the intended interval time.
          sleep (sleeptime);
    #endif
    
          dallasIsMeasuring = true;
       }
    }
    
    
    // This function helps to avoid a problem with the latest Dallas temperature library.
    int16_t millisToWaitForConversion(uint8_t bitResolution)
    {
       switch (bitResolution) 
       {
         case 9:
            return 94;
         case 10:
            return 188;
         case 11:
            return 375;
         default:
            return 750;
       }
    }
    
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_STATUS) {
        // Change relay state
        digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.sensor, message.getBool());
        // Write some debug info
        //Serial.print("Incoming change for sensor:");
        //Serial.print(message.sensor);
        //Serial.print(", New status: ");
        //Serial.println(message.getBool());
      }
    }
    
    Troubleshooting

  • Node / sketch with Dallas and Relay starts behaving weird after one day
    karl261K karl261

    Yes, the 10 seconds is, because I am using it to control the heating of a mash (beer). So I want the temperature (if it changed) to be sent very often.

    The line with getControllerConfig() I have from the mysensors temperature sensor sketch example.

    Actually my initial post has an error, maybe I can correct. Yes, the temperature should be checked every 10 seconds. But when the sensor failed it kept sending the same temperature every 6 or 7 minutes in the same interval. So not as specified by the sketch.

    Troubleshooting

  • Node / sketch with Dallas and Relay starts behaving weird after one day
    karl261K karl261

    Hi,

    I am having trouble with a node. It is a combined Dallas temperature sensor with a relay.

    Everything works fine, but after about a day the node starts to behave weird. Sketch attached.

    Once it kept on sending the temperature, but did not react to requests to switch the relay anymore.
    A power cycle did not help, maybe some capacitors were not fully empty, another power cycle and everything was back to normal.
    Another time the same thing happened: The node kept sending the temperatures, but no reaction on the relay.
    Another time it failed like this: It kept sending the same temperature over and over again, the true temperature was definitely different (so it was not reading the temperature from the Dallas). It just sent the same temperature, in some strange regular interval, every 7 minutes or so. No matter that the sketch only sends the temperature if it is different from the previous one. Also no reaction on the relay.

    I do not know what happens, the node somehow works and operates and sends temperatures, but somehow gets confused. The issue is reproducible it seems, I just need to let it run for 24 hours or more.

    Any ideas? Anything wrong in the sketch? Maybe some variable or number that is overflowing? Or the time or the Atmega (millis)?

    It is a self built node with an Atmega328p running at 8 MHz with the internal clock. I have built other nodes like this some with 1 MHz that read the temperature around the house, all working fine. But totally different sketches.

    Thanks very much in advance for any ideas!

    // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool.
    //#define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
    // #define MY_RF24_PA_LEVEL RF24_PA_MIN           // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
    // #define MY_RADIO_RFM69                         // 433Mhz transmitter and reveiver.
    
    // Choose if you want this sensor to also be a repeater.
    // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
    
    // Are you using this sensor on battery power?
    // #define BATTERY_POWERED                        // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater!
    
    //#define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_PARENT_NODE_ID 99
    #define MY_PARENT_NODE_IS_STATIC
    #define MY_NODE_ID 8
    #define MY_BAUD_RATE 9600
    
    // LIBRARIES (in the Arduino IDE go to Sketch -> Include Library -> Manage Libraries to add these if you don't have them installed yet.)
    #include <SPI.h>
    #include <MySensors.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    //Added this nteger to avoid stupid collect2.exe: error: ld returned 5 exit status.
    //It seems adding one or removing one (or plenty) solves the error.
    //int stupidinteger=0;
    //int stupidintegertwo=0;
    //int stupidintegerthree=0;
    
    // VARIABLES YOU CAN CHANGE
    #define COMPARE_TEMP 1                            // Send temperature only if changed? 1 = Yes 0 = No. Can save battery.
    #define ONE_WIRE_BUS 7                            // Digital pin where Dallas sensor(s) is/are connected.
    #define maxAttachedDS18B20 16                     // Maximum amount of teperature sensors you can connect to this arduino (16).
    unsigned long measurementInterval = 9250;        // Time to wait between reads (in milliseconds).
    //float tempThreshold = 0.1;                        // How big a temperature difference has to be before an update is sent. Makes the sensor less precise, but also less jittery, and can save battery.
    
    
    //VARIABLES YOU PROBABLY SHOULDN'T CHANGE
    #define TEMP_CHILD_ID 0                           // for MySensors. Within this node each sensortype should have its own ID number.
    OneWire oneWire(ONE_WIRE_BUS);                    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
    DallasTemperature sensors(&oneWire);              // Pass the oneWire reference to Dallas Temperature.
    float lastTemperature[maxAttachedDS18B20];        // creates an array to hold the previous temperature measurements for each possible sensor.
    int numSensors = 0;                               // variable to contain the number of found attached sensors.
    unsigned long measurementSleepTime = 0;           // variable to store the calculated Sleep time if the node is battery powered.
    bool metric = true;                               // Variable that stores if the sensor will output the temperature in Fahrenheit of Celsius. The gateway sends this preference to the node.
    bool receivedConfig = false;                      // This is not used in the code, but perhaps MySensors requires this?
    
    
    // Mysensors settings
    MyMessage msg(TEMP_CHILD_ID,V_TEMP);              // Sets up the message format that we'l be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
    
    
    void before()
    {
       sensors.begin();                               // Startup up the OneWire library. It allows multiple sensors to talk over one wire (one pin).
    
    for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
     
    }
    }
    
    
    void setup()
    {
       for(int i=0; i<maxAttachedDS18B20; i++) 
       {
          lastTemperature[i] = 0;  //Pre-filling array with 0's.
       }
       sensors.setWaitForConversion(false); // requestTemperatures() will not block current thread
    
    #ifdef BATTERY_POWERED // If the node is batter ypowered, we'll let Sleep take over the scheduling.
       measurementSleepTime = measurementInterval;
       measurementInterval = 0; // When the Arduino is asleep, millis doesn't increment anymore (time stops as it were). To fix this, we'll set the measurement interval time to 1, so that when the arduino wakes up it will immediately try to measure again.
    #endif
    
       //Serial.begin(115200); // for serial debugging.
       //Serial.println("Hello world, I am a sensor node.");
    }
    
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Maischen relay and Dallas", "1.0");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
      }
    
       numSensors = sensors.getDeviceCount();          // Fetch the number of attached temperature sensors
       for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++) {
          present(i, S_TEMP);     
       }
    }
    
    
    
    void loop()
    {     
      // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // query conversion time and sleep until conversion completed
      int16_t conversionTime = millisToWaitForConversion(sensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
    //    Serial.print("Library");
    //    Serial.print(" says its conversion time is ");
    //    Serial.print(conversionTime);
    //    Serial.println(" ms");
      wait(conversionTime);
    
      // Read temperatures and send them to controller 
      for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++) {
     
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
    //    Serial.print("Sensor #");
    //    Serial.print(i);
    //    Serial.print(" says it is ");
    //    Serial.print(temperature);
    //    Serial.println(" degrees");
     
        // Only send data if temperature has changed and no error
        #if COMPARE_TEMP == 1
        if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
        #else
        if (temperature != -127.00 && temperature != 85.00) {
        #endif
     
          Serial.print(temperature - lastTemperature[i]);
          Serial.print("Sending the new temperature to the gateway.\n");
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature,1));
          // Save new temperatures for next compare
          lastTemperature[i]=temperature;
        }
    //  else {
    //  Serial.print(temperature - lastTemperature[i]);
    //  Serial.print("- difference too small, so not sending the new measurement to the gateway.\n");
    //  }
      }
      wait(measurementInterval);
    }
    
    
    // This function helps to avoid a problem with the latest Dallas temperature library.
    int16_t millisToWaitForConversion(uint8_t bitResolution)
    {
       switch (bitResolution) 
       {
         case 9:
            return 94;
         case 10:
            return 188;
         case 11:
            return 375;
         default:
            return 750;
       }
    }
    
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_STATUS) {
        // Change relay state
        digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.sensor, message.getBool());
        // Write some debug info
        //Serial.print("Incoming change for sensor:");
        //Serial.print(message.sensor);
        //Serial.print(", New status: ");
        //Serial.println(message.getBool());
      }
    }
    
    
    
    Troubleshooting

  • BME280 How to use it outdoors
    karl261K karl261

    Hi, no, I live rather far from the sea. I don't know what is killing the outdoor sensor. The same in the greenhouse survives much weirder temperatures and humidities.

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    Interesting idea, the ptfe tape. I will try it with the next sensor!

    So, only the outdoor sensors fail. It is now more than one that failed.

    I have one in the living room -- perfect.

    And, very strange: I have one in the green house. Huge T differences, sometimes very hot, and often 100% humidity. Actually conditions should be worse for this sensor compared to the outdoor sensor. But: it is just fine.

    Weird.

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    Now after 2-3 month more outside the sensor seems to be finally dead. No reaction anymore. Also the 2nd one in the greenhouse does not reply anymore. I'll have to check. The one in the living room is fine.

    It seems that at least the ones I bought are not really lasting long outdoors.

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    So, this story also continues. After having these problems, I brought the sensor into the house and left it running for the past several weeks in the living room. Actually it is working fine. No more problems.

    Now, for Christmas, I have brought it back outside to the birdhouse. And it is still working fine, even at -10 °C. Let's see how long it will last this time.

    What I also noticed is that now I have a second of these in the greenhouse where the humidity is definitely from time to time 100%. At 4°C. But both outdoor sensors somehow never reach 100%, but stop somewhere between 85-90%. It seems they are not made to detect 100% humidity.

    Hardware

  • Raspberry uninteruptable power suppy
    karl261K karl261

    My UPS is working fine now for the past several months. My current setup is like this:

    AC -- Power suppply power bank -- power bank -- supercaps -- voltage regulator 5V -- raspi.

    The supercaps are needd because when the powerbank switches there is a short power interruption. The supercaps are buffering this.

    The 5V voltage regulator is needed, because when the power bank is charging and discharging at the same time its output voltage drops to 4.6 V or so. The voltage regulator keeps this at 5 V at all times.

    Hardware

  • Raspberry uninteruptable power suppy
    karl261K karl261

    @AWI Ok, so the bosst converter has arrived. Now I have a stupid question: Should I add the boost converter before of after the caps? Somehow I cannot figure out the advantages / disadvantages of one or the other method.

    The problem with my power bank is, that the voltage drops to 4.5 V when the power bank is charging. When I disconnect the power bank from its supply, the voltage is 5 V as expected.

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    @r-nox Hm, it is reading every 15 seconds at the moment. Do you think this is too much?

    The current sensor is not completely broken, it seems. Sometimes it is showing "normal" values. I brought it into the house to test it, and in the house it seems to show normal values. I will know more tomorrow morning.

    According to its specs it is supposed to be good for weather monitoring. But then, it seems it does not like "weather" too much.

    I also found it strange that in the past 30 days the maximum humidity it read was 87 %. And for sure there were plenty of nights here with 100 %. But ok, I could live with that. But it has started to show far too low values for humidity, down to 0 %. I'll leave it in the house for 1-2 days and then see how it behaves outside.

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    @r-nox You mean too many readings per time unit?

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    @r-nox Somehow, doesn't it? A bit too short for my taste. It should not see any rain, I wonder what is killing it. Or, how I can protect it even better.

    @Nca78 I had a SI7021 with protective foil before, but it was not very accurate. Actually it was quite far off, that's why I started to look for something more accurate.

    When I look around online there seems to be some connection/confusion with the SI7021 and SHT21. But I did not really understand it. Does anybody know more about it?

    EDIT: Hm, seems to be two different sensors, but the board is always the same. So I would need to check to really get a SHT21 and with a protective cover...

    EDIT2: I do not seem to find any SHT21 with protective cover...

    Hardware

  • BME280 How to use it outdoors
    karl261K karl261

    It does not look that it was much longer time. But instead like the sensor before, the current one is now showing values between 0-22% humidity. T seems to be fine. That is SO disappointing. It seems that these things are not suitable for outdoor use. Lasted only a month...

    Buuuuh.

    Hardware

  • nRf24L01+ connection quality meter
    karl261K karl261

    @Mark-Swift Where do you see the failures? Do you have a log output?
    The code is for mysensors 2.0.0. Did you adapt all the network specific #define in the beginning of the sketch to your network? In my example there is a static parent set and the static parent has the ID 99. If that does not exist, there will be failures.

    My Project

  • nRf24L01+ connection quality meter
    karl261K karl261

    For those who need and don't have a display like me, here is my sketch version for output to the serial console. So what I do is, I run around with a laptop connected to the node and watch the serial console, or, I just move around with a tablet and the node. The tablet is connected to my raspi and I watch the output of my gw on the pi using picocom. Picocom handles very well the missing line feeds in the output. The gw output is also very informative, there are no statistics, but still I see when stuff fails...

    Thanks for the cool sketch @AWI!

    /*
     PROJECT: MySensors / Quality of radio transmission 
     PROGRAMMER: AWI (MySensors libraries)
     DATE: 20160529/ last update: 20160530
     FILE: AWI_Send.ino
     LICENSE: Public domain
    
     Hardware: ATMega328p board w/ NRF24l01
        and MySensors 2.0
        
    Special:
        
        
    Summary:
        Sends a radio message with counter each  x time to determine fault ratio with receiver
    Remarks:
        Fixed node-id & communication channel to other fixed node
        
    Change log:
    20160530 - added moving average on fail/ miss count, update to 2.0
    */
    
    
    //****  MySensors *****
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    #define MY_RADIO_NRF24                                  // Enable and select radio type attached
    //#define MY_RF24_CHANNEL 80                                // radio channel, default = 76
    // MIN, LOW, HIGH, MAX
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    #define MY_NODE_ID 250
    #define NODE_TXT "Q 250"                                // Text to add to sensor name
    
    #define MY_PARENT_NODE_ID 99                          // fixed parent to controller when 0 (else comment out = AUTO)
    #define MY_PARENT_NODE_IS_STATIC
    #define MY_BAUD_RATE 9600
    
    
    // #define MY_RF24_CE_PIN 7                             // Ceech board, 3.3v (7,8)  (pin default 9,10)
    // #define MY_RF24_CS_PIN 8
    #define DESTINATION_NODE 0                              // receiving fixed node id (default 0 = gateway)
    
    #include <SPI.h>
    #include <MySensors.h>  
    
    
    // helpers
    #define LOCAL_DEBUG
    
    #ifdef LOCAL_DEBUG
    #define Sprint(a) (Serial.print(a))                     // macro as substitute for print, enable if no print wanted
    #define Sprintln(a) (Serial.println(a))                 // macro as substitute for println
    #else
    #define Sprint(a)                                       // enable if no print wanted -or- 
    #define Sprintln(a)                                     // enable if no print wanted
    #endif
    
    
    // MySensors sensor
    #define counterChild 0
    
    // send constants and variables
    int messageCounter = 0 ; 
    const int messageCounterMax = 100 ;                     // maximum message counter value 
    const unsigned counterUpdateDelay = 500 ;               // send every x ms and sleep in between
    
    // receive constants and variables
    boolean failStore[messageCounterMax] ;                  // moving average stores & pointers
    int failStorePointer = 0 ;
    boolean missedStore[messageCounterMax] ;
    int missedStorePointer = 0 ;
    int newMessage = 0 ;
    int lastMessage = -1 ;
    int missedMessageCounter = 0 ;                          // total number of messages in range (messageCounterMax)
    int failMessageCounter = 0 ;                            // total number of messages in range (messageCounterMax)
    uint8_t parent = 0 ;                                    // parent node-id 
    
    
    // standard messages
    MyMessage counterMsg(counterChild, V_PERCENTAGE);       // Send value
    
    
    void setup() {
    
        for(int i= 0 ; i <  messageCounterMax ; i++){       // init stores for moving averages
            failStore[i] = true ;
            missedStore[i] = true ;
        }
        missedStorePointer = failStorePointer = 0 ;
        delay(1000);
    }
    
    void presentation(){
    // MySensors
        present(counterChild, S_DIMMER, "Quality counter " NODE_TXT) ;  // counter uses percentage from dimmer value
    }
    
    
    void loop() {
        // Sprint("count:") ; Sprintln(messageCounter) ;
        Sprint("Parent: "); Sprint(parent); Sprint("       Fail "); Sprint(failMessageCounter); Sprint("   "); Sprint(getCount(failStore, messageCounterMax)); Sprintln("%");
        Sprint("Destination: "); Sprint(DESTINATION_NODE); Sprint("  Miss "); Sprint(missedMessageCounter); Sprint("   "); Sprint(getCount(missedStore, messageCounterMax)); Sprintln("%");
    
    
        missedStore[failStorePointer] = false  ;            // set slot to false (ack message needs to set) ; 
        boolean succes = failStore[failStorePointer] = send(counterMsg.setDestination(DESTINATION_NODE).set(failStorePointer), true);  // send to destination with ack
        if (!succes){
            failMessageCounter++ ; 
            Sprint("Fail on message: ") ; Sprint(failStorePointer) ;
            Sprint(" # ") ; Sprintln(failMessageCounter);
        }
        failStorePointer++ ;
        if(failStorePointer >= messageCounterMax){
            failStorePointer =  0   ;                       // wrap counter
        }
        parent = getParentNodeId();                         // get the parent node (0 = gateway)
        wait(counterUpdateDelay) ;                          // wait for things to settle and ack's to arrive
    }
    
    void receive(const MyMessage &message) {                // Expect few types of messages from controller
        newMessage = message.getInt();                      // get received value
        switch (message.type){
            case V_PERCENTAGE:
                missedStore[newMessage] = true ;            // set corresponding flag to received.
                if (newMessage > lastMessage){              // number of messages missed from lastMessage (kind of, faulty at wrap)
                    Sprint("Missed messages: ") ; Sprintln( newMessage - lastMessage - 1) ;
                    missedMessageCounter += newMessage - lastMessage - 1 ;
                }
                lastMessage = newMessage ;
                break ;
            default: break ;
        }
    }
    
    
    // calculate number of false values in array 
    // takes a lot of time, but who cares...
    int getCount(boolean countArray[], int size){
        int falseCount = 0 ;
        for (int i = 0 ; i < size ; i++){
            falseCount += countArray[i]?0:1 ;
        }
        return falseCount ;
    }
    
    My Project

  • Is it possible to run more than one pin to an interrupt for sleep/wake purposes?
    karl261K karl261

    This sketch works a little bit better... Hm, it sometimes is not reading a key, but it seems to be the loose cable connections?!

    #include <Wire.h>
    #include <Keypad_I2C.h>
    #include <Keypad.h>
    #define I2CADDR 0x38
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 8
    
    
    #include <MySensors.h>
    #include <SPI.h>
    
    word temp_pin_state;
    
    unsigned long time;
    
    
    unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    
    const byte ROWS = 4; //four rows
    const byte COLS = 4; //three columns
    char keys[ROWS][COLS] = {
      {'1','2','3','A'},
      {'4','5','6','B'},
      {'7','8','9','C'},
      {'*','0','#','D'}
    };
    
    // Digitran keypad, bit numbers of PCF8574 i/o port
    byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
    
    Keypad_I2C kpd( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CADDR, PCF8574 );
    
    void setup(){
        Wire.begin( );
        kpd.begin( makeKeymap(keys) );
    //    Serial.begin(9600);
        Serial.println( "start" );
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        kpd.port_write( 0xff );
        temp_pin_state = kpd.pinState_set( );
    }
    
    void loop(){
    
        Serial.println("Waking up");
    
        kpd.port_write( temp_pin_state );
    //    wait(100);
    
        time = millis();
        while ((millis() - time) < 250) {
          char key = kpd.getKey();
        
          if (key){
            Serial.println(key);
          }
        }
        
    
        Serial.println("Good Night");
        temp_pin_state = kpd.pinState_set( );
        kpd.port_write( 0xf0 );
        wait(50);
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), FALLING, SLEEP_TIME);
    }
    
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=8)
    TSM:FPAR
    TSP:MSG:SEND 8-8-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 8-8-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-8 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 99-99-8 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=99, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=8)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-8 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    start
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    !TSP:MSG:SEND 8-8-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=fail:2.0.0
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=ok:0
    TSP:MSG:READ 0-0-8 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    Request registration...
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-8 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=8, parent=0, distance=1, registration=1
    Waking up
    Good Night
    Waking up
    1
    Good Night
    Waking up
    2
    Good Night
    Waking up
    3
    Good Night
    Waking up
    A
    Good Night
    Waking up
    4
    Good Night
    Waking up
    5
    Good Night
    Waking up
    Good Night
    Waking up
    B
    Good Night
    Waking up
    7
    Good Night
    Waking up
    Good Night
    Waking up
    9
    Good Night
    Waking up
    C
    Good Night
    Waking up
    *
    Good Night
    Waking up
    0
    Good Night
    Waking up
    #
    Good Night
    Waking up
    D
    Good Night
    
    Troubleshooting

  • Is it possible to run more than one pin to an interrupt for sleep/wake purposes?
    karl261K karl261

    @AWI Ok, I got it working somehow, now with the original Keypad_I2C library, because it had the functions ready to write to the pins... But it needs some more tine tuning. And it does not work all the time, sometimes I need to reset the PCF, by disconnecting it from power and then restart the Arduino.

    In the log below the first try does not work, the second try after reset it works.

    And after the log the sketch. It sure needs some improvement.

    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=8)
    TSM:FPAR
    TSP:MSG:SEND 8-8-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-8 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 99-99-8 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=99, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=8)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-8 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    start
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    !TSP:MSG:SEND 8-8-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=fail:2.0.0
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=ok:0
    TSP:MSG:READ 0-0-8 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    Request registration...
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-8 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=8, parent=0, distance=1, registration=1
    Waking up
    1
    Good Night
    Waking up
    Good Night
    Waking up
    Good Night
    Waking up
    Good Night
    Waking up
    Good Night
    Waking up
    Good Night
    Waking up
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=8)
    TSM:FPAR
    TSP:MSG:SEND 8-8-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-8 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSP:MSG:READ 99-99-8 s=255,c=3,t=8,pt=1,l=1,sg=0:1
    TSP:MSG:FPAR RES (ID=99, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=8)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:MSG:READ 0-0-8 s=255,c=3,t=25,pt=1,l=1,sg=0:1
    TSP:MSG:PONG RECV (hops=1)
    TSP:CHKUPL:OK
    TSM:UPL:OK
    TSM:READY
    start
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=ok:0100
    !TSP:MSG:SEND 8-8-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=fail:2.0.0
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,ft=1,st=ok:0
    TSP:MSG:READ 0-0-8 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    Request registration...
    TSP:MSG:SEND 8-8-0-0 s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=ok:2
    TSP:MSG:READ 0-0-8 s=255,c=3,t=27,pt=1,l=1,sg=0:1
    Node registration=1
    Init complete, id=8, parent=0, distance=1, registration=1
    Waking up
    Good Night
    Waking up
    1
    Good Night
    Waking up
    2
    Good Night
    Waking up
    3
    Good Night
    Waking up
    A
    Good Night
    Waking up
    4
    Good Night
    Waking up
    5
    Good Night
    Waking up
    6
    Good Night
    Waking up
    B
    Good Night
    Waking up
    7
    Good Night
    Waking up
    8
    Good Night
    Waking up
    9
    Good Night
    Waking up
    C
    Good Night
    Waking up
    *
    Good Night
    Waking up
    0
    Good Night
    Waking up
    #
    Good Night
    Waking up
    D
    Good Night
    
    #include <Wire.h>
    #include <Keypad_I2C.h>
    #include <Keypad.h>
    #define I2CADDR 0x38
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_NODE_ID 8
    
    
    #include <MySensors.h>
    #include <SPI.h>
    
    word temp_pin_state;
    
    unsigned long time;
    
    
    unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    
    const byte ROWS = 4; //four rows
    const byte COLS = 4; //three columns
    char keys[ROWS][COLS] = {
      {'1','2','3','A'},
      {'4','5','6','B'},
      {'7','8','9','C'},
      {'*','0','#','D'}
    };
    
    // Digitran keypad, bit numbers of PCF8574 i/o port
    byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
    
    Keypad_I2C kpd( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CADDR, PCF8574 );
    
    void setup(){
        Wire.begin( );
        kpd.begin( makeKeymap(keys) );
    //    Serial.begin(9600);
        Serial.println( "start" );
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        temp_pin_state = kpd.pinState_set( );
    }
    
    void loop(){
    
        Serial.println("Waking up");
    
        kpd.port_write( temp_pin_state );
        wait(100);
    
        time = millis();
        while ((millis() - time) < 500) {
          char key = kpd.getKey();
        
          if (key){
            Serial.println(key);
          }
        }
        
    
        Serial.println("Good Night");
        temp_pin_state = kpd.pinState_set( );
        kpd.port_write( 0xf0 );
        wait(100);
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), FALLING, SLEEP_TIME);
    }
    
    Troubleshooting

  • Is it possible to run more than one pin to an interrupt for sleep/wake purposes?
    karl261K karl261

    @AWI I am trapped between "collect2.exe: error: ld returned 5 exit status" errors and non working sketches. This is the world of pain. I am tempted to give up. It just does not make sense. I like things that do make sense...

    Troubleshooting

  • Is it possible to run more than one pin to an interrupt for sleep/wake purposes?
    karl261K karl261

    Ok, the keypad works. All keys. Now I have to check the interrupt.

    The interrupt is not working any more. At least I don't see it on the Voltmeter. The interrupt pin remains high all the time.

    I think this is because to get the key pressed, the library is scanning through the pins and writes different high low states to the ports of the pcf. This kills again the interrupt functionality.

    Yes, if I take out the loop function char key = kpd.get_key(); then the interrupt works again, because the library only writes 0xf0 and then it works. When the library is scanning, it does not work anymore.

    maybe it is possible to write 0xf0 before going to sleep... Then it won't scan, just wait for the interrupt?

    With the knew knowledge of 0xf0 writing I could also test the keypad_I2C library.

    Troubleshooting

  • Is it possible to run more than one pin to an interrupt for sleep/wake purposes?
    karl261K karl261

    @AWI This makes no sense at all! I did what you did, and it compiled. Then I reverted the steps, to my original setup, and it compiles too. WHY? I would be SO HAPPY if somebody could explain.

    So the sketch works, but not all keys...

    Troubleshooting
  • Login

  • Don't have an account? Register

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