Skip to content

General Discussion

1.6k Topics 14.2k Posts

A place to talk about whateeeever you want

  • Buzzer when door opened longer than X seconds

    3
    0 Votes
    3 Posts
    2k Views
    ChakkieC
    @Boots33 Thanks for the help. The main problem was how to set the time when the doors are opened. I have tried several attempts and everytime the timer is reset. Therefore the buzzer will never be triggered because the timer and the current time is always the same. I have solved this problem. The working script is here below: #include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define CHILD_ID_Koel 31 #define CHILD_ID_Vries 32 #define BUTTON_PIN_Koel 7 // Arduino Digital I/O pin for button/reed switch #define BUTTON_PIN_Vries 8 // Arduino Digital I/O pin for button/reed switch #define INTERRUPT BUTTON_PIN_Koel -2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define INTERRUPT BUTTON_PIN_Vries -2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define buzzPin 2 // I/O-pin from buzzer connects here unsigned long currentMillisKoel; unsigned long currentMillisVries; MySensor gw; Bounce debouncerKoel = Bounce(); Bounce debouncerVries = Bounce(); int oldValueKoel = -1; int oldValueVries = -1; int KoelBuzz = 0; int VriesBuzz = 0; unsigned long DoorDelay = 5000UL; unsigned long KoelTimer = 0UL; unsigned long VriesTimer = 0UL; MyMessage msgKoel(CHILD_ID_Koel, V_TRIPPED); MyMessage msgVries(CHILD_ID_Vries, V_TRIPPED); void setup() { gw.begin(NULL, 204, false, 0); // Setup the button pinMode(BUTTON_PIN_Koel, INPUT); pinMode(BUTTON_PIN_Vries, INPUT); //Buzz pin pinMode(buzzPin, OUTPUT); digitalWrite(buzzPin, HIGH); // Activate internal pull-up digitalWrite(BUTTON_PIN_Koel, HIGH); digitalWrite(BUTTON_PIN_Vries, HIGH); // After setting up the button, setup debouncer debouncerKoel.attach(BUTTON_PIN_Koel); debouncerVries.attach(BUTTON_PIN_Vries); debouncerKoel.interval(5); debouncerVries.interval(5); // Register binary input sensor to gw (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. gw.present(CHILD_ID_Koel, S_DOOR); gw.present(CHILD_ID_Vries, S_DOOR); } // Check if digital input has changed and send in new value void loop() { // Fridge door script debouncerKoel.update(); // Get the update value int valueKoel = debouncerKoel.read(); if (valueKoel != oldValueKoel) { // Send in the new value gw.send(msgKoel.set(valueKoel == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0 oldValueKoel = valueKoel; KoelBuzz = digitalRead(BUTTON_PIN_Koel); Serial.println(KoelBuzz); if (KoelBuzz == LOW) { //Door is open. KoelTimer = millis(); // Set the time. Serial.println(KoelTimer); } } // check how long the doors are opened unsigned long currentMillisKoel = millis(); if ((currentMillisKoel - KoelTimer) >= DoorDelay && KoelBuzz == LOW) { // Serial.println("Counter start"); // Serial.println(KoelTimer); // Serial.println(currentMillisKoel); digitalWrite(buzzPin, KoelBuzz); // Tone ON // Serial.println("Buzzer triggerd"); } // Freezer door script debouncerVries.update(); // Get the update value int valueVries = debouncerVries.read(); if (valueVries != oldValueVries) { // Send in the new value gw.send(msgVries.set(valueVries == HIGH ? 0 : 1)); // change this value to if NC then 0 : 1; if NO then 1 : 0 oldValueVries = valueVries; VriesBuzz = digitalRead(BUTTON_PIN_Vries); Serial.println(VriesBuzz); if (VriesBuzz == LOW) { //Door is open. VriesTimer = millis(); // Set the time. Serial.println(VriesTimer); } } if (VriesBuzz && KoelBuzz == HIGH) { digitalWrite(buzzPin, VriesBuzz); // Tone OFF } // check how long the doors are opened unsigned long currentMillisVries = millis(); if ((currentMillisVries - VriesTimer) >= DoorDelay && VriesBuzz == LOW) { // Serial.println("Counter start"); // Serial.println(VriesTimer); // Serial.println(currentMillisVries); digitalWrite(buzzPin, VriesBuzz); // Tone ON // Serial.println("Buzzer triggerd"); } // Sleep until interrupt comes in on motion sensor. Send update every two minute. // gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); // Serial.println("sleep"); }
  • Relay and Repeater - Just learning stuff

    4
    0 Votes
    4 Posts
    5k Views
    jl277013J
    Do I need to link/pair the repeater node to the gateway or does it just work when I power it up?
  • Sense if my Kitchen hood is running?

    house ventilation electrical consumer sensor
    6
    0 Votes
    6 Posts
    3k Views
    hugowsH
    What about a vibration sensor? At least in my kitchen, the fans do produce a slight vibration to the metal roof thing. They pretty cheap on Ebay, I must try it myself...
  • Safety first ;-)

    4
    2 Votes
    4 Posts
    2k Views
    YveauxY
    @Oitzu Hehe! Nope, but both were wrapped in huge antistatic bags, one could camp in :joy:
  • Dimensional Sensor

    3
    0 Votes
    3 Posts
    1k Views
    Andres LanzaA
    @parachutesj Thank you so much, I will check it out.
  • 4 channel AC dimer.

    2
    0 Votes
    2 Posts
    2k Views
    AWIA
    @csa02221862 A nice board if you look at the total package. However these are basic triac dimmer circuits (AC) with optocoupler isolation. You need to be aware that the steering circuit (arduino/ raspberry) needs to take care of the zero cross detection and firing of the triacs. It has been discussed a few times on this forum. Basically a circuit like this: [image: 0_1464201525816_upload-345bd0ae-15a9-4ba8-bea9-6b3ded0d6012] Where the upper part measures the "AC sine wave" (needed only once) and the part below the steering circuit (to be repeated for each channel) Building it with Ailexpress parts should not cost you more than €/$ 1 per channel. But as I said you don't get the complete assembled package)
  • Forum Creation here is nuts

    3
    0 Votes
    3 Posts
    2k Views
    A
    Do you really spend that much time writing responses? if your neck is aching from looking at the box then your screen isn't setup properly.
  • Why is the the DIY PCBs on openhardware.io so expensive?

    9
    0 Votes
    9 Posts
    2k Views
    hekH
    Not at the moment. There is still only a few boards where the author has activated sales function. When this number grows, I'll add some more filters. https://www.openhardware.io/explore#view=forSale
  • Some clarification on Presentation, Set, Req et al

    1
    0 Votes
    1 Posts
    659 Views
    No one has replied
  • Reboot Node

    reboot node id watchdog
    2
    0 Votes
    2 Posts
    4k Views
    AWIA
    @dzairo search the Web for rebooting arduino from code. There are many ways each with its own (dis) advantages.
  • ACKs... Scarce information

    8
    0 Votes
    8 Posts
    3k Views
    hekH
    You only need to enable if if you actually use the resulting ack message for something. If you look at the RelayWithButton example you can see an example of how the local relay only get updated when the ack is received (after pressing the local button).
  • Send directly and to gateway

    1
    0 Votes
    1 Posts
    735 Views
    No one has replied
  • Using mqttGateway2.pl for Serial to MQTT on RaspberryPI

    31
    0 Votes
    31 Posts
    12k Views
    R
    Not sure I'm doing this right way, but changing this line: fh => $serialDevice->{'HANDLE'}, to this line fh => new_from_fd IO::Handle ($serialDevice->{FD}, "w"), Fixed Filehandle GEN0 opened only for input bug for me on RPi 2. Fix works because of $serialDevice->{'HANDLE'} is opened as read only in SerialDevice and should not be used for write: # a handle object for ioctls: read-only ok $self->{HANDLE} = new_from_fd IO::Handle ($self->{FD}, "r");
  • Ideas to detect car traffic in a driveway?

    10
    1 Votes
    10 Posts
    5k Views
    D
    @mfalkvidd Thanks. That explains it all pretty perfectly.
  • Uno as serial gateway? Can it also be a sensor node?

    7
    0 Votes
    7 Posts
    2k Views
    rollercontainerR
    I've got a MQTTClientGateway using an Uno with DHT22 sensor attached. It's working for weeks without problems.
  • AIRCRAFT VHF TRANSCEIVER PROJECT

    5
    0 Votes
    5 Posts
    2k Views
    stevemS
    @bjacobse RF circuit is mine, based on many simulations etc., so I can't fall back on 3rd party designs. Yes, it will have to be certified globally, as much as possible. I've been involved with the approval cycle in the past, so I'm familiar with how this works. I'm too old for financial involvements with other people, so I'll just have to see what "shakes out". I'm "beating the bushes" now for potential manufacturers who may want to procure the design outright. Thanks for your input.
  • Dumb beginner conceptual question...

    3
    0 Votes
    3 Posts
    1k Views
    172pilot1
    Thanks.. I did break down and order 10 of the nrf radios last night... should be here tomorrow.. In thinking it through more, it seems that it's shortsighted of me to want everything on Wifi just because it's familiar.. I'd end up needing eventually to possibly expand my subnet, have to be reliant on an access point that is probably being killed by my son playing online games, etc.. I'm sure there's a learning curve to the NRFs, but from what I read about their low power requirements and the advantage of all of the self healing, it seems it's the right way to go.. Thanks for the info!
  • Codebender on ipad hiding code

    8
    0 Votes
    8 Posts
    2k Views
    mfalkviddM
    Found it! Thanks a million!
  • question about serial data

    4
    0 Votes
    4 Posts
    1k Views
    mfalkviddM
    No worries. There is a reason it is called FAQ - lots of people ask that question :-)
  • Where do I set the sensor ID?

    6
    0 Votes
    6 Posts
    3k Views
    mfalkviddM
    Great that it worked. Thanks for reporting the result :)

13

Online

12.4k

Users

11.2k

Topics

113.4k

Posts