Git Product home page Git Product logo

spark-als's Introduction

spark-als

This project contains open-source firmware for an USB HID Ambient Light Sensor (ALS) implementation using Digispark Attiny85-based microcontroller development board and BH1750FVI I2C light sensor module.

Fork

This repository is a fork of 3cky/tiny-hid-als. Their work inspired my project, which aims to improve on:

Functionality

My project extends the functionality of the ALS sensor, for example introducing support for absolute and relative thresholding and reporting more information about the sensor to the driver.

Adhering to standard

The original project did not follow Microsoft's requirements for ALS sensors, meaning there wasn't any guarantee that functionality such as automatic brightness will work. I tried to change that to the best of my understanding of the official sensor implementation guide (here, here, here and here). Theoretically, the project should now pass WHQL certification.

Resolution

My project increases the sampling resolution to about 0.15 lux. This increases the usability of the sensor in dark conditions, while also making it possible to detect very small fluctuations of light across the whole spectrum. It is possible to drive down the resolution to 0.11 lux, but this limits the dynamic range under the required 10,000 lux for auto brightness control in Windows.

Code size and RAM usage

My project reduces the code size (it is around 17% smaller), while at the same time incorporating significantly more code logic. This is largely due to creating my own extremely lightweight library for communication with the sensor from the ground up, making use of felias-fogg/SoftI2CMaster more efficient I2C implementation instead of widely used Wire.h, and using zero-overhead constexpr functions for pre-calculating parts of formulas for conversion of values in compile time. The code size could potentially be reduced even further, for example by using fixed-point decimal library instead of floats, or focusing on rewriting main logic for code size, but there shouldn't be a need as it fits onto Attine85 with ease.

Documentation

I tried to explain the functionality of the project in the code through comments. Extra attention is added to the new sensor library, making it easy to change parameters, if necessary.

Issues

Please feel free to create an issue if you discover a bug, or discuss if you think I misinterpreted the standard. I tried to debug with all tools available to me, but this is my first bigger project implementing HID device and mistakes could have been made.

Schematic

Digispark connected to BH1750

OS support

USB HID sensors framework is supported out of the box since Linux 3.7 and Windows 8.

Compiling and installing

First, please install PlatformIO open source ecosystem for IoT development compatible with Arduino code and its command line tools (Windows, MacOs and Linux). Also, you may need to install git in your system.

Note: with platformIO you don't need the Arduino IDE and install libraries, this will do it for you.

Compiling and installing:

pio run --target upload

Note: you need connect your Digispark after each compiling for upload the new firmware or reset it. More info here.

License

This project is distributed with GPL license, see LICENSE file for more informations.

spark-als's People

Contributors

3cky avatar matejkocourek avatar

Stargazers

 avatar  avatar Petrus Claviger avatar

Watchers

 avatar

spark-als's Issues

Compiling issue

Hello
i'm getting error while compiling:

src\main.cpp: At global scope:
src\main.cpp:208:23: error: too many initializers for 'const unsigned char [316]'
HID_END_COLLECTION};
^
*** [.pio\build\digispark-tiny\src\main.cpp.o] Error 1

image

Any idea how to fix that?

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.