Skip to content

Connect to a light sensor and return the light lux value.

License

Notifications You must be signed in to change notification settings

DeTonti-Bunker/lux-api

Repository files navigation

Raspberry PI Lux Sensor API

This repository contains a Fastify API server that reads lux values from a light sensor connected to a Raspberry PI.

Prerequisites

Installation

  1. Clone this repo to your Raspberry PI:
git clone https://github.com/DeTonti-Bunker/lux-api.git
  1. Install dependencies:
npm ci
  1. Start the server:
npm run start
  1. Test the API (returns the current lux value from the light sensor):
curl http://localhost:3000/lux
{
  "lux": 11
}

API Endpoints

  • GET /lux: Returns the current lux value from the light sensor
{
  "lux": 11
}
  • GET /lux/max: Returns the maximum lux value possible.
{
  "lux": 188
}
  • GET /lux/min: Returns the minimum lux value possible.
{
  "lux": 0
}

Hardware Setup

Sensor Wiring GPIO Diagram

Refer to the instructions (but make sure to connect the VCC to the 3.3V PIN):

About

Connect to a light sensor and return the light lux value.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published