- Use with Raspberry Pi
- Requires lgpio
- Code tested inside virtual Raspberry Pi Zero/3/4 environments on GitHub
#include "BH1750.h"
#include <iostream>
int main() {
BH1750::BH1750 sensor;
sensor.connect();
std::cout << sensor.lux() << std::endl;
return 0;
}
After writing your own code (eg. main.cpp), compile and link with the lgpio library as follows:
pi@raspberrypi:~ $ g++ -Wall -o prog main.cpp -llgpio