How to distinguish sensors?
-
What are the possibilities to distinguish between different sensors?
I have 3 different sensors BME280 SHT21 and SHT31.
How can I find out which sensor is connected to the Wipy/Lopy?
Is that even possible?
Who can help me? -
@Wolli01 The must have different I2C addresses. If a sensor is responding, it is present (BME280: 0x76, SHT21: 0x40, SHT31: 0x44).
-
@robert-hh said in How to distinguish sensors?:
The must have different I2C addresses. If a sensor is responding, it is present (BME280: 0x76, SHT21: 0x40, SHT31: 0x44).
Thanks for the info. How can you ask for something like this before?
Is there a code snippet somewhere? -
@robert-hh
I'm so busy now. Are the I2C addresses always the same or is this solution not advisable?i2c = I2C(0, I2C.MASTER) print(i2c.scan()) if i2c.scan() == [68]: Sensorwahl = 'sht31' #Vorgabe welcher Sensor verwendet werden soll if i2c.scan() == [64]: Sensorwahl = 'sht20_21' #Vorgabe welcher Sensor verwendet werden soll -
@Wolli01 You may change I2C addresses by wiring at the module. Besides that, they are constant. But the code should better be:
i2c = I2C(0, I2C.MASTER) device_list = i2c.scan() print(device_list) if 68 in device_list: Sensorwahl = 'sht31' #Vorgabe welcher Sensor verwendet werden soll if 64 in device_list: Sensorwahl = 'sht20_21' #Vorgabe welcher Sensor verwendet werden sollReason: i2c.scan() may return more than one entry, if more than one device is connected.
-
@robert-hh Thank You!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login