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

Last update: Jul 24, 2022

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

GitHub

https://github.com/Cshayan/react-native-ambient-light-sensor
You might also like...

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.

Aug 6, 2022

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

Aug 14, 2022

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

Jan 13, 2022

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

Jan 13, 2022

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

Apr 18, 2022

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

Jun 17, 2022

Protect yourself from being tracked 🌍 by AirTags 🏷 and Find My accessories 📍

Protect yourself from being tracked 🌍 by AirTags 🏷 and Find My accessories 📍

AirGuard - AirTag tracking protection Protect yourself from Find My Tracking The AirTags and other Find My devices are simple, small and perfect to tr

Aug 18, 2022

A manga reader app that can be used save / search / find and read latest manga / manhwa

A manga reader app that can be used save / search / find and read latest manga / manhwa

A manga reader app that can be used save / search / find and read latest manga / manhwa

Nov 20, 2021

Haven is an app to help people in need find resources.

Haven Haven is an app to help people in need find resources. Haven connects people to resources such as food pantries, homeless shelters, healthcare,

Nov 26, 2021
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

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.)
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

Feb 28, 2022
Ride hailing app that helps users find drivers and take them from point A to point B.
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

Oct 26, 2021
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

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

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

Oct 15, 2021
Find your dream Job - built with MVVM ,GraphQL ,Glide, Shimer
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

Mar 18, 2022
Find your new favorite wallpaper that looks just like you 🖌️
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

May 16, 2022
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

May 19, 2022
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

Aug 10, 2022