Navigation

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

    Posts made by Graham

    • RE: ESP8266gateway with sensor

      Here is my code for doing something equivalent. You seem to have the pinMode line missing in setup()

      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup() { 
        pinMode(MOTION_SENSOR_PIN, INPUT_PULLUP);      // sets the motion sensor digital pin as input
      }
      
      void presentation() {
        // Present locally attached sensors here    
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor", "1.1");
      
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
      }
      
      boolean pinstate = false;
      
      void loop() {
        boolean newstate = (digitalRead(MOTION_SENSOR_PIN) == HIGH);
        if (newstate != pinstate) {
          if (newstate == true) {
            send(msg.set("1"));
            Serial.println("Motion Started");
            pinstate = newstate;
          } else {
            send(msg.set("0"));
            Serial.println("Motion Stopped");
            pinstate = newstate;
          }
        }
      }
      
      posted in Hardware
      Graham
      Graham
    • RE: 💬 Motion Sensor

      @ben999 The sketch you have will report the state of the pin every 2 minutes as well as when interrupted by motion.

      If the SR501 is still within its timeout after the last motion detected, the pin will still be high. Eventually, (the maximum length of time is about 10 minutes) the pin should go low. If it doesn't, there is a fault with the SR501.

      The timeout can be adjusted by one of the dials (see http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-hc-sr501-motion-sensor-tutorial/#Time_Delay_Adjustment). I'm not sure what the shortest period is, but it is probably less than two minutes, which would send 0 in the next message.

      You would, however, get another interrupt if more motion occurred before the two minutes are up.

      posted in Announcements
      Graham
      Graham
    • RE: 💬 Motion Sensor

      So my notification board gets a new entry every two minutes...

      The SLEEP_TIME define tells your board to wake up every two minutes regardless of whether there is an interrupt. If you want longer, increase this value. I think you can also set it to 0 to only wake on interrupts.

      posted in Announcements
      Graham
      Graham
    • RE: 💬 Building a Raspberry Pi Gateway

      I would like to try this, but my pins19-23 are already used by other hardware. Has anyone tried using the SPI1 Pins?

      posted in Announcements
      Graham
      Graham
    • RE: 💬 Building a MQTT Gateway

      I have set up an MQTT gateway running on a Wemos D1, and a motion sensor running on an arduino nano.

      It seems to work successfully, but I had to define MY_NODE_ID in the sensor sketch because the negotiation for this is done by the controller. Presumably, I'm going to have to program my controller to respond to the mqtt message being sent to negiotiate the id, but I cannot find any documentation on the correct reply. Does someone have a link?

      The mqtt message being sent to negotiate the node id was

      mygateway1-out/255/255/3/0/3 (null)
      
      posted in Announcements
      Graham
      Graham