Giter VIP home page Giter VIP logo

light_sensor's Introduction

light_sensor

Control a smart bulb with raspberry pi sensors.

The project uses a PIR sensor to detect movement and a photo transistor to measure ambient light. When movement and ambient light below the threshold set are deteced simultaneously, the bulb is switched on for 10 minutes. During that 10 minutes, if further movement is detected, the time until switch off will be pushed forward to ten minutes from that time. If no movement is detected for ten minutes the bulb is swtiched off.

Initial brightness is determined by calculating the percentage by which the current light measurement is below the threshold, e.g. if the threshold is 0.05 and the measurement is 0.0375, the bulb will switch on with 25% brightness. After being switched on, the sensor will continously measure light levels. If the ambient light level is above/below the threshold, the current brightness will be decreased/increased by 5%. The incremental change is to prevent sudden large changing in brightness. The threshold can be adjusted with a variable resistor on the board.

The raspberry pi communicates with the bulb using the LIFX API (https://api.developer.lifx.com), though can potentially work with any smart bulb brand with a public api.

The photo transistor output is analog. As the raspberry pi does not have any analog inputs as standard, a MCP3008 analog to digitial converter was used (https://learn.adafruit.com/mcp3008-spi-adc/python-circuitpython). An easier but more expensive solution would an Explorer Hat, which provides 4 analog input channels.

Potential Improvements Adjust bulb colour based on a temperature sensor

light_sensor's People

Contributors

destructodd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.