Using Sensors and Pi

I’m used to using sensors on Arduino, but having problems understanding use on Pi. It seems Processing has GPIO function, but it isn’t clear to me whether you can hook up a Lux sensor (like TSL2561) to the Pi and expect it to read values using Processing (especially since sensors usually require a specific library). So far I’m only seeing Python scripts for sensors without using Processing for Pi.

My end use is having a light sensor trigger video (using Processing’s GL Video). So, being able to exclude an Arduino would be nice.

Not much experience with r-pi but I believe the following links could provide you some insight of what needs to be done:

https://pi.processing.org/reference/
https://forum.processing.org/two/discussions/tagged/gpio/p1

External resources:

https://projects.raspberrypi.org/en/projects/introduction-to-processing
https://theraspberryblonde.wordpress.com/2016/07/10/raspberry-pi-gpio-control-with-processing/

Kf

Hi @Zengirl2 - so the TSL2561 uses I2C to communicate with the host computer. You can use Hardware I/O library’s I2C class to talk I2C with the device. If you look at the examples that come with the Hardware I/O library, you’ll find a few whose name start with I2C. Those are not implementing the needed code for your specific device, but should give you a general idea.

If you already have a Python script, than it would only be a manner of taking the I2C related code from there and translating it to something that uses Processing’s I2C class. (That’s generally easier than writing code from scratch looking only at the device’s datasheet - but this can be a fun challenge also.)

If you don’t get around to doing this conversion yourself, post the link to the Python code, and I’ll give it a try.

Great news: Olivier LeDiouris has already implemented support for that sensor using the Hardware I/O library!

Edit: This is now part of the examples that come with the 3.3.7.1 release - it’s called Light_I2C_TSL2561.

Hey, sorry, been busy over the summer and just saw this note. Thanks so much and I will check it out!