JULA motion LED hack



  • 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);
    }
    


  • Soooo what does it do?



  • Ehh, detect motion 😃



  • Ohh haha ok now I get it.

    Nice!



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



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


Log in to reply
 

442
Online

6.7k
Users

7.6k
Topics

80.5k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.