anirudh
Posts: 1
Joined: Thu Apr 19, 2018 6:54 am

Detect a sensor when connected to Rpi

Thu Apr 19, 2018 7:00 am

How do I detect what kind of sensor is connected to a Raspberry Pi board ?

mattmiller
Posts: 1816
Joined: Thu Feb 05, 2015 11:25 pm

Re: Detect a sensor when connected to Rpi

Thu Apr 19, 2018 7:41 am

Mostly you can't

You normally work out what the sensor is - decide which pin you connect it to - then write a program to read data from it (normally using a library that someone has written)

alphanumeric
Posts: 1414
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Detect a sensor when connected to Rpi

Sun Apr 22, 2018 7:29 pm

What he said. The only auto detect, GPIO wise that I know of is via the HAT ID EPROM, if it has one. You can look for devices (addresses) on i2c with i2cdetect but that won't actually tell you what's connected, just that something is there. What are you working on with?

nios2
Posts: 37
Joined: Mon Mar 12, 2018 3:22 am

Re: Detect a sensor when connected to Rpi

Mon Apr 23, 2018 2:45 am

alphanumeric wrote:
Sun Apr 22, 2018 7:29 pm
What he said. The only auto detect, GPIO wise that I know of is via the HAT ID EPROM, if it has one. You can look for devices (addresses) on i2c with i2cdetect but that won't actually tell you what's connected, just that something is there. What are you working on with?
Agree with the above. If you are using only I2C devices you could scan the address range and identify address locations that are populated. That in itself would not identify the exact device, however some I2C devices include a makers ID code (ADXL345 for example) which along with its address could identify the device.

So as per the previous poster, it all depends on which devices you are using.

Return to “Python”

Who is online

Users browsing this forum: lmarmisa and 7 guests