Helps to find your surrounding's light value (for android only) using device light sensor

Overview

react-native-ambient-light-sensor

Helps to find your surrounding's light value (in lux unit) (for android only) using device light sensor

Installation

npm install react-native-ambient-light-sensor

Usage

import { startLightSensor, stopLightSensor } from 'react-native-ambient-light-sensor';
import { View, Text, DeviceEventEmitter } from 'react-native';

// ...

export default function App() {
  const [result, setResult] = React.useState<number | undefined>();

  useEffect(() => {
      startLightSensor();
      
      const subscription = DeviceEventEmitter.addListener(
        'LIGHT_SENSOR',
        (data: { lightValue: number }) => {
            setResult(data.lightValue);
        },
    );

    return () => {
        stopLightSensor();
        subscription?.remove();
    };
  }, []);

  return (
    <View>
      <Text>Light Result Value: {result}</Text>
    </View>
  );
}

Use case

You can apply any logic of your own based on the surrounding's light condition. For example, to auto turn on your device's flash/torch light if the surrounding environment is dark/dim.

Important Note

The primary sensor data type for ambient light sensors is illuminance in lux (lumens per square meter). Use the data from below table to find and apply logic to your application accordingly.

The following example data set represents rough thresholds for common lighting conditions, and the corresponding lighting step. Here, each lighting step represents a change in lighting environment.

Lighting condition From (lux) To (lux)
Pitch Black 0 10
Very Dark 11 50
Dark Indoors 51 200
Dim Indoors 201 400
Normal Indoors 401 1000
Bright Indoors 1001 5000
Dim Outdoors 5001 10,000
Cloudy Outdoors 10,001 30,000
Direct Sunlight 30,001 100,000
Note: This data set is for illustration and may not be completely accurate for all users or situations.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

You might also like...
Alkatraz is an app that helps you to Reach your goals by managing your Habits .
Alkatraz is an app that helps you to Reach your goals by managing your Habits .

Alkatraz - Build healthy habits for healthy life Alkatraz is an app that helps you to Reach your goals by managing your Habits . It's makes your life

Source code of JekyllEx Android App which can manage your Jekyll blog directly from your Android device!
Source code of JekyllEx Android App which can manage your Jekyll blog directly from your Android device!

JekyllEx Android App Built with ❤︎ by Gourav Khunger 🚀 Introduction JekyllEx is an Android App that allows you to manage a Jekyll Blog directly from

Manage your torrents from your Android device with Transdroid.
Manage your torrents from your Android device with Transdroid.

All popular clients are supported: µTorrent, Transmission, rTorrent, Vuze, Deluge, BitTorrent 6, qBittorrent, and many more. You can view and manage running torrents and individual files. Adding is easy via the integrated search or RSS feeds (full version required). Monitor progress using the home screen widget or background alarm service.

Tournant is a Gourmand/Gourmet recipe parser which serves your dishes on your Android device

Tournant Gourmand/Gourmet recipe parser Website: tournant.zimbelstern.eu Tournant serves your favorite dishes on your Android device! With Tournant, y

NamelessnessR is a vpn hub that combines a number of vpn protocols to provide a hub to a single vpn powerful to protect your privacy only.
NamelessnessR is a vpn hub that combines a number of vpn protocols to provide a hub to a single vpn powerful to protect your privacy only.

NamelessnessR Design concept The Design concept is designed using adobe xd basing of different ideas but mainly Anxray, V2rayNG and NamelessnetX with

NamelessnessR is a vpn hub that combines a number of vpn protocols to provide a hub to a single vpn powerful to protect your privacy only.
NamelessnessR is a vpn hub that combines a number of vpn protocols to provide a hub to a single vpn powerful to protect your privacy only.

namelessnexR Design concept The Design concept is designed using adobe xd basing of different ideas but mainly Anxray, V2rayNG and NamelessnetX with N

