検索コード

リレーとディスプレイを使ったMAX6675によるK型熱電対の使用

リレーとディスプレイを使ったMAX6675によるK型熱電対の使用

このプロジェクトは、MAX6675を用いてK型熱電対をArduinoに接続し、制御用リレーと温度表示用ディスプレイを組み込む方法を示します。この構成は、精密な温度監視と自動応答が求められるさまざまな用途で非常に有用です。以下はいくつかのプロジェクト案です:

MAX6675 Thermocoupler module
  • 精密電子機器用の過熱保護
  • 生物実験用の温度制御インキュベーター
  • コーヒーまたはビール用の自動醸造システム
  • 産業プロセスの監視と制御
  • 温室やその他の管理された環境における環境モニタリング

ハードウェア/コンポーネント

このプロジェクトを構築するには、次のコンポーネントが必要です:

  • Arduino Uno(または互換ボード)
  • MAX6675 K型熱電対モジュール(動画の00:58で)
  • リレーモジュール
  • TM1637 4桁LEDディスプレイモジュール
  • ジャンパーワイヤー
  • 接続ワイヤー

配線ガイド

配線は動画内の05:36で説明されています。具体的な接続は、表面実装チップを使用するかPCBモジュールを使用するかによって異なります。詳しい配線図は動画を参照してください。

Arduino wiring for MAX6675 Thermocoupler module
Arduino wiring for MAX6675 Thermocoupler module

コードの説明

ArduinoのコードはMAX6675ライブラリを使用して熱電対から温度値を読み取ります。コードの主な設定可能な部分は次のとおりです:

  • 熱電対ピンの定義:thermoDO,thermoCS、そしてthermoCLK(ビデオの:53で) これらのピンは配線方式に従って調整する必要があります。
  • リレー制御ピン: ピン10がリレーの制御に使用されます(ビデオの[05:36]で)。必要に応じてこれを変更してください。
  • ディスプレイの設定(使用する場合): コードにはTM1637ディスプレイを設定するためのセクションが含まれています。必要に応じてCLKとDIOのピンを調整してください(動画の[03:53]参照)。

コードには摂氏と華氏で温度を読み取る関数が含まれています。コードの重要な部分は、温度がしきい値(この例では80.0°C)を超えているかを判定する条件文です。もし超えていればリレーが作動し、ピン10がLOWになります。


// If temperature goes above 80.0C, turn the relay ON
if(thermocouple.readCelsius() > 80.00){
  digitalWrite(10, LOW);// Set pin 10 LOW
} else {
  digitalWrite(10, HIGH);// Set pin 10 HIGH
}

ライブプロジェクト/デモンストレーション

動画はプロジェクトが実際に動作している様子を示しています(動画の06:59で)。センサーは周囲温度を正確に読み取り、加熱すると温度が上昇します。リレーの機能も示されています。

  • [00:00] イントロダクション
  • [00:39] センサーの概要
  • [01:40] ピン接続
  • [02:22] ライブラリのインストール
  • [03:53] コードの解説 (セットアップ)
  • [04:06] コードの説明 (ループ)
  • [05:36] 配線
  • [06:59] ライブデモンストレーション

画像

MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
K-Type Thermocoupler module with wire
K-Type Thermocoupler module with wire
K-Type thermocoupler connector
K-Type thermocoupler connector
Arduino wiring for MAX6675 Thermocoupler module
Arduino wiring for MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
MAX6675 Thermocoupler module
24-Arduino code for a MAX6675 K-type thermocouple (without relay and display)
言語: C++
/*
 * This is the Arduino code for MAX6675 Thermocouple K-Type with Relay and Display.
 * This code has been explained in our video at https://youtu.be/cD5oOu4N_AE.

 * 
 * Written by Ahmad Shamshiri for Robojax Video
 * Date: December 9, 2017, in Ajax, Ontario, Canada
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: This code is "AS IS" and for educational purposes only.
 * 
 */

 // This example is public domain. Enjoy!
