|
| 1 | +// SPDX-FileCopyrightText: 2023 Carter Nelson for Adafruit Industries |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +// LTC4315 with two AHT20 sensors example |
| 6 | +// Set the LTC4315 switch A5 on and switch A4 off |
| 7 | +// The translated sensor will be on address 0x68 |
| 8 | + |
| 9 | +#include <Adafruit_AHTX0.h> |
| 10 | + |
| 11 | +Adafruit_AHTX0 default_aht; |
| 12 | +Adafruit_AHTX0 ltc4316_aht; |
| 13 | + |
| 14 | +void setup() { |
| 15 | + Serial.begin(115200); |
| 16 | + while ( !Serial ) delay(10); |
| 17 | + Serial.println("Adafruit AHT20 with LTC4316 demo!"); |
| 18 | + if (! default_aht.begin(&Wire, 0, 0x38)) { |
| 19 | + Serial.println("Could not find AHT20 on 0x38? Check wiring."); |
| 20 | + while (1) delay(10); |
| 21 | + } |
| 22 | + if (! ltc4316_aht.begin(&Wire, 0, 0x68)) { |
| 23 | + Serial.println("Could not find AHT20 attached to LTC4316 on 0x68? Check wiring and switches"); |
| 24 | + while (1) delay(10); |
| 25 | + } |
| 26 | + Serial.println("AHT20 sensors found on 0x38 and 0x68"); |
| 27 | +} |
| 28 | + |
| 29 | +void loop() { |
| 30 | + sensors_event_t humidity0, temp0; |
| 31 | + sensors_event_t humidity1, temp1; |
| 32 | + default_aht.getEvent(&humidity0, &temp0);// populate temp and humidity objects with fresh data |
| 33 | + ltc4316_aht.getEvent(&humidity1, &temp1);// populate temp and humidity objects with fresh data |
| 34 | + Serial.println("AHT20 on 0x38:"); |
| 35 | + Serial.print("Temperature: "); Serial.print(temp0.temperature); Serial.println(" degrees C"); |
| 36 | + Serial.print("Humidity: "); Serial.print(humidity0.relative_humidity); Serial.println("% rH"); |
| 37 | + Serial.println(); |
| 38 | + Serial.println("AHT20 on 0x68:"); |
| 39 | + Serial.print("Temperature: "); Serial.print(temp1.temperature); Serial.println(" degrees C"); |
| 40 | + Serial.print("Humidity: "); Serial.print(humidity1.relative_humidity); Serial.println("% rH"); |
| 41 | + Serial.println(); |
| 42 | + |
| 43 | + delay(500); |
| 44 | +} |
0 commit comments