# Using Sensors and Pi

**URL:** <https://discourse.processing.org/t/using-sensors-and-pi/1189>\
**Category:** Processing for Pi\
**Created:** [June 23, 2018, 8:12pm UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189 "2018-06-23T20:12:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zengirl2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zengirl2/32/448_2.png) [@Zengirl2](https://discourse.processing.org/u/Zengirl2)\
**Post date:** [June 23, 2018, 8:12pm UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189/1 "2018-06-23T20:12:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 24, 2018, 2:38am UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189/2 "2018-06-24T02:38:03Z")

</div>

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

> [Reference - Processing for Pi](https://pi.processing.org/reference/)  
> [Tagged with gpio - Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussions/tagged/gpio/p1)

External resources:

> [https://projects.raspberrypi.org/en/projects/introduction-to-processing](https://projects.raspberrypi.org/en/projects/introduction-to-processing)  
> [Raspberry Pi GPIO Control With Processing – The Raspberry Blonde](https://theraspberryblonde.wordpress.com/2016/07/10/raspberry-pi-gpio-control-with-processing/)

Kf

---

<div class="post-metadata">

**Author:** ![gohai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gohai/32/25_2.png) [@gohai](https://discourse.processing.org/u/gohai)\
**Post date:** [June 25, 2018, 3:05am UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189/3 "2018-06-25T03:05:53Z")

</div>

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](https://github.com/processing/processing/tree/master/java/libraries/io/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.

---

<div class="post-metadata">

**Author:** ![gohai](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gohai/32/25_2.png) [@gohai](https://discourse.processing.org/u/gohai)\
**Post date:** [June 29, 2018, 6:43pm UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189/4 "2018-06-29T18:43:11Z")

</div>

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](https://github.com/processing/processing/tree/master/java/libraries/io/examples/Light_I2C_TSL2561).

---

<div class="post-metadata">

**Author:** ![Zengirl2](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/zengirl2/32/448_2.png) [@Zengirl2](https://discourse.processing.org/u/Zengirl2)\
**Post date:** [September 7, 2018, 8:22pm UTC](https://discourse.processing.org/t/using-sensors-and-pi/1189/5 "2018-09-07T20:22:35Z")

</div>

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