I am trying to connect and read 5 individual HDC100x Temperature and Humidity sensors using I2C. The first problem is making the arduino recognize each of the sensors. I have used the A0 and A1 pins, so the arduino sees four separate sensors (addresses are 40, 41, 42, and 43). It cannot find the 5th sensor because there is no way to put voltage on the A0 and A1 pins to differentiate it from the other 4. Is there another way I can wire/program so that it can find all 5 sensors?
The second problem is getting the arduino to read from multiple sensors. I have found programs that read off of multiple heat sensors like a TC74. There are also programs for reading a single HDC100x, but not multiple. Specifically, I am looking for a way to call for the sensor by address and read its temperature.
Multiple sensors: http://www.electroschematics.com/9798/reading-temperatures-i2c-arduino/
Single HDC100x sensor: A professional collaborative platform for embedded development ยท PlatformIO
#include <Adafruit_HDC1000.h>
#include <Wire.h>
int add0 = 40;
int add1 = 41;
int add2 = 42;
int add3 = 43;
Adafruit_HDC1000 hdc = Adafruit_HDC1000();
void setup() {
Serial.begin(9600);
Wire.begin(); // create a wire object
}
void loop() {
int c0 = read_temp(add0);
delay(100);
int c1 = read_temp(add1);
delay(100);
int c2 = read_temp(add2);
delay(100);
int c3 = read_temp(add3);
delay(100);
Serial.print("Sensor 1: ");
Serial.print(c0);
Serial.print("C | ");
Serial.print("Sensor 2: ");
Serial.print(c1);
Serial.print("C | ");
Serial.print("Sensor 3: ");
Serial.print(c2);
Serial.print("C");
Serial.print("Sensor 1: ");
Serial.print(c3);
Serial.println("C | ");
delay(500);
}
int read_temp(int address) {
//start the communication with IC with the address xx
Wire.beginTransmission(address);
//send a bit and ask for register zero
Wire.write(0);
//end transmission
Wire.endTransmission();
//request 1 byte from address xx
Wire.requestFrom(address, hdc.readTemperature());
//wait for response
while(Wire.available() == 0);
//put the temperature in variable c
int c = Wire.read();
return c;
}