PCB lives now in its own git repo https://git.la10cy.net/DeltaLima/CanGrow-12V-PCB
38 lines
1,009 B
C
38 lines
1,009 B
C
/*
|
|
*
|
|
* include/Sensor/07_ADS1115.h - ADS1115 16 bit ADC I2C driver
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
#include <Adafruit_ADS1X15.h>
|
|
|
|
#define SENSOR_07_NAME "ADS1115"
|
|
|
|
|
|
const byte Sensor_07_ADS1115_Addr[] = { 0x48, 0x49, 0x4A, 0x4B };
|
|
|
|
Adafruit_ADS1115 ADS1115[sizeof(Sensor_07_ADS1115_Addr)];
|
|
|
|
int Sensor_07_ADS1115[sizeof(Sensor_07_ADS1115_Addr)][4];
|
|
|
|
void Sensor_07_ADS1115_Update(const byte AddrId) {
|
|
for(byte i = 0; i < 4; i++) {
|
|
Sensor_07_ADS1115[AddrId][i] = ADS1115[AddrId].readADC_SingleEnded(i);
|
|
}
|
|
}
|
|
|
|
bool Sensor_07_ADS1115_Init(const byte AddrId) {
|
|
const static char LogLoc[] PROGMEM = "[Sensor:07_ADS1115:Init]";
|
|
bool returnCode;
|
|
if(ADS1115[AddrId].begin(Sensor_07_ADS1115_Addr[AddrId])) {
|
|
Log.notice(F("%s found at addr 0x%x" CR), LogLoc, Sensor_07_ADS1115_Addr[AddrId]);
|
|
Sensor_07_ADS1115_Update(AddrId);
|
|
returnCode = true;
|
|
} else {
|
|
Log.error(F("%s FAILED! Not found at addr 0x%x" CR), LogLoc, Sensor_07_ADS1115_Addr[AddrId]);
|
|
returnCode = false;
|
|
}
|
|
return returnCode;
|
|
}
|