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

  • Don't have an account? Register

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