PCB lives now in its own git repo https://git.la10cy.net/DeltaLima/CanGrow-12V-PCB
41 lines
1 KiB
C
41 lines
1 KiB
C
/*
|
|
*
|
|
* include/Sensor/08_ADS1015.h - ADS1115 16 bit ADC I2C driver
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* #include <Adafruit_ADS1X15.h>
|
|
* This already got included in Sensor_07_ADS1115.h
|
|
*/
|
|
|
|
#define SENSOR_08_NAME "ADS1015"
|
|
|
|
|
|
const byte Sensor_08_ADS1015_Addr[] = { 0x48, 0x49, 0x4A, 0x4B };
|
|
|
|
Adafruit_ADS1015 ADS1015[sizeof(Sensor_08_ADS1015_Addr)];
|
|
|
|
int Sensor_08_ADS1015[sizeof(Sensor_08_ADS1015_Addr)][4];
|
|
|
|
void Sensor_08_ADS1015_Update(const byte AddrId) {
|
|
for(byte i = 0; i < 4; i++) {
|
|
Sensor_08_ADS1015[AddrId][i] = ADS1015[AddrId].readADC_SingleEnded(i);
|
|
}
|
|
}
|
|
|
|
bool Sensor_08_ADS1015_Init(const byte AddrId) {
|
|
const static char LogLoc[] PROGMEM = "[Sensor:08_ADS1015:Init]";
|
|
bool returnCode;
|
|
if(ADS1015[AddrId].begin(Sensor_08_ADS1015_Addr[AddrId])) {
|
|
Log.notice(F("%s found at addr 0x%x" CR), LogLoc, Sensor_08_ADS1015_Addr[AddrId]);
|
|
Sensor_08_ADS1015_Update(AddrId);
|
|
returnCode = true;
|
|
} else {
|
|
Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Sensor_08_ADS1015_Addr[AddrId]);
|
|
returnCode = false;
|
|
}
|
|
return returnCode;
|
|
}
|