This repository contains a Fastify API server that reads lux values from a light sensor connected to a Raspberry PI.
- Raspberry PI (Tested with 4 Model B)
- Light sensor module cqrobot wiki TSL2491X_Light_Sensor
- Node.js and npm installed on the Raspberry pi
- Clone this repo to your Raspberry PI:
git clone https://github.com/DeTonti-Bunker/lux-api.git
- Install dependencies:
npm ci
- Start the server:
npm run start
- Test the API (returns the current lux value from the light sensor):
curl http://localhost:3000/lux
{
"lux": 11
}
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
}
Refer to the instructions (but make sure to connect the VCC to the 3.3V PIN):
- Light sensor module cqrobot wiki TSL2491X_Light_Sensor