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
  1. Home
  2. My Project
  3. JULA motion LED hack

JULA motion LED hack

Scheduled Pinned Locked Moved My Project
6 Posts 3 Posters 3.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • EfflonE Offline
    EfflonE Offline
    Efflon
    wrote on last edited by Efflon
    #1

    I found a cheap (€5) battery powered motion sensor LED at jula.se that I couldn't resist to pry open.
    0_1485886713650_anslut.jpg

    Looking at the PCB I found the standard BISS0001 used in most PIR motion sensors.
    0_1485888098919_anslut.pcb.jpg
    I de-soldered LED resistor and the resistor connecting the IC with the transistor causing the LED to shine. The bottom orange cable is the sensor output going HIGH when motion is detected. In this sensor trigger time was set to 25s by a 10K resistor at R2, I have replaced it with a short=0 to only have part of a second output (look at the datasheet for more details). The photo resistor is also removed unless you only want night triggering. Pin 9 on the IC, blue circle, is used to enable/disable the sensor. I have left it untouched, for now.

    Since it's powered by 3xAAA=4,5V I take 3V from the top right VDC regulator (?).

    It all fits just fine in the box..ehh
    0_1485905158978_anslut.done.jpg

    The example motion sketch have been used as base for my code. I have made some small changes. I disable motion detection for 30min after first trigger. I sleep for 6hours before reporting battery level. Interrupt is triggered by RISING.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     *
     * DESCRIPTION
     * Motion Sensor example using HC-SR501
     * http://www.mysensors.org/build/motion
     *
     */
    
    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <MySensors.h>
    #include <Vcc.h>
    
    const float VccMin        = 2.0*0.6;  // Minimum expected Vcc level, in Volts. Example for 2xAA Alkaline.
    const float VccMax        = 2.0*1.5;  // Maximum expected Vcc level, in Volts. Example for 2xAA Alkaline.
    const float VccCorrection = 1.0/1.0;  // Measured Vcc by multimeter divided by reported Vcc
    
    Vcc vcc(VccCorrection);
                            //  h      m      s       ms
    unsigned long SLEEP_TIME =  6UL * 60UL * 60UL * 1000UL; // Sleep time between reports (in milliseconds)
    unsigned long DISABLE_TIME =      30UL * 60UL * 1000UL; // Time until sensor is re-enabled after triggering (in milliseconds)
    #define MOTION_SENSOR_PIN 2   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 0   // Id of the sensor child
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    int wakeup = 0;
    
    void setup()
    {
      pinMode(MOTION_SENSOR_PIN, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()
    {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Motion Sensor", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION, "Motion tripped", true);
    }
    
    void loop()
    {
      // Read digital motion value
      bool tripped = digitalRead(MOTION_SENSOR_PIN) == HIGH;
    
      if (tripped) 
      {
        send(msg.set(1));  // Send tripped value to gw
        send(msg.set(0));  // Send tripped value to gw 
        // Ignore any motion for a set time
        sleep(DISABLE_TIME);
      }
    
      // Send battery level when waking up from long sleep
      if (wakeup == -1)
      {
        uint8_t batteryPcnt = static_cast<uint8_t>(0.5 + vcc.Read_Perc(VccMin, VccMax));
        // Send battery level, used as heartbeat of the sensor
        sendBatteryLevel(batteryPcnt);
      }
      
      // Sleep until interrupt comes in on motion sensor. Send update every two minute.
      wakeup = sleep(digitalPinToInterrupt(MOTION_SENSOR_PIN), RISING, SLEEP_TIME);
    }
    
    1 Reply Last reply
    6
    • pansenP Offline
      pansenP Offline
      pansen
      wrote on last edited by
      #2

      Soooo what does it do?

      Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

      1 Reply Last reply
      0
      • EfflonE Offline
        EfflonE Offline
        Efflon
        wrote on last edited by
        #3

        Ehh, detect motion :smiley:

        1 Reply Last reply
        1
        • pansenP Offline
          pansenP Offline
          pansen
          wrote on last edited by
          #4

          Ohh haha ok now I get it.

          Nice!

          Orange Pi Plus 2e connected to nrf24 PA via SPI running git-development MySensors gateway, OpenHAB2, mosquitto and MySQL persistence.

          1 Reply Last reply
          1
          • engyE Offline
            engyE Offline
            engy
            wrote on last edited by
            #5

            Cool! What is the consumption of the node and how long batteries last?

            EfflonE 1 Reply Last reply
            0
            • engyE engy

              Cool! What is the consumption of the node and how long batteries last?

              EfflonE Offline
              EfflonE Offline
              Efflon
              wrote on last edited by
              #6

              @engy I never let the sensor stay for to long since it was so ugly and seemed to drain my batteries fast. What I eventually did was restore it to its original state with a light and light-sensor and powered with a usb charger. Now when motion is detected an event with the light intensity is sent to my HASS server, who then decides if the light should turn on or not....

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              19

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

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