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
GrahamG

Graham

@Graham
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • ESP8266gateway with sensor
    GrahamG Graham

    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;
        }
      }
    }
    
    Hardware

  • 💬 Motion Sensor
    GrahamG Graham

    @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.

    Announcements

  • 💬 Motion Sensor
    GrahamG Graham

    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.

    Announcements

  • 💬 Building a Raspberry Pi Gateway
    GrahamG Graham

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

    Announcements

  • 💬 Building a MQTT Gateway
    GrahamG Graham

    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)
    
    Announcements
  • Login

  • Don't have an account? Register

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