You can store all your password, bank details, card details in one place and remember only one master PIN. The application works totally offline.
You can store all your password, bank details, card details in one place and remember only one master PIN. The application works totally offline.

Keep Password An application where you can store all your password, bank details, card details in one place and remember only one master PIN. The appl

KVMapper: A Key-Value Mapper app for MacOS, created with Kotlin and Compose Desktop
KVMapper: A Key-Value Mapper app for MacOS, created with Kotlin and Compose Desktop

KVMapper is an application to convert key-value pairs from one format to another. About This app was purely written in Kotlin and compiled fo

Android common lib demo, include ImageCache, HttpCache, DropDownListView, DownloadManager, install apk silent and so on, you can find description
Android common lib demo, include ImageCache, HttpCache, DropDownListView, DownloadManager, install apk silent and so on, you can find description

android-demo 关于我,欢迎关注 微博:Trinea 主页:trinea.cn 邮箱:trinea.cn#gmail.com 微信:codek2 依赖:trinea-android-common android-auto-scroll-view-pager viewpager-indica

Comments
  • light sensor returns empty value

    light sensor returns empty value

    Hi, I have created new react native app and installed this package, I am using the example code from the readme file.

    When I run the code light sensor returns empty value. I am currently testing on the physical device.

    Do I need to configure anything else?

    opened by chiragparekh 6
Releases(v1.0.2)
Owner
Shayan Chatterjee
Software Engineer | Kalinga Institute of Industrial Technology(KIIT) | CSE
Shayan Chatterjee
M-OV-ies - An Android Application that helps users find where to stream their favorite movies

Stream-ON Video Demo: Description: Final Project for CS50 - 2021: An Android App

null 0 Jan 1, 2022
HostelMate - A Need For Hosteler (An Android App that helps students to find the best resource like hostels and tiffin centers etc.)

Android-Study-Jams-Hostel-Mate HostelMate - A Need For Hosteler (An Android App that helps students to find the best resource like hostels and tiffin

null 2 Feb 28, 2022
Ride hailing app that helps users find drivers and take them from point A to point B.

Ride-hailing_rider_app Ride hailing app that helps users find drivers and take them from point A to point B. What I Used ? Clean Architecture : Basica

Oucif Mohammed 2 Aug 26, 2022
IND appointment checker helps you to find some available slots in IND website.

IND Appointment Checker What is IND? The Immigration and Naturalisation Service (IND) assesses all residence permit applications from the people who w

Ufuk Halis 3 Oct 18, 2022
Wiped is a wiping app that helps you to delete a file permanently from your device

Wiped Wiped is a wiping app that helps you to delete a file permanently from your device. How Is It Done? Did you know that when you delete a file in

null 1 May 16, 2022
HyperUPnP is Android Application that lets you to Stream Media from PC, NAS or any other device running UPnP/DLNA compliant media server to your Android Device.

Hyper UPnP Android UPnP/DLNA client Stream Media from PC, NAS or any other device running UPnP/DLNA compliant media server to your Android Device. Int

Var Bhat 8 Jul 17, 2022
Android Sensor Based App

Sensor-Team Sensor Based Mobile Applications Make sure you have the latest version of android studio There are no api keys that need to be generated n

Georg Vassilev 0 Oct 15, 2021
Xposed-based motion simulator with sensor support.

This project is under active development MotionEmulator Android motion simulator with sensor support. Scenarios If you study in universities in China,

ZhuFu 26 Dec 24, 2022
Find your dream Job - built with MVVM ,GraphQL ,Glide, Shimer

nextJob Find your dream Job The idea of the application is to help users find job opportunities and internships that exist on the internet in an organ

inaciosacataria 3 Mar 18, 2022
Find your new favorite wallpaper that looks just like you 🖌️

Wollpaper Find your new favorite wallpaper that looks just like you. Builds The pre-built app can be downloaded under "releases" on the right side of

Vinícius Resende 2 May 16, 2022