Voltage data acquisition for a thermo-electric generator module

Hi there,

I was wondering if someone could point me in the right direction.

I’m currently involved in a project where I need to log the temperature and the voltage for a 1.6W TEG module that is being heated via a solar evacuated heat tube.

The setup comprises of a:

-Arduino Uno
-Ocean Control Thermocouple Module
-Adafruit data logger

I am able to log the temperature from several thermocouples but I am having trouble logging the voltage.

The code I am using an existing piece of coding that is shown below:

// use the following libraries
#include <SPI.h> // serial peripheral interphasing (PIN communications MISO MOSI)
#include<SD.h> // sd function library
#include “MAX31855.h” // cold junction compensator library
#include “KTA259V3.h” // multiplexer channel SPI control library
#include “RTClib.h” // RTC library
#include <Wire.h> // required for RTC

RTC_DS1307 rtc; //RTC command
int CS_pin = 10; // SD pin
char file_today_name[30]; // Create char to hold today’s file name by date

const int no_therm = 8; //****************** INPUT THE NUMBER OF THERMOCOUPLES IN USE (1-8) ************************************ !! ENTER 0 IF NONE IN USE !!
const int no_V_In = 2; // ****************** INPUT THE NUMBER OF VOLTAGE INPUTS IN USE (1-2) ************************************ !! ENTER 0 IF NONE IN USE !!
const float frequency = 5; // ****************** INPUT THE FREQUENCY OF DATA ACQUISITION IN SECONDS NO LESS THAN 1.6s ************* !! CURRENTLY SET AT 5s !!
const int T_millis = (frequency * 1000) -(200* no_therm); // converts frequency to microseconds accounting for the 0.2s delay for each sensor to settle
const int no_sensors = (no_therm + no_V_In); // SUM OF SENSORS IN USE

//int power = 3; // power pin for flow sensors

float DatMat [no_sensors][1]; // Data matrix of dimensions (num of sensors X 1) to store sensor data
int i = 1; // counter which tracks sensor logging and indexes matrix
int sensorValue; // analogue read pin value

#define CHANNELS_ENABLED no_therm // The number of channels enabled
KTA259V3 tc = KTA259V3(9); // Init with chip select on pin 9

void setup()

Serial.println(“Datalogger initialising”);
pinMode(SS, OUTPUT);
//digitalWrite (power, HIGH);

// SD set up and test

pinMode(CS_pin, OUTPUT); // CS pin is an output

if(!SD.begin(CS_pin)) // If CS_pin reads false the program will terminate
Serial.println(“Card Failure”);

// RTC set up and test

#ifdef AVR
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due

if (! rtc.isrunning())
Serial.println(“RTC is NOT running!”);

void loop() {

if (i< (no_sensors+1)) // sensors plus one because i starts at 1, necessary because matrix indexing begins at 0, thus (1-1 = 0)

if (i < no_therm) // read the thermocouples

uint8_t channel;
for (channel=1; channel<=CHANNELS_ENABLED; channel++)
delay(200); // channel read every 0.2s (delay for digital medium to settle)

DatMat [i-1][0] = (tc.get_temperature()); // Stores sensor data into a matrix, placing each into ascending rows, this will then be used to log the data
else if (i >= (no_therm))// if the thermocouples have been read then read the analogue inputs
for (int n = 0; n <= (1); n++) // this loops through the analogue pins from 0 - 1

sensorValue = analogRead(n);
float voltage = sensorValue * (5.0 / 1023.0);
DatMat [i-1][0] = (voltage); // Stores sensor data into a matrix, placing each into ascending rows, this will then be used to log the data

else // If all the sensors have been read then log them
DateTime now = rtc.now(); // Request time from RTC

sprintf(file_today_name, “%02d%02d%02d.txt”, now.day(), now.month(), now.year()); // (C++ function) to convert file_today_name into date.txt format
File dataFile = SD.open(file_today_name, FILE_WRITE); // open the SD file

// time stamp the file
dataFile.print(’ ‘);
dataFile.print(now.hour(), DEC);
dataFile.print(now.minute(), DEC);
dataFile.print(now.second(), DEC);
dataFile.print(’ ');

// time stamp printed to screen
Serial.print(’ ‘);
Serial.print(now.hour(), DEC);
Serial.print(now.minute(), DEC);
Serial.print(now.second(), DEC);
Serial.print(’ ');

for (int k=0; k <= (no_sensors -1); k++) // This loop writes sensor data to file and prints to screen for all sensors
dataFile.print(’ ');

Serial.print(’ ');

// cold junction temp recorded for calibration purposes
Serial.print(tc.get_cold_junction_temperature()); // prints the cold junction temp
Serial.print(’ ‘);
dataFile.print(tc.get_cold_junction_temperature()); // writes the cold junction temp to file
dataFile.print(’ ');

Serial.println(’ ‘);
dataFile.println(’ ');
dataFile.close(); // closes the file

delay(T_millis); //frequency of data aquisition
i =1; // reset indexing counter

According to the DAQ manual provided, the voltage wires just need to be connected to the analogue ports but I am failing to get any voltage readings…

Does anyone have suggestions bearing in mind I’m very new to this software so I could be making a simple error!

Welcome to the forums.

Please be so kind as to read the first post in any forum entitled how to use this forum.
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

What is the voltage level you are trying to measure, the UNO AtoD inputs must not have more than 5Vdc applied to them.
If you have a higher voltage you will need to make a potential divider.

Thanks.. Tom... :slight_smile:

Your TEG generates current based on temperature difference from one side to the other. You measure the current by connecting a resistor across the output of the TEG. The resistor will produce a potential difference (voltage) across it's leads in proportion to the current produced by the TEG.

If you are using a VOM to measure the TEG voltage, you are placing a high value resistor across the TEG leads. That resistor is inside your VOM.

You need to check the TEG specs to determine how much current it will produce, then size the resistor to give you a voltage the Arduino can measure.