// www.ladyada.net/learn/sensors/thermocouple

#include "max6675.h"


int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
  
void setup() {
  Serial.begin(9600);
  // Use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  
  Serial.println("Robojax: MAX6675 test");
  // Wait for MAX chip to stabilize
  delay(500);
}

void loop() {
  // Basic readout test, just print the current temperature


   Serial.print("C = "); 
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

   // If temperature goes above 80.0C, turn the relay ON
   if(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW);// Set pin 10 LOW
   }else{
    digitalWrite(10, HIGH);// Set pin 10 HIGH
   }
    
 
   delay(1000);
}
25-Arduino code for a MAX6675 K-type thermocouple with relay (no display)
言語: C++
/*
 * これは、リレーとディスプレイを使用したMAX6675サーモカップルKタイプのArduinoコードです。出力ピン10はリレーに接続されています。温度が設定値に達すると、ピン10がリレーをONにします。
 * 
 * このコードについては、https://youtu.be/cD5oOu4N_AEで説明しています。
 * 
 * ロボジャックスビデオのためにアハマド・ネジェラビによって書かれました。 日付:2017年12月9日、カナダのオンタリオ州アジャックスにて。 このコードを共有する際はこのメモをコードと共に保持することを条件に許可が与えられました。 免責事項:このコードは「現状のまま」で、教育目的のみのものです。
 * 
 * /
 * 
 * この例はパブリックドメインです。お楽しみください!
 * // www.ladyada.net/learn/sensors/thermocouple
 */
#include "max6675.h"


int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;

void setup() {
  Serial.begin(9600);
 // Arduinoピンを使用する
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(10, OUTPUT); // ピン10を出力として設定する

  Serial.println("Robojax: MAX6675 test");
 // MAXチップが安定するのを待つ
  delay(500);
}

void loop() {
 // 基本的な読み取りテスト、現在の温度を表示するだけです。


   Serial.print("C = ");
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

 // 温度が80.0℃を超えた場合、リレーをONにしてください。
   if(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW); // ピン10をLOWに設定
   }else{
    digitalWrite(10, HIGH); // ピン10をHIGHに設定
   }


   delay(1000);
}
26-Arduino code for a MAX6675 K-type thermocouple with relay and display
言語: C++
/*
 * これは、リレーとディスプレイを備えたMAX6675サーモカップルKタイプのためのArduinoコードです。出力ピン10はリレーに接続されています。温度が所望の値に達すると、ピン10がリレーをONにします。温度はディスプレイにも表示されます。ディスプレイを動作させるにはTM1637ライブラリを含める必要があります。TM1637はhttp://robojax.com/learn/libraryからダウンロードできます。このコードは、私たちの動画で説明されています:https://youtu.be/cD5oOu4N_AE
 * 
 * Ahmad Nejrabi著、Robojax Videoのために作成
 * 日付:2017年12月9日、カナダ・オンタリオ州アジャックスにて
 * この注記をコードと一緒に保管する限り、このコードを共有することを許可します。
 * 免責事項:このコードは「現状のまま」であり、教育目的のみのものです。
 */
#include "max6675.h"
#include <Arduino.h>
#include <TM1637Display.h>

int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;

 // 表示用のコード
#define CLK 2
#define DIO 3
#define TEST_DELAY   2000
TM1637Display display(CLK, DIO);
 // 表示終了のコード

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;

void setup() {
  Serial.begin(9600);
 // Arduinoピンを使用する
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  pinMode(10, OUTPUT); // ピン10を出力として設定する

  Serial.println("Robojax: MAX6675 test");
 // MAXチップが安定するまで待ってください。
  delay(500);
}

