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
markjgabbM

markjgabb

@markjgabb
About
Posts
86
Topics
17
Shares
0
Groups
0
Followers
0
Following
1

Posts

Recent Best Controversial

  • Are folks here happy with Domoticz?
    markjgabbM markjgabb

    @sundberg84 i dont know about you, but i use imperihome as a front end over the top of domoticz with mydomoathome.....that way you get the strong base of domoticz, but i more user friendly and customisable front end

    Domoticz

  • (SOLVED) complete reset for registration and adding
    markjgabbM markjgabb

    this solution has worked perfectly
    thanks guys for all your advice...domoticz definatly cant un ignore anyway that i can find either

    Troubleshooting

  • 💬 Easy/Newbie PCB for MySensors
    markjgabbM markjgabb

    on the subject of batteries i have to say im really impressed with the setup of these boards....
    ive got a DHT and lux resistor measuring every 10 minutes, and i cant even remember how long ago i last changed the batteries...i think its about 3-4 months now....nothing special, just aldi batteries (australian cheap shopping chain)

    last check they are still 65%

    OpenHardware.io mysensors battery easy newbie pcb mysx

  • devices a long time away from controller.....
    markjgabbM markjgabb

    @mfalkvidd
    thanks for that....judging by his operation of the device it shouldnt matter how long its away..seems to be only thing he did was use a static ID, as im guessing it might change if its away for long enough....

    seems pretty simple as its a send only device.....
    only thing that i can think of that i may want feedback for is to light up buttons when they are available....

    not sure if im going to do these as powered by car...or if they should be battery powered...im guessing if battery powered lit up buttons is a bad idea

    General Discussion

  • first battery powered DHT lux
    markjgabbM markjgabb

    @sundberg84 champion and here is completed sketch which compiles without errors

    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_NODE_ID 14
    #define MY_PARENT_NODE_ID 100
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_LIGHT 2
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    #define LIGHT_SENSOR_ANALOG_PIN A1
    unsigned long SLEEP_TIME = 120000; // Sleep time between reads (in milliseconds)
    
    #define SKETCH_NAME "loungeroom living sensor #1"        // Change to a fancy name you like
    #define SKETCH_VERSION "1"                    // Your version
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    int LightLevel = 0;
    int lastLightLevel;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    
    //=========================
    // BATTERY VOLTAGE DIVIDER SETUP
    // 1M, 470K divider across battery and using internal ADC ref of 1.1V
    // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
    // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
    // 3.44/1023 = Volts per bit = 0.003363075
    #define VBAT_PER_BITS 0.003363075  
    #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
    #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
    int batteryPcnt = 0;                              // Calc value for battery %
    int batLoop = 0;                                  // Loop to help calc average
    int batArray[3];                                  // Array to store value for average calc.
    int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
    //=========================
    
    void setup()  
    { 
     analogReference(INTERNAL);             // For battery sensing
    
      delay(500); // Allow time for radio if power used as reset
      
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      metric = getConfig().isMetric;
    }
    
    void presentation()  
    { 
      // Send the Sketch Version Information to the Gateway
     // Send the Sketch Version Information to the Gateway
      sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }
    
    void loop()      
    {  
      delay(500); // Allow time for radio if power used as reset
      delay(dht.getMinimumSamplingPeriod());
     
      // Fetch temperatures from DHT sensor
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      // Fetch humidity from DHT sensor
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
      int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
          send(LightMsg.set(lightLevel));
          lastLightLevel = lightLevel;
      }
          
      batM();
      sleep(SLEEP_TIME); //sleep a bit
    }
    
    void batM() //The battery calculations
    {
       delay(500);
       // Battery monitoring reading
       int sensorValue = analogRead(BATTERY_SENSE_PIN);    
       delay(500);
       
       // Calculate the battery in %
       float Vbat  = sensorValue * VBAT_PER_BITS;
       int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
       Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
       
       // Add it to array so we get an average of 3 (3x20min)
       batArray[batLoop] = batteryPcnt;
      
       if (batLoop > 2) {  
         batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
         batteryPcnt = batteryPcnt / 3;
     
       if (batteryPcnt > 100) {
         batteryPcnt=100;
     }
     
         Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
           sendBatteryLevel(batteryPcnt);
           batLoop = 0;
          }
         else 
         {
         batLoop++;
         }
    }
    
    Troubleshooting

  • 💬 Easy/Newbie PCB for MySensors
    markjgabbM markjgabb

    @mfalkvidd ahhhhh That answers my question perfectly....i was just dumping it into notepad ++ ill try that first thing in the morning.

    OpenHardware.io mysensors battery easy newbie pcb mysx

  • What did you build today (Pictures) ?
    markjgabbM markjgabb

    thanks to assistance of some of the people here i now have up and running a front gate controller for my double front gates (Solar powered)

    now have a node that monitors the batteries, knows if the gate is open or closed and has a relay for activating the gate

    General Discussion

  • loungeroom sketch transport failure
    markjgabbM markjgabb

    @sundberg84 solved the light sensitivity level by swapping the 10k for a 100k...
    makes it more acurate in lighter enviroments, but less so in dark enviroments

    but by my theory after its a little dim im counting it as dark all the way to full dark for lighting purposes anyway

    cheers for all your help....

    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