|
Post by SDL on May 19, 2017 15:39:28 GMT -8
obdata MAY 17, 2017 AT 00:47 #23519 Hello, We have two of the AM2315 sensors connected to a GROVE 4 CHANNEL 16 BIT ADC BOARD, connected to an Arduino Mega 2560. We’ve figured out how to read temperature and humidity from one sensor, but not how to read both and switch between them. Can someone post some sample code or point us to some? Thanks, Jason EDIT | CLOSE | STICK (TO FRONT) | MERGE | TRASH | SPAM | REPLY SwitchDoc Labs MAY 18, 2017 AT 10:07 #23552 OBData, The AM2315 is an I2C device and needs to be plugged into an I2C port, not an ADC port. Since you can’t change the I2C address of an AM2315, you need to use an 4 Channel I2C Mux to read multiple sensors. You could also probably use a Grove PowerSave to selectively turn on AM2315 on and off to read the unit. SDL EDIT | MOVE | SPLIT | TRASH | SPAM | REPLY [email protected]' obdata MAY 18, 2017 AT 11:22 #23558 Oops, sorry, we actually are using the 4 channel Mux board, not sure how I got my post mixed up. So how do we choose which sensor to read?
|
|
|
Post by SDL on May 19, 2017 15:47:38 GMT -8
Obdata,
You need to switch the Mux to point at the I2C bus the AM2315 is on:
The most common mistake on wiring up the I2C mux is forgetting to connect the power pins for each bus (nothing works without it!).
From the spec:
JP6 - I2C Auxiliary Power Pads
These pads allow you to hook up power supplies for each of the 4 I2C Muxed busses. Depending on your design, you may be powering the I2C devices on each bus from another power supply. In that case, you would leave these pads empty. Otherwise, you connect the appropriate power supply for each bus. For example, if you want all busses at 3.3V and the host is a Raspberry Pi, you would hook up VCC (from the Pi @ 3.3V) . You can mix 3.3V and 5.0V I2C busses by connecting the pads on JP6 to their respective power supplies.
JP7 - Auxiliary VCC connections
These connectors are all tied to VCC on JP1 / 3, the VCC from the host interface (usually the Raspberry Pi or Arduino)
Following is the test code from the SDL_Pi_TCA9545 repository.
You just stick in your read AM2315 code in the appropriate slot.
#!/usr/bin/env python # # 03/05/2015 # #
# imports
import sys import time import datetime import random import SDL_Pi_TCA9545 import subprocess
#/*========================================================================= # I2C ADDRESS/BITS # -----------------------------------------------------------------------*/ TCA9545_ADDRESS = (0x73) # 1110011 (A0+A1=VDD) #/*=========================================================================*/
#/*========================================================================= # CONFIG REGISTER (R/W) # -----------------------------------------------------------------------*/ TCA9545_REG_CONFIG = (0x00) # /*---------------------------------------------------------------------*/
TCA9545_CONFIG_BUS0 = (0x01) # 1 = enable, 0 = disable TCA9545_CONFIG_BUS1 = (0x02) # 1 = enable, 0 = disable TCA9545_CONFIG_BUS2 = (0x04) # 1 = enable, 0 = disable TCA9545_CONFIG_BUS3 = (0x08) # 1 = enable, 0 = disable
#/*=========================================================================*/
# Main Program
print "" print "Test SDL_Pi_TCA9545 Version 1.0 - SwitchDoc Labs" print "" print "Sample uses 0x73" print "Program Started at:"+ time.strftime("%Y-%m-%d %H:%M:%S") print ""
filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt" starttime = datetime.datetime.utcnow()
tca9545 = SDL_Pi_TCA9545.SDL_Pi_TCA9545(addr=TCA9545_ADDRESS, bus_enable = TCA9545_CONFIG_BUS0)
# rotates through all 4 I2C buses and prints out what is available on each
while True: print "-----------BUS 0-------------------" tca9545.write_control_register(TCA9545_CONFIG_BUS0) # read the control register back control_register = tca9545.read_control_register() print "tca9545 control register B3-B0 = 0x%x"% (control_register & 0x0f ) print "ignore Interrupts if INT3' - INT0' not connected" print "tca9545 control register Interrupts = 0x%x"% ((control_register & 0xf0) >> 4) i2ccommand = "sudo i2cdetect -y 1" output = subprocess.check_output (i2ccommand,shell=True, stderr=subprocess.STDOUT ) print output
print "-----------------------------------" print time.sleep(5.0)
print "-----------BUS 1-------------------" tca9545.write_control_register(TCA9545_CONFIG_BUS1) # read the control register back control_register = tca9545.read_control_register() print "tca9545 control register B3-B0 = 0x%x"% (control_register & 0x0f ) print "ignore Interrupts if INT3' - INT0' not connected" print "tca9545 control register Interrupts = 0x%x"% ((control_register & 0xf0) >> 4) i2ccommand = "sudo i2cdetect -y 1" output = subprocess.check_output (i2ccommand,shell=True, stderr=subprocess.STDOUT ) print output
print "-----------------------------------" print time.sleep(5.0)
print "-----------BUS 2-------------------" tca9545.write_control_register(TCA9545_CONFIG_BUS2) # read the control register back control_register = tca9545.read_control_register() print "tca9545 control register B3-B0 = 0x%x"% (control_register & 0x0f ) print "ignore Interrupts if INT3' - INT0' not connected" print "tca9545 control register Interrupts = 0x%x"% ((control_register & 0xf0) >> 4) i2ccommand = "sudo i2cdetect -y 1" output = subprocess.check_output (i2ccommand,shell=True, stderr=subprocess.STDOUT ) print output
print "-----------------------------------" print time.sleep(5.0)
print "-----------BUS 3-------------------" tca9545.write_control_register(TCA9545_CONFIG_BUS3) # read the control register back control_register = tca9545.read_control_register() print "tca9545 control register B3-B0 = 0x%x"% (control_register & 0x0f ) print "ignore Interrupts if INT3' - INT0' not connected" print "tca9545 control register Interrupts = 0x%x"% ((control_register & 0xf0) >> 4) i2ccommand = "sudo i2cdetect -y 1" output = subprocess.check_output (i2ccommand,shell=True, stderr=subprocess.STDOUT ) print output
print "-----------------------------------" print time.sleep(5.0)
|
|
|
Post by obdata on May 26, 2017 12:17:26 GMT -8
Ok, we're actually using Arduino. I've run the board test code found at github.com/switchdoclabs/SDL_Arduino_TCA9545A The board is detected at address 0x73, but the AM2315 sensors are not detected. I do have the 5v power connected from JP7 to JP6 pins. The sensors work if they are wired directly to the Arduino, but we can't get them to work through the mux board. I'm pretty sure everything is wired correctly. Thanks,
|
|
|
Post by SDL on May 27, 2017 13:02:43 GMT -8
OBData,
Post the results from the running of the SDL_Arduino_TCA9545A code. Let's take a look at the results. Sorry about missing the fact you are running an Arduino. We use these with Arduino Mega 2560 units all the time.
Best regards,
BP
|
|
lc
New Member
Posts: 1
|
Post by lc on Mar 13, 2018 6:29:04 GMT -8
I am having this same issue on an arduino UNO, there are 3 AM2315 sensors connected to the board (unfortunately I can't use the 4th grove connector on the board because the JP7 pins have a header that keeps the grove connector from making a connection. That said, here is my output. Everything is wired up as the spec calls for (all JP6 are connected to JP7, even have JP8 connected to VCC and tried with and without reset connected to VCC)
------------------------------ ------------------------------ SDA_Arduino_TCA9545_Test Reading all four I2C Buses ------------------------------ ------------------------------
------------------------------ ------------------------------ Bus 0 Control Register:1 Scanning... I2C device found at address 0x73 ! done
------------------------------ Bus 1 Control Register:2 Scanning... I2C device found at address 0x73 ! done
------------------------------ Bus 2 Control Register:4 Scanning... I2C device found at address 0x73 ! done
------------------------------ Bus 3 Control Register:8 Scanning... I2C device found at address 0x73 ! done
------------------------------ ------------------------------ Bus 0 Control Register:1 Scanning... I2C device found at address 0x73 ! done
------------------------------ Bus 1 Control Register:2 Scanning... I2C device found at address 0x73 ! done
... and of course it continues to loop. I gather it sees the board on all 4 buses but is not seeing any of the AM2315 sensors.
|
|
|
Post by SDL on Mar 13, 2018 6:40:17 GMT -8
First thing to remember is that the AM2315 powers down between readings, so it doesn't show up on the scan on Arduino or Raspberry Pis typically.
You need to try to read the AM2315 to see if it is there.
Cut off the buckle on the Grove connector to fit into JP7. Next order we make of this board, we are moving some stuff around.
Best regards,
BP
|
|