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
stockenS

stocken

@stocken
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Using the "Selector switch" in Domoticz (tutorial)
    stockenS stocken

    Greetings!

    So i have a ledstrip and i am using your sketch straight off.
    I do not have a physical button connected, but the code for the button is still there.

    I have setup a Selector Switch in domoticz like in your example, but i doesnt work with the values 2,3,4 etc. the patterns doesnt start.
    If i change it to http://192.168.1.30:8090/json.htm?type=command&param=switchlight&idx=157&switchcmd=Set Level&level=25 i get the alarm blinking red and white.

    what are the values for each pattern in your "moodlight" sketch?
    Or do i have to add something to the sketch for it to work?

    Domoticz

  • 3-in-1 Humidity Temp and Motion
    stockenS stocken

    Hi,
    I took your updated code for 2.0 and tried to add a relay.
    The code looks like this:

    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 10
    #define CHILD_ID_TEMP 11
    #define CHILD_ID_MOT 12 //motion sensor
    
    
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    
    #define RELAY_1  7  // 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 CHILD_ID 5
    #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
    
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    
    unsigned long interval= 3000;//dht.getMinimumSamplingPeriod(); // the time we need to wait
    unsigned long previousMillis=0; // millis() returns an unsigned long.
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED); //me
    
    
    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()  
    { 
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
     // metric = getConfig().isMetric;
    
     pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()  
    { 
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo("4-1 Sensor", "1.0");
    
      // 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_MOT, V_TRIPPED); //me
      
      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);
    	}
    }
    
    void loop()      
    {  
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
       
    // only run loop if time has passed. 
    unsigned long currentMillis = millis(); // grab current time       
    
     // check if "interval" time has passed
     if ((unsigned long)(currentMillis - previousMillis) >= interval) {
    
     
           send(msgMot.set(tripped?"1":"0")); 
                  
      
          #ifdef MY_DEBUG
           Serial.print("Motion: ");
           Serial.println(tripped);
          #endif
    
    
    
     
      
      // 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;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        }
        send(msgTemp.set(temperature, 1));
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      }
     
      // 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));
          #ifdef MY_DEBUG
          Serial.print("H: ");
          Serial.println(humidity);
          #endif
      }   
    
    
    
    
       // save the "current" time
       previousMillis = millis();
    
     }  
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      //sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    
    }
    
    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());
    	}
    }
    

    However, when i look in domoticz the relay isnt presented as a child.
    Plus, the motion sensor is called "S_LIGHT_LEVEL" and not "S_MOTION" as it does in my other device (that only have temp, hum motion and not a relay in the sketch).
    temp/hum sensor and motion sensor works as intended in domoticz.
    My first though is that the motion and relay somehow is a bit mixed up by the sketch, but im kinda new to this so im not sure.
    Would really appreciate if someone can look at the sketch and see if there is any obvious problem :)

    My Project motion 3 in 1 temp humidity

  • 💬 Relay
    stockenS stocken

    greetings, i have an idea to use a 12volt fan to move some air from one room to the room next to it (the first room has a stove for heating).
    and i was thinking a relay would do the trick so i dont manually have to start it (and a nice script in domoticz that uses the data from the temp sensor + the ability to manually turn it on/off in domoticz).
    now to my question: which relay should i get?
    I looked at the ones in the store but it seems they are either for 230VAC or 5VDC

    Announcements
  • Login

  • Don't have an account? Register

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