Comments (21)
I agree. However, a quick search didn't turn up anything related to the AM2302 (DHT22) and I2C. Do you know of any documentation covering this? I have a few DHT22s, so it wouldn't be that difficult to get a multiplexer and begin testing in the near future.
from mycodo.
Oh dang, I meant the AM2315, sorry for the confusion. Drivers are part of tentacle_pi (github).
Sensor:
https://www.adafruit.com/products/1293
Driver:
https://github.com/lexruee/tentacle_pi
Multiplexer:
https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/overview
from mycodo.
Nice! A little pricey, but it has a few percent better accuracy in the extreme ends of the humidity range than the DHT22. I'll see about picking one up and a multiplexer and giving it a shot.
from mycodo.
Thanks :)
from mycodo.
Got the sensor today. I should have the multiplexer soon.
from mycodo.
That's great, thanks!
Benjamin Morrison
On Nov 11, 2015, at 7:09 PM, Kyle Gabriel [email protected] wrote:
Got the sensor today. I should have the multiplexer soon.
β
Reply to this email directly or view it on GitHub.
from mycodo.
Got the multiplexer today. Maybe Saturday I'll have some time to hook them up.
from mycodo.
@hephaestoskin Do you have experience using this I2C multiplexer, either with i2c-tools or Python?
from mycodo.
This looks like it includes a class for the TCA9548A: https://pypi.python.org/pypi/pymlab/
from mycodo.
No I'm afraid I don not have experience in this. I'm still just learning.
from mycodo.
Well, the easy part of adding sensor support is done (c27e903), now I need to figure out how to use the multiplexer. I spent a good while tonight on it and I think I got to the point where I'm selecting the channel of the multiplexer, but I haven't been able to get a reading through the multiplexer.
from mycodo.
I'm pretty sure I've figured out how to change the channel of the multiplexer with the following code:
#!/usr/bin/python
# Change channel of TCA9548A
# Example: sudo ./multiplexer_channel.py 0
import smbus
import time
import sys
I2C_address = 0x70
I2C_bus_number = 1
I2C_ch_0 = 0b00000001
I2C_ch_1 = 0b00000010
I2C_ch_2 = 0b00000100
I2C_ch_3 = 0b00001000
I2C_ch_4 = 0b00010000
I2C_ch_5 = 0b00100000
I2C_ch_6 = 0b01000000
I2C_ch_7 = 0b10000000
def I2C_setup(i2c_channel_setup):
bus = smbus.SMBus(I2C_bus_number)
bus.write_byte(I2C_address,i2c_channel_setup)
time.sleep(0.1)
print "TCA9548A I2C channel status:", bin(bus.read_byte(I2C_address))
I2C_setup(int(sys.argv[1]))
But I still haven't been able to read the AM2315 while connected to the multiplexer. The sensor works when directly connected to the Pi I2C (already integrated into Mycodo with the commit in my last comment), so it doesn't seem to be a hardware issue. I do have an I2C barometric pressure sensor I could try to use with the multiplexer.
from mycodo.
Hm, perhaps we should add a thread to the Adafruit forums so their staff can respond? It is their multiplexer. I wish I knew enough to help myself.
Benjamin Morrison
On Nov 14, 2015, at 10:41 AM, Kyle Gabriel [email protected] wrote:
I'm pretty sure I've figured out changing the channel of the multiplexer with the following code:
#!/usr/bin/python
Change channel of TCA9548A
Example: sudo ./multiplexer_channel.py 0
import smbus
import time
import sysI2C_address = 0x70
I2C_bus_number = 1
I2C_ch_0 = 0b00000001
I2C_ch_1 = 0b00000010
I2C_ch_2 = 0b00000100
I2C_ch_3 = 0b00001000
I2C_ch_4 = 0b00010000
I2C_ch_5 = 0b00100000
I2C_ch_6 = 0b01000000
I2C_ch_7 = 0b10000000def I2C_setup(i2c_channel_setup):
bus = smbus.SMBus(I2C_bus_number)
bus.write_byte(I2C_address,i2c_channel_setup)
time.sleep(0.1)
print "TCA9548A I2C channel status:", bin(bus.read_byte(I2C_address))I2C_setup(int(sys.argv[1]))
But I still haven't been able to read the AM2315 while connected to the multiplexer.β
Reply to this email directly or view it on GitHub.
from mycodo.
Okay. Creating a thread on Adafruit forums.
For completeness, here's the code I use to read the AM2315, from tentacle_pi drivers:
#!/usr/bin/python
from tentacle_pi.AM2315 import AM2315
am = AM2315(0x5c,"/dev/i2c-1") # Hardcoded address 0x5c
for x in range(0,10):
temperature, humidity, crc_check = am.sense()
print "temperature: %s" % temperature
print "humidity: %s" % humidity
print "crc: %s" % crc_check
time.sleep(2)
When I have the sensor attached to the multiplexer, set the channel using the code previously posted, I change the above code's 0x5c address to 0x70, but it can't get a reading.
from mycodo.
Posted to the Adafruit Forum: Using the TCA9548A I2C Multiplexer with a Pi & AM2315 Sensor
from mycodo.
The I2C multiplexer and AM2315 are finally working in harmony! Thanks to adafruit_support_rick on the Adafruit support forum.
from mycodo.
Support for the multiplexer added with commit 677299e
from mycodo.
Let me know if you have any problems if you attempt to use the multiplexer with multiple sensors. I only have one sensor, but I've tested it on different channels. It should theoretically work with up to 8 sensors connected to each multiplexer (up to 8 multiplexers), making 64 the maximum number of AM2315s that can be used. Such a great idea, thanks for the suggestion!
from mycodo.
I haven't added support for multiple multiplexers. Currently only one on address 0x70 is supported. I'll reopen this until I add support for multiple multiplexers. That's not going overboard, is it?
from mycodo.
Up to 8 simultaneously-connected multiplexers supported with commit cb7c33c
from mycodo.
Hi, I used your code above to change the channel of the multiplexer. It all seemed to work, However I assume your program just reports the status or number of the channel. How would you get it to report the I2c address of the attached device?
from mycodo.
Related Issues (20)
- Add notes via API HOT 5
- Zigbee2MQTT Plugin for Mycodo HOT 3
- Bang-Bang controller hangs randomly. Can not acquire a measurement, but all inputs and calculation Functions are working with no errors. HOT 3
- issue with TCA9548a multiplexer HOT 6
- Python 3 code(v2.0) not showing output HOT 12
- Blank Widgets HOT 10
- mycodo ERROR - mycodo.influx - Unknown Influxdb version: HOT 3
- Action - Ramp Value
- add ability to copy a function
- Request to add DFRobot i2c Fermion: LWLP5000 Differential Pressure Sensor (Β±500pa)
- Allow setting the same output fΓΌr PID Controller and PID Autotune
- request add Days Counter with advanced functions
- PID widgets display null instead of negative values HOT 12
- Volume Flow Rate in Gallons as well as Liters HOT 1
- Reverse pumping using trigger function with volume not permitted
- Upgrade problem HOT 6
- fswebcam and config file HOT 1
- Installing dependency `bluepy` results in `Could not build wheels for bluepy` HOT 2
- Introducing a Version of the Enhanced Mycodo Integration for Home Assistant HACS HOT 2
- Error with I2C OLED: NameError 'DigitalInOut' is not defined in spi_device.py HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mycodo.