Thermocouple Type K - Arduino ESP32

by T_rent1998 in Circuits > Arduino

23 Views, 0 Favorites, 0 Comments

Thermocouple Type K - Arduino ESP32

Thermocouple SetUp.jpeg

Intro - ESP 32 microcontroller circuit was set up with a HS711 amplifier to read a thermocouple type K for a reference input from digital thermometer.

Supplies

  1. 1 - Breadboard
  2. 1 - Thermocouple type K
  3. 1 - HS711 Amplifier
  4. 1 - Arduino ESP 32
  5. 1 - DS18B20 Digital Thermometer
  6. 3 - resistors
  7. 5 - male to female jumper wires
  8. 3 - female to female jumper wires
  9. 1 - USB to ESP 32 connector
  10. 2 - hook up clips (female)
  11. 1 - hook up clip (male)

Connect Electronic Technology

From ESP 32

  1. D25 -> SCK on HS711 Amplifier
  2. D26 -> DT on HS711 Amplifier
  3. VIN -> VCC on HS711 Amplifier
  4. GND -> GND on HS711 Amplifier
  5. D27 -> spot A2 on breadboard
  6. GND -> spot A1 on breadboard
  7. 3V3 -> spot A3 on breadboard



From HS711 Amplifier

  1. A+ -> small prong on DS18B20 digital thermometer
  2. A- -> large prong on DS18B20 digital thermometer
  3. E+ -> spot F1 on breadboard
  4. E- -> spot F6 on breadboard



From DS18B20 digital thermometer

  1. Small prong -> F3 on breadboard



On breadboard

  1. GND - spot A1 on breadboard
  2. D27 - spot A2 on breadboard
  3. 3V3 - spot A3 on breadboard
  4. Resistor (23k ohms) B2 to B3
  5. Thermocouple (semi circle outward from rest of connections) in C1, C2, C3
  6. E+ - spot F1 on breadboard
  7. E- - spot F6 on breadboard
  8. Small prong - F3 on breadboard
  9. Resistor (23k ohms) G1 to G3
  10. Resistor (23k ohms) G3 to G6

Initialize Arduino ESP 32

Using a USB plugin, plug in the Arduino to your computer.

Initialize the Arduino by downloading Arduino IDE (arduino.cc/en/software)

Under boards manager, search and install Arduino ESP32 Boards by Arduino

Click on ‘select board’, select port, search for and select ‘DOIT ESP32 DEVKIT V1’

Run Code

Under Files, Examples, HX711 Arduino Library, HX711_Basic_Example


#include "HX711.h"


// HX711 circuit wiring

const int LOADCELL_DOUT_PIN = 26;

const int LOADCELL_SCK_PIN = 25;


HX711 scale;


const float Vref = 2.0; // Reference voltage in volts

const int gain = 128;  // Gain factor for HX711

const long maxBits = 8388608; // 2^23, the maximum code for 24-bit ADC


void setup() {

 Serial.begin(57600);

 scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

}

void loop() {


 if (scale.is_ready()) {

  long reading = scale.read();


  // Calculate Vtc from the code

  float Vtc = (float(reading) * Vref) / (gain * maxBits);


  // Print raw reading and calculated voltage

  Serial.print("HX711 reading: ");

  Serial.print(reading);

  Serial.print(" => Vtc: ");

  Serial.print(Vtc, 6); // 6 decimal places for precision

  Serial.println(" V");


 } else {

  Serial.println("HX711 not found.");

 }

 delay(1000);

}


For LOADCELL_DOUT_PIN = 26 and LOADCELL_SCK_PIN = 25

Run code

Downloads

Solve for Voltage of Thermocouple

Update code to find V_tc

V_ref = 2V, gain = 128, 24 bits-sign = 2^23

V_tc = (code x V_ref) / (gain x 2^23)

Add code for solving and press upload

Using Thermocouple Type K reference table, use V_tc to find temperature