Arduino-Based 16-Bit Datalogger

Monitoring and follow-up solution for the acquisition of multipurpose measurements. Based on Arduino and monitored using a Windows GUI.

IntermediateFull instructions provided3 hours4,546
Arduino-Based 16-Bit Datalogger

Things used in this project

Hardware components

Adafruit TCA9548A 1-to-8 I2C Multiplexer
×1
Adafruit ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier
4 pcs per pannel
×4
Arduino UNO
Arduino UNO
×1
Connector JST
connections for the TCA9548A entries
×8
resistor 2k ohm
pull-up resistors
×2
JST PH S4B, 2mm Pitch, 4 Way, 1 Row, Right Angle PCB Header, Through Hole
1 per acquisition PCB
×1
PCB terminal block
entry block making the measurement wires easy to connect
×4
Adafruit JST cable
1 per acquisition PCB
×1
CAMDENBOSS, Base Element
optional
×1

Story

Read more

Schematics

Electrical scheme of the multiplexer shield

multiplexer shield

Acquisition shield

Electrical scheme of the acquisition shield

Code

Arduino sketch

C/C++
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <EEPROM.h>

typedef Adafruit_ADS1115* ads_ptr;



#include "Wire.h"
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}
     
#define TCAADDR 0x70 //address of the TCA9548A multiplexer
#define VERBOSE 0

ads_ptr ads1115_array[8][4];

uint8_t addr_ads1115[4] = {0x48, 0x49, 0x4A, 0x4B};  // the four possible address' of each ads1115 module
int init_value = 0;

int entry_status [8];
int stop_acq = 0;
void tcaselect(uint8_t i) {
  if (i > 7) return;
    
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  


}
     
     
// standard Arduino setup()
void setup()
{
    while (!Serial);
    delay(1000);
    //
    Wire.begin();
    
    
    Serial.begin(115200);
    Wire.setClock(400000);
    TWBR = ((F_CPU /40000l) - 16) / 2; // Change the i2c clock to 400KHz
    
    if (VERBOSE) Serial.println("\nTCAScanner ready!");
    
    for (uint8_t t=0; t<3; t++) {
      tcaselect(t);
      if (VERBOSE) Serial.print("TCA Port #");
      if (VERBOSE) Serial.print(t);
      if (VERBOSE) Serial.print("on address : 0x");
      if (VERBOSE) Serial.println(TCAADDR, HEX);
        
      for (uint8_t addr = 0; addr<=127; addr++) {
        //if (addr == TCAADDR) continue;
          
        uint8_t data;
        if (! twi_writeTo(addr, &data, 0, 1, 1)) {
            if (VERBOSE) Serial.print("Found I2C 0x");
            if (VERBOSE) Serial.println(addr,HEX);
        }
      }
      for (int j=0; j<4; j++){
        ads1115_array[t][j] = new Adafruit_ADS1115(addr_ads1115[j]);
        ads1115_array[t][j]->begin();

        if (VERBOSE) Serial.print("ADS1115 on address ");
        if (VERBOSE) Serial.print(addr_ads1115[j], HEX);
        if (VERBOSE) Serial.println(" initialized");
        
      }
    }
}

void serialEvent() {
  if (init_value==0)
  {
    for (uint8_t t=0; t<8; t++) {
      while(Serial.available()==0);
      char charValue[2];
      charValue[0] = Serial.read();
      int val = atoi(charValue);
      entry_status[t] = val;

    }
    init_value =1;
  }

  else
  {
    if(Serial.available()){
      char charValue[2];
      charValue[0]= Serial.read();
      stop_acq = atoi(charValue);

    }
  }
}
void loop() 
{

  if ((init_value==1) &&(stop_acq ==0)){
    double gain = 0.1875;
    String mesg = "";
    int16_t results;
    for (uint8_t t=0; t<8; t++) 
    {
      if (entry_status[t]!=0)
      {
        tcaselect(t);
        if (VERBOSE) Serial.print("tca select ");
        if (VERBOSE) Serial.print(t);
        if (VERBOSE) Serial.print("on address : 0x");
        if (VERBOSE) Serial.println(TCAADDR, HEX);
        for (int j=0; j<4; j++)
        {
          ads1115_array[t][j]->setGain(GAIN_TWOTHIRDS);
          
          results = ads1115_array[t][j]->readADC_Differential_0_1();
          mesg += results * gain ;
          mesg += " ";
          
          results = ads1115_array[t][j]->readADC_Differential_2_3();
          mesg += results * gain ;
          mesg += " ";
        }
      }
    }
    Serial.println(mesg);
  }
  delay(10);
}

software monitoring and acquisition (ArDAQ)

Credits

BBRI (Belgian Building Research Institute)

BBRI (Belgian Building Research Institute)

1 project • 7 followers
Thanks to Wégria Gaëtan and Lonfils Timothée.

Comments