[go: up one dir, main page]

0% found this document useful (0 votes)
106 views7 pages

3 CH Sensor Suhu DS1820 LM35 TC

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

1 Inkubatek [supported by : www.tokotronik.

com]

3 CH SENSOR SUHU DS1820, LM35 & THERMOCOUPLE


Sistem Kerja Alat:
Arduino UNO membaca nilai temperatur linkungan dengan 3 sensor suhu jenis DS1820/22, LM35
dan Thermocouple . Hasil pembacaan kedua sensor ditampilkan ke Serial Monitor.

Kebutuhan Hardware :
 Arduino UNO Board
 Modul sensor temperatur DS182/22
 Modul sensor LM35
 Modul Sensor Thermocouple dg driver MAX6675
 Power Supply 7-9 Vdc

DS1820/22 Waterproof
DS1820/22

Thermocouple &
MAX675
2 Inkubatek [supported by : www.tokotronik.com]

LM35

Schematics

Koneksi Arduino dengan Sensor DS1820/22 :

Pin ARDUINO Sensor DS1820

5V 5 V (red)

GND GND (grey)

11 Data (yellow)
3 Inkubatek [supported by : www.tokotronik.com]

Koneksi Arduino dengan Sensor Thermocouple (Driver max6675) :

Pin ARDUINO MAX6675

5V VCC

GND GND

8 S0

9 CS

10 SCK

Koneksi Arduino dengan Sensor LM35 :

Pin ARDUINO Sensor LM35

5V 5V

GND GND

A0 Analog Sensor Out

Source Code/Sketch :
/*************************************

* Program : Project 2 3 Ch Sensor Suhu DS1820 LM35 TC

* Input : Sensor LM35 di pin A0

* Sensor DS1820

* Sensor Thermocouple (MAX6675)

* SO --> PIN 8

* SCK --> PIN 10

* CS --> PIN 9

* Output : Serial Monitor

* 125 Proyek Arduino Inkubatek

* www.tokotronik.com

* ***********************************/

#include <OneWire.h>
4 Inkubatek [supported by : www.tokotronik.com]

#include <Wire.h>

#include "max6675.h"

OneWire ds(11); // on pin 11 --DS1820

int thermoDO = 8;

int thermoCS = 9;

int thermoCLK = 10;

unsigned int adc,tempDS,tempLM,tempTC;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

//============================================

void setup(void) {

Serial.begin(9600);

Serial.println("Monitoring 3 Sensor Suhu : DS1820, Thermocouple, LM35");

//===========================================

void loop(void) {

byte i;

byte present = 0;

byte type_s;

byte data[12];

byte addr[8];

float celsius, fahrenheit;

//===================================

if ( !ds.search(addr)) {

ds.reset_search();

delay(250);

return;
5 Inkubatek [supported by : www.tokotronik.com]

// the first ROM byte indicates which chip

switch (addr[0]) {

case 0x10: // Chip = DS18S20 or old DS1820

type_s = 1;

break;

case 0x28: // Chip = DS18B20

type_s = 0;

break;

case 0x22: // Chip = DS1822

type_s = 0;

break;

default: //Device is not a DS18x20 family device.

return;

ds.reset();

ds.select(addr);

ds.write(0x44, 1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not

// we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();

ds.select(addr);

ds.write(0xBE); // Read Scratchpad

for ( i = 0; i < 9; i++) { // we need 9 bytes

data[i] = ds.read();

}
6 Inkubatek [supported by : www.tokotronik.com]

int16_t raw = (data[1] << 8) | data[0];

if (type_s) {

raw = raw << 3; // 9 bit resolution default

if (data[7] == 0x10) {

raw = (raw & 0xFFF0) + 12 - data[6];

else {

byte cfg = (data[4] & 0x60);

if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms

else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms

else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms

celsius = (float)raw / 16.0;

fahrenheit = celsius * 1.8 + 32.0;

tempDS=celsius;

//====================

adc = analogRead(0);

tempLM=(adc*5)/10;

//====================

celsius=thermocouple.readCelsius();

tempTC=celsius;

Serial.print("Temp DS1820=");

Serial.print(tempDS);

Serial.println(" Celcius");

Serial.print("Temp Thermocouple=");

Serial.print(tempTC);

Serial.println(" Celcius");

Serial.print("Temp LM35=");
7 Inkubatek [supported by : www.tokotronik.com]

Serial.print(tempLM);

Serial.println(" Celcius");

delay(1000);

Jalannya Alat :
Jalankan Serial Monitor (dari menu Tool – Serial Monitor) set baud rate pada nilai 9600 bps. Pada
Serial Monitor akan tampil nilai temperature yang dibaca oleh Arduino dengan sensor suhu DS1820 ,
LM35 dan Thermocouple. Jika temperatur berubah, tampilan di Serial Monitor akan mengikutinya.

You might also like