void loop() {
 // 基本的な読み出しテスト、現在の温度を印刷するだけです。

 // 表示用のコード
  display.setBrightness(0x0f);
 // すべてのセグメントオン
  uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
  display.setSegments(data);
  delay(1);
  int temp = (int) thermocouple.readCelsius();
  display.showNumberDec(temp, true, 3, 0);
 // 表示終了のコード
   Serial.print("C = ");
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

 // 温度が80.0℃を超えたら、リレーをオンにしてください。
   if(thermocouple.readCelsius() > 80.00){
    digitalWrite(10, LOW); // ピン10をLOWに設定
   }else{
    digitalWrite(10, HIGH); // ピン10をHIGHに設定
   }


   delay(1000);
}
27-Arduino code for two MAX6675 K-type thermocouples with relay (no display)
言語: C++
/*
 * これは、リレーとディスプレイを備えたMAX6675サーモカップルKタイプのためのArduinoコードです。
 * 出力ピン10はリレーに接続されています。
 * 温度が希望の値に達すると、ピン10がリレーをONにします。
 * 
 * このコードは、私たちのビデオで説明されています: https://youtu.be/cD5oOu4N_AE
 * 
 * ロボジャックスビデオのためにアハマド・シャムシリによって書かれました。
 * 日付:2018年6月2日、カナダのオンタリオ州エイジャックス
 * このメモをコードと共に保持することを条件に、このコードを共有する許可が与えられました。
 * 免責事項:このコードは「現状のまま」で、教育目的のみのものです。
 * 
 * /
 * 
 * この例はパブリックドメインです。どうぞお楽しみください!
 * www.ladyada.net/learn/sensors/thermocouple
 */
#include "max6675.h"


int thermoDO1 = 4;
int thermoCS1 = 5;
int thermoCLK1 = 6;

int thermoDO2 = 7;
int thermoCS2 = 8;
int thermoCLK3 = 9;


MAX6675 thermocouple1(thermoCLK1, thermoCS1, thermoDO1); // 最初の熱電対
MAX6675 thermocouple2(thermoCLK2, thermoCS2, thermoDO2); // 2番目の熱電対
int vccPin1 = 3;
int gndPin1 = 2;
int relayPin1 =10;

int vccPin2 = 11;
int gndPin2 = 12;
int relayPin2 =13;

void setup() {
  Serial.begin(9600);
 // Arduinoピンを使用する
  pinMode(vccPin1, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin1, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(relayPin1, OUTPUT); // サーモカップル1の出力としてピン10を設定する

  pinMode(vccPin2, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin2, OUTPUT); digitalWrite(gndPin, LOW);
    pinMode(relayPin2, OUTPUT); // ピン13を出力として設定し、熱電対2に使用します。

  Serial.println("Robojax: MAX6675 test");
 // MAXチップが安定するのを待ってください。
  delay(500);
}

void loop() {
 // 基本的な読み出しテスト、現在の温度を表示するだけです。

 // 熱電対1用
   Serial.print("C = ");
   Serial.println(thermocouple.readCelsius());
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());

 // 温度が80.0℃を超えた場合は、リレーをオンにします。
   if(thermocouple1.readCelsius() > 80.00){
    digitalWrite(relayPin1, LOW); // ピン relayPin1 を LOW に設定
   }else{
    digitalWrite(relayPin1, HIGH); // ピン relayPin1 を HIGH に設定
   }
 // 熱電対1端

 // 熱電対 2用
   Serial.print("C2 = ");
   Serial.println(thermocouple2.readCelsius());
   Serial.print("F2 = ");
   Serial.println(thermocouple2.readFahrenheit());

 // 温度が80.0℃を超えた場合は、リレーをオンにします。
   if(thermocouple2.readCelsius() > 80.00){
    digitalWrite(relayPin2, LOW); // リレーピン2をLOWに設定
   }else{
    digitalWrite(relayPin2, HIGH); // ピン relayPin2 を HIGH に設定
   }
 // 熱電対2端子

   delay(1000);
}

ファイル📁

ファイルは利用できません。