Navigation

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

    Topics created by ago1980

    • ago1980

      I can not switch off from Home assistant
      Home Assistant • • ago1980  

      1
      0
      Votes
      1
      Posts
      464
      Views

      No one has replied

    • ago1980

      help modify code
      Domoticz • • ago1980  

      1
      0
      Votes
      1
      Posts
      646
      Views

      No one has replied

    • ago1980

      relay as a switch not as a button (domoticz)
      Domoticz • • ago1980  

      25
      0
      Votes
      25
      Posts
      5631
      Views

      zrom69

      thanks for the work you did i add the motion sensor and light level sensor its not working well you can help me thank you /* Relay with toggle switch sketch modified to work with no uplink to gateway Toggle switch connected between pin3 and ground. */ #define MY_DEBUG // Enable debug prints to serial monitor #define MY_RADIO_NRF24 // Enable and select radio type attached #define MY_TRANSPORT_WAIT_READY_MS 5000 //set how long to wait for transport ready in milliseconds #include <MySensors.h> #include <Bounce2.h> #define CHILD_ID_LEVEL A0 #define RELAY_PIN 5 // Arduino Digital I/O pin number for relay #define SWITCH_PIN 4 // Arduino Digital I/O pin number for switch #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 #define CHILD_ID_MOT 2 //motion sensor #define CHILD_ID_LEVEL 3 #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); int oldswitchState = 0; bool state = false; bool firstStart = true; int photocellPin = 0; // The photoresistor and resistance 10 / 12KOhms connected on the pin / analog pin A0 int photocellReading; unsigned long interval= 6000;//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 msg(CHILD_ID, V_STATUS); MyMessage msgMot(CHILD_ID_MOT, V_TRIPPED); MyMessage msgLight(CHILD_ID_LEVEL, V_LIGHT_LEVEL); void setup(){ pinMode(SWITCH_PIN, INPUT_PULLUP); // Setup the button pin, Activate internal pull-up debouncer.attach(SWITCH_PIN); // After setting up the button, setup debouncer debouncer.interval(5); pinMode(RELAY_PIN, OUTPUT); // set relay pin in output mode digitalWrite(RELAY_PIN, RELAY_OFF); // Make sure relay is off when starting up } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Relay & Toggle", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_BINARY); present(CHILD_ID_LEVEL, S_LIGHT_LEVEL); present(CHILD_ID_MOT, V_TRIPPED); //me } void loop(){ if (firstStart) { // this code is only run once at startup debouncer.update(); oldswitchState = debouncer.read(); // set oldswitchState to the current toggle switch state send(msg.set(false), false); // notify controller of current state no ack firstStart = false; // set firstStart flag false to prevent code from running again } debouncer.update(); int switchState = debouncer.read(); // Get the update value if (switchState != oldswitchState) { // check for new throw of toggle switch state = !state; // Toggle the state digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF); // switch the relay to the new state send(msg.set(state), false); // notify controller of current state no ack oldswitchState = switchState; } // 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")); photocellReading = analogRead(photocellPin)/10; // Conversion en 100% (approximatif) // Valeur de la photorésistance avec lampe torche devant = ~1000 Serial.print("Luminosité : "); Serial.println(photocellReading); send(msgLight.set(photocellReading, 1)); if(tripped == 1 && photocellReading < 30) // Si la luminosité est inférieure à 30% #ifdef MY_DEBUG Serial.print("Motion: "); Serial.println(tripped); #endif } } /-------------------start of functions--------------------------/ void receive(const MyMessage &message) { if (message.type == V_STATUS) { // check to see if incoming message is for a switch state = message.getBool(); // get the new state digitalWrite(RELAY_PIN, state ? RELAY_ON : RELAY_OFF); // switch relay to new state /*---- Write some debug info----*/ Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
    • ago1980

      Help Relay Example with button
      Domoticz • help relay example with button • • ago1980  

      3
      0
      Votes
      3
      Posts
      1169
      Views

      ago1980

      @Boots33 Thanks a lot works
    • ago1980

      You can send value to the lcd and domoticz gateways?
      Domoticz • domoticz • • ago1980  

      1
      0
      Votes
      1
      Posts
      954
      Views

      No one has replied