Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Nicklas Starkel
    3. Best
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by Nicklas Starkel

    • RE: [SOLVED] After upgrade to mysensors 2.1 problems with radio module might manifest itself more.

      @Anticimex and @tekka .
      I just upgraded my GW (MEGA) and most sensors.
      I do not know what you did, but my range is incredible now (and everything works!)
      I had good coverage in my apartment before, but if I went outside my front door it started failing (steel security door).
      Now, I can not only go outside the door, I can actually go 3 stairs down in my building with AWIs NRF tester.
      Same hardware is used and nothing has changed from my part.

      Kudos and thank you.

      posted in Troubleshooting
      Nicklas Starkel
      Nicklas Starkel
    • RE: gw.sleep on battery powered magnet door switch

      @siod , I had the same problem.
      I actually ordered a original NRF 24 mini and this seemed to solve some of my problems.
      i think another problem I'm having is that my batteries has a huge self discharge (old 3.7v 18650)

      On a side note.. I'm with @sling .
      Loose the pullups and set them LOWยด.
      I have a 1MOhm resistor between VCC and PIN 2 and PIN 3 (also 2 switches).
      Using the pullup HIGH draws around 130uA versus LOW it draws between 7 to 10uA!

      posted in My Project
      Nicklas Starkel
      Nicklas Starkel
    • RE: ๐Ÿ’ฌ Battery Powered Sensors

      @mfalkvidd , it was too late at night for me.
      I had it at current but it didn't show anything. So without thinking I put it at voltage.
      And the problem with not showing anything when I had it at current was I had blown the internal multimeter fuse some days ago.
      Ehrmm.. yes. move along, nothing to see here ๐Ÿ™‚

      posted in Announcements
      Nicklas Starkel
      Nicklas Starkel
    • RE: ๐Ÿ’ฌ Battery Powered Sensors

      Good article/site on why Alkaline is the best way to go for Mysensors nodes ๐Ÿ™‚
      http://batteryuniversity.com/learn/article/elevating_self_discharge

      posted in Announcements
      Nicklas Starkel
      Nicklas Starkel
    • RE: My 2AA battery sensor

      @EasyIoT , how are your sensors doing, its been 2 years ๐Ÿ™‚
      And also, @m26872 , the node 105. Is it alive?

      posted in My Project
      Nicklas Starkel
      Nicklas Starkel
    • RE: Sleep time is not actual sleep time

      @Yveaux and @mfalkvidd thanks!
      It's not important for me, just curious to know why ๐Ÿ™‚

      posted in Troubleshooting
      Nicklas Starkel
      Nicklas Starkel
    • RE: ๐Ÿ’ฌ Battery Powered Sensors

      @parachutesj you have to modify the pro mini. Remove the power led according to instructions!

      posted in Announcements
      Nicklas Starkel
      Nicklas Starkel
    • Watering flowers on the balcony + LED illumination

      I recently managed to build a small irrigation system for my balcony, using mysensors of course!
      It was picked up by Sweden's best "smart home"-shop "m.nu" and I had a chance to blog about it.
      @hek , I didn't really clean up the code so you actually got credit for it on their facebook page, lol.
      Hope you approve or I will make them change it.
      Maybe you can see a trade off with the fame and that I also mentioned mysensors.org ๐Ÿ™‚

      Swedish version:
      https://blog.m.nu/gastblogg-styrning-av-bevattning-balkonglador/

      English using google translate:
      https://translate.google.com/translate?sl=sv&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=https%3A%2F%2Fblog.m.nu%2Fgastblogg-styrning-av-bevattning-balkonglador%2F&edit-text=

      Cheers

      posted in My Project
      Nicklas Starkel
      Nicklas Starkel
    • RE: [SOLVED] After upgrade to mysensors 2.1 problems with radio module might manifest itself more.

      @Anticimex

      I had built the NRF tester and had perfect coverage with no drops in my apartment before (with signing!) from any of my NRFs.

      To test further I even put one of those plateboards for testing NRF to my gateway. Added external power from another source.
      Did the same to my NRF tester but still it fails.
      Have put them close and also gone around in my apartment to eliminate distance signal error, still the same.
      So only difference is mysensors 2.1.
      However, since no one else is complaining then maybe the problem IS with my setup.
      Or could also be that no one else has updated ๐Ÿ˜‰

      I'm using Arduino 1.6.11, maybe I should install 1.8.1?

      posted in Troubleshooting
      Nicklas Starkel
      Nicklas Starkel
    • RE: ๐Ÿ’ฌ Battery Powered Sensors

      @hek , I've read that post several times ๐Ÿ™‚
      Since it was so outdated (2 years) I naturally assumed the 'battery powering article' was a newer way to do it (especially since mys2.0).
      Also, the post you linked to is attributed if you use no voltage regulator.
      And in the article this is also one of the things you are recommended to remove, hence making it even more confusing as to why the article describes another way than the post.

      posted in Announcements
      Nicklas Starkel
      Nicklas Starkel
    • RE: delay different functions in loop

      After some hours of sleep and refactoring everything, now I think I've managed to get everything working.
      I have some problem wrapping my head around "forceTransmit" command and how it works.
      Also, millis() is also something I have to learn ๐Ÿ™‚

      Here is the code if anyone finds it interesting.
      What it does is measure soil moisture every hour and sends info (normal forkthingie).
      Also reading every 30 seconds for temperature and humidity (si7021)
      If humidity changes by 1 or temperature by 0.2 it will send info.
      If no info has been sent it will force send info every 20 minutes.

      3 Relays are there to power water pumps and a LED strip.

      i have now semi-learned the use of functions, which is fun ๐Ÿ™‚
      cheers!

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      //Network
      #define MY_NODE_ID 62
      #define MY_PARENT_NODE_ID 0
      #define MY_PARENT_NODE_IS_STATIC
      #define MY_RADIO_NRF24
      //Includes
      #include <SPI.h>
      #include <MySensors.h>
      #include <SI7021.h>
      #include <RunningAverage.h>
      //Define Relay
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_2  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define RELAY_3  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 3 // 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
      #define RELEASE "1.4"
      //Define Moisture things
      #define AVERAGES 2
      
      // Child sensor ID's
      #define CHILD_ID_TEMP  5
      #define CHILD_ID_HUM   6
      #define CHILD_ID_MOISTURE 7
      // How many milli seconds between each measurement of temp and humidity
      #define MEASURE_INTERVAL 30000
      // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
      #define FORCE_TRANSMIT_INTERVAL 2000 // 20minutes
      // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
      // TEMP_TRANSMIT_THRESHOLD for temperature threshold.
      #define HUMI_TRANSMIT_THRESHOLD 1.0
      #define TEMP_TRANSMIT_THRESHOLD 0.2
      #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
      #define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
      #define STABILIZATION_TIME 1000 // Let the sensor stabilize before reading
      SI7021 humiditySensor;
      
      // Sensor messages
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgMoist(CHILD_ID_MOISTURE, V_HUM);
      MyMessage msgR1(RELAY_1, V_STATUS);
      MyMessage msgR2(RELAY_2, V_STATUS);
      // Global settings
      const unsigned long tUpdateTemp = 5000; // update interval
      unsigned long t0;
      const unsigned long tUpdateMoist = 360000; // update interval
      unsigned long t1;
      int measureCount = 0;
      boolean isMetric = true;
      boolean highfreq = true;
      boolean transmission_occured = false;
      
      // Storage of old measurements
      float lastTemperature = -100;
      int lastHumidity = -100;
      int oldMoistureLevel = -1;
      //Change direction on moisture
      byte direction = 0;
      //Moisture sensor pins
      RunningAverage raHum(AVERAGES);
      const int SENSOR_ANALOG_PINS[] = {A0, A1}; // Sensor is connected to these two pins. Avoid A3 if using ATSHA204. A6 and A7 cannot be used because they don't have pullups.
      
      void before()
      {
          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()
      {
        Serial.begin(115200);
        humiditySensor.begin();
        isMetric = getControllerConfig().isMetric;
        Serial.print(F("isMetric: ")); Serial.println(isMetric);
        raHum.clear();
        t0=millis();
        t1=millis();
        //sendTempHumidityMeasurements(true);
        //sendMoistureMeasurements();
        delay(250);
        for (int i = 0; i < N_ELEMENTS(SENSOR_ANALOG_PINS); i++)
        {
          pinMode(SENSOR_ANALOG_PINS[i], OUTPUT);
          digitalWrite(SENSOR_ANALOG_PINS[i], LOW); 
        }
      }
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("RelayTempHumMoist", "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,"Relays");
        }
        present(CHILD_ID_TEMP,S_TEMP,"Temperature");
        present(CHILD_ID_HUM,S_HUM,"Humidity");
        present(CHILD_ID_MOISTURE, S_HUM,"Moisture");
      }
      
      
      void loop()
      {
        measureCount ++;
        bool forceTransmit = false;
        transmission_occured = false;
        if (measureCount > FORCE_TRANSMIT_INTERVAL)
        {
          forceTransmit = true; 
          measureCount = 0;
          Serial.print(F("inne i loopen :"));
        }
      
      if ((millis() - t1) > tUpdateMoist) sendMoistureMeasurements();
          sendTempHumidityMeasurements(forceTransmit);
      }
      
      void sendTempHumidityMeasurements(bool force)
      {
        wait(MEASURE_INTERVAL);
        bool tx = force;
        si7021_env data = humiditySensor.getHumidityAndTemperature();
        raHum.addValue(data.humidityPercent);
        float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100.0);
        float diffHum = abs(lastHumidity - raHum.getAverage());
        Serial.print(F("TempDiff :"));Serial.println(diffTemp);
        Serial.print(F("HumDiff  :"));Serial.println(diffHum);
        t0 = millis();
        if (isnan(diffHum)) tx = true; 
        if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
        if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true;
      
        if (tx)
        {
          measureCount = 0;
          float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0;
      
          int humidity = data.humidityPercent;
          Serial.print("T: ");Serial.println(temperature);
          Serial.print("H: ");Serial.println(humidity);
      
          send(msgTemp.set(temperature,1));
          send(msgHum.set(humidity));
          lastTemperature = temperature;
          lastHumidity = humidity;
          transmission_occured = true;
        }
      }
          
      void sendMoistureMeasurements()
      {
        pinMode(SENSOR_ANALOG_PINS[direction], INPUT_PULLUP); // Power on the sensor
        analogRead(SENSOR_ANALOG_PINS[direction]);// Read once to let the ADC capacitor start charging
        sleep(STABILIZATION_TIME);
        int moistureLevel = (1023 - analogRead(SENSOR_ANALOG_PINS[direction]));
      
        // Turn off the sensor to conserve battery and minimize corrosion
        pinMode(SENSOR_ANALOG_PINS[direction], OUTPUT);
        digitalWrite(SENSOR_ANALOG_PINS[direction], LOW);
      
        direction = (direction + 1) % 2; // Make direction alternate between 0 and 1 to reverse polarity which reduces corrosion
        // Always send moisture information so the controller sees that the node is alive
      
        // Send rolling average of 2 samples to get rid of the "ripple" produced by different resistance in the internal pull-up resistors
        // See http://forum.mysensors.org/topic/2147/office-plant-monitoring/55 for more information
        if (oldMoistureLevel == -1)
        { // First reading, save value
          oldMoistureLevel = moistureLevel;
        }
        send(msgMoist.set((moistureLevel + oldMoistureLevel +  0.5) / 2 / 10.23, 1));
        oldMoistureLevel = moistureLevel;
        t1 = millis();
      }
      
      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());
        }
      }```
      posted in Troubleshooting
      Nicklas Starkel
      Nicklas Starkel