I cant add simple photoresistor

I am using rasp pi 3 model b, and i want to add simple analog photoresostor but i cant choose gpio

,

Thanks for help guys

Hi @tomislavpisk02 and welcome to the Cayenne Community.

This is because the Photoresistor is an analog sensor, and the Raspberry Pi does not have any Analog pins by default. If you add one of the supported Analog to Digital converter extensions from Add New > Device / Widget > Extensions to your project and wire the photoresistor through that, then you’ll see that extension show up in the ‘Connectivity’ menu and you’ll be able to select one of its analog pins.

If you look at our tutorial for wiring a Photoresistor to the Raspberry Pi, we show an example where it is wired to the MCP3008 Analog to Digital convertor.

thanks for fast answer, but i can use it with my raspberry when i simply start python program. So data from it can be read without extensions.

I’m kind of curious how you’re doing this if you don’t mind sharing the code. Is it a simple photoresistor or some sort of digital light sensor? Maybe something like this? Dr. Monk's DIY Electronics Blog: Analog Sensors without Analog Inputs on the Raspberry Pi

Regardless, if you can access the data on your Pi’s command line, then you can definitely pass it into Cayenne if you remove it from your dashboard as a ‘Raspberry Pi’ device and re-connect it to Cayenne as an MQTT device using our Python MQTT client.

This way, you can pass any generic sensor data into Cayenne and a widget will automatically be created for it - (rather than the process of adding and configuring the Photoresistor widget to your Cayenne dashboard).

For example, you can use commands like:

client.luxWrite(2, 155.55) to send the value 155.55 lux to Cayenne on MQTT Channel 2

or

client.virtualWrite(6, 17.222, "analog_sensor", "null") to pass the generic value 17.222 to MQTT Channel 6

and so on.

I will try your way when i come home, but this is the code, it is really
simple as i said :slight_smile:

import RPi.GPIO as GPIO, time, os

DEBUG = 1
GPIO.setmode(GPIO.BCM)

def RCtime (RCpin):
reading = 0
GPIO.setup(RCpin, GPIO.OUT)
GPIO.output(RCpin, GPIO.LOW)
time.sleep(0.1)

GPIO.setup(RCpin, GPIO.IN)

This takes about 1 millisecond per loop cycle

while (GPIO.input(RCpin) == GPIO.LOW):
reading += 1
return reading

while True:
print RCtime(18) # Read RC timing using pin #18

sri, 7. lip 2017. 17:51 Rsiegel mydevices@discoursemail.com je napisao:

1 Like

It is possible to wire a luminosity sensor to the raspberry pi. I have done it a couple of times :slight_smile:
I was following this publication: Raspberry Pi Light Sensor using a simple LDR - Pi My Life Up

1 Like