Components and supplies
HC-05 Bluetooth Module
LM35
Arduino Mega 2560
Resistor 221 ohm
Resistor 4.75k ohm
DS18B20 Programmable Resolution 1-Wire Digital Thermometer
Resistor 100 ohm
LED (generic)
Apps and platforms
Bluetooth Terminal
Arduino IDE
Project description
Code
Temperatures with LM35 and DS18B20
arduino
just open the file, modify to your arduino and be happy
1/*Code adapted from many sources available in internet like http://www.instructables.com/id/ARDUINO-TEMPERATURE-SENSOR-LM35/ 2and http://www.instructables.com/id/How-to-use-DS18B20-Temperature-Sensor-Arduino-Tuto/ 3send me an e-mail if you need jomar.amaral@gmail.com 4*/ 5#include <OneWire.h> 6#include <DallasTemperature.h> 7 8#define ONE_WIRE_BUS_1 2 9 10OneWire oneWire_in(ONE_WIRE_BUS_1); 11 12DallasTemperature sensor_inhouse(&oneWire_in); 13 14float DS; //DS18B20 is conected to digital pin 2 15int ledPin[] = {38, 40, 42, 44, 46, 48, 50, 52}; //pins used, you can modify to you arduino board 16const int LM35 = A15; //define o pino que le a saida do lm35 17float T; //variavel que armazena a temperatura medida 18float valor; 19float TM; 20 21void setup(void) 22{ 23 Serial.begin(9600); 24 // Serial.println("Dallas Temperature Control Library Demo - TwoPin_DS18B20"); 25 26 sensor_inhouse.begin(); 27 for (int j=0; j<8; j++) 28 { 29 pinMode(ledPin[j], OUTPUT); // configura pino digital como sada 30 } 31 32} 33 34void loop(void) 35{ 36// Serial.print("Requesting temperatures..."); 37 sensor_inhouse.requestTemperatures(); 38 // Serial.println(" done"); 39DS = sensor_inhouse.getTempCByIndex(0); 40 Serial.print("Temperatura em DS18: "); 41 // Serial.println(sensor_inhouse.getTempCByIndex(0)); 42 Serial.println(DS); 43 delay(1000); 44 45 valor = analogRead(LM35); 46 T = ((5*(valor)*100)/1024); 47 Serial.print("Temperatura em LM35: "); 48 Serial.println(T); 49 delay(1000); 50 51TM = (DS + T)/2; 52 Serial.print("***Temperatura mEdia em C: "); 53 Serial.println(TM); 54 delay(3000); 55 56 if (TM < 20.00) 57 { 58 digitalWrite(52,HIGH); 59 digitalWrite(50,LOW); 60 digitalWrite(48,LOW); 61 digitalWrite(46,LOW); 62 digitalWrite(44,LOW); 63 digitalWrite(42,LOW); 64 digitalWrite(40,LOW); 65 digitalWrite(38,LOW); 66 } 67 if ((TM >= 20.00) && (TM < 21.50)) 68 { 69 digitalWrite(52,HIGH); 70 digitalWrite(50,HIGH); 71 digitalWrite(48,LOW); 72 digitalWrite(46,LOW); 73 digitalWrite(44,LOW); 74 digitalWrite(42,LOW); 75 digitalWrite(40,LOW); 76 digitalWrite(38,LOW); 77 } 78 if ((TM >= 21.50) && (TM < 23.50)) 79 { 80 digitalWrite(52,HIGH); 81 digitalWrite(50,HIGH); 82 digitalWrite(48,HIGH); 83 digitalWrite(46,LOW); 84 digitalWrite(44,LOW); 85 digitalWrite(42,LOW); 86 digitalWrite(40,LOW); 87 digitalWrite(38,LOW); 88 } 89 if ((TM >= 23.50) && (TM < 25.50)) 90 { 91 digitalWrite(52,HIGH); 92 digitalWrite(50,HIGH); 93 digitalWrite(48,HIGH); 94 digitalWrite(46,HIGH); 95 digitalWrite(44,LOW); 96 digitalWrite(42,LOW); 97 digitalWrite(40,LOW); 98 digitalWrite(38,LOW); 99 } 100 if ((TM >= 25.50) && (TM < 27.50)) 101 { 102 digitalWrite(52,HIGH); 103 digitalWrite(50,HIGH); 104 digitalWrite(48,HIGH); 105 digitalWrite(46,HIGH); 106 digitalWrite(44,HIGH); 107 digitalWrite(42,LOW); 108 digitalWrite(40,LOW); 109 digitalWrite(38,LOW); 110 } 111 if ((TM >= 27.50) && (TM < 30.00)) 112 { 113 digitalWrite(52,HIGH); 114 digitalWrite(50,HIGH); 115 digitalWrite(48,HIGH); 116 digitalWrite(46,HIGH); 117 digitalWrite(44,HIGH); 118 digitalWrite(42,HIGH); 119 digitalWrite(40,LOW); 120 digitalWrite(38,LOW); 121 } 122 if ((TM >= 30.00) && (TM < 33.00)) 123 { 124 digitalWrite(52,HIGH); 125 digitalWrite(50,HIGH); 126 digitalWrite(48,HIGH); 127 digitalWrite(46,HIGH); 128 digitalWrite(44,HIGH); 129 digitalWrite(42,HIGH); 130 digitalWrite(40,HIGH); 131 digitalWrite(38,LOW); 132 } 133 if (TM >= 33.00) 134 { 135 digitalWrite(52,HIGH); 136 digitalWrite(50,HIGH); 137 digitalWrite(48,HIGH); 138 digitalWrite(46,HIGH); 139 digitalWrite(44,HIGH); 140 digitalWrite(42,HIGH); 141 digitalWrite(40,HIGH); 142 digitalWrite(38,HIGH); 143 } 144} 145
Temperatures with LM35 and DS18B20
arduino
just open the file, modify to your arduino and be happy
1/*Code adapted from many sources available in internet like http://www.instructables.com/id/ARDUINO-TEMPERATURE-SENSOR-LM35/ 2and 3 http://www.instructables.com/id/How-to-use-DS18B20-Temperature-Sensor-Arduino-Tuto/ 4send 5 me an e-mail if you need jomar.amaral@gmail.com 6*/ 7#include <OneWire.h> 8#include 9 <DallasTemperature.h> 10 11#define ONE_WIRE_BUS_1 2 12 13OneWire oneWire_in(ONE_WIRE_BUS_1); 14 15DallasTemperature 16 sensor_inhouse(&oneWire_in); 17 18float DS; //DS18B20 is conected to digital pin 19 2 20int ledPin[] = {38, 40, 42, 44, 46, 48, 50, 52}; //pins used, you can modify 21 to you arduino board 22const int LM35 = A15; //define o pino que le a saida do 23 lm35 24float T; //variavel que armazena a temperatura medida 25float valor; 26float 27 TM; 28 29void setup(void) 30{ 31 Serial.begin(9600); 32 // Serial.println("Dallas 33 Temperature Control Library Demo - TwoPin_DS18B20"); 34 35 sensor_inhouse.begin(); 36 37 for (int j=0; j<8; j++) 38 { 39 pinMode(ledPin[j], OUTPUT); // configura 40 pino digital como sada 41 } 42 43} 44 45void loop(void) 46{ 47// Serial.print("Requesting 48 temperatures..."); 49 sensor_inhouse.requestTemperatures(); 50 // Serial.println(" 51 done"); 52DS = sensor_inhouse.getTempCByIndex(0); 53 Serial.print("Temperatura 54 em DS18: "); 55 // Serial.println(sensor_inhouse.getTempCByIndex(0)); 56 Serial.println(DS); 57 58 delay(1000); 59 60 valor = analogRead(LM35); 61 T = ((5*(valor)*100)/1024); 62 63 Serial.print("Temperatura em LM35: "); 64 Serial.println(T); 65 delay(1000); 66 67TM 68 = (DS + T)/2; 69 Serial.print("***Temperatura mEdia em C: "); 70 Serial.println(TM); 71 72 delay(3000); 73 74 if (TM < 20.00) 75 { 76 digitalWrite(52,HIGH); 77 digitalWrite(50,LOW); 78 79 digitalWrite(48,LOW); 80 digitalWrite(46,LOW); 81 digitalWrite(44,LOW); 82 83 digitalWrite(42,LOW); 84 digitalWrite(40,LOW); 85 digitalWrite(38,LOW); 86 87 } 88 if ((TM >= 20.00) && (TM < 21.50)) 89 { 90 digitalWrite(52,HIGH); 91 92 digitalWrite(50,HIGH); 93 digitalWrite(48,LOW); 94 digitalWrite(46,LOW); 95 96 digitalWrite(44,LOW); 97 digitalWrite(42,LOW); 98 digitalWrite(40,LOW); 99 100 digitalWrite(38,LOW); 101 } 102 if ((TM >= 21.50) && (TM < 23.50)) 103 { 104 105 digitalWrite(52,HIGH); 106 digitalWrite(50,HIGH); 107 digitalWrite(48,HIGH); 108 109 digitalWrite(46,LOW); 110 digitalWrite(44,LOW); 111 digitalWrite(42,LOW); 112 113 digitalWrite(40,LOW); 114 digitalWrite(38,LOW); 115 } 116 if ((TM >= 23.50) 117 && (TM < 25.50)) 118 { 119 digitalWrite(52,HIGH); 120 digitalWrite(50,HIGH); 121 122 digitalWrite(48,HIGH); 123 digitalWrite(46,HIGH); 124 digitalWrite(44,LOW); 125 126 digitalWrite(42,LOW); 127 digitalWrite(40,LOW); 128 digitalWrite(38,LOW); 129 130 } 131 if ((TM >= 25.50) && (TM < 27.50)) 132 { 133 digitalWrite(52,HIGH); 134 135 digitalWrite(50,HIGH); 136 digitalWrite(48,HIGH); 137 digitalWrite(46,HIGH); 138 139 digitalWrite(44,HIGH); 140 digitalWrite(42,LOW); 141 digitalWrite(40,LOW); 142 143 digitalWrite(38,LOW); 144 } 145 if ((TM >= 27.50) && (TM < 30.00)) 146 { 147 148 digitalWrite(52,HIGH); 149 digitalWrite(50,HIGH); 150 digitalWrite(48,HIGH); 151 152 digitalWrite(46,HIGH); 153 digitalWrite(44,HIGH); 154 digitalWrite(42,HIGH); 155 156 digitalWrite(40,LOW); 157 digitalWrite(38,LOW); 158 } 159 if ((TM >= 30.00) 160 && (TM < 33.00)) 161 { 162 digitalWrite(52,HIGH); 163 digitalWrite(50,HIGH); 164 165 digitalWrite(48,HIGH); 166 digitalWrite(46,HIGH); 167 digitalWrite(44,HIGH); 168 169 digitalWrite(42,HIGH); 170 digitalWrite(40,HIGH); 171 digitalWrite(38,LOW); 172 173 } 174 if (TM >= 33.00) 175 { 176 digitalWrite(52,HIGH); 177 digitalWrite(50,HIGH); 178 179 digitalWrite(48,HIGH); 180 digitalWrite(46,HIGH); 181 digitalWrite(44,HIGH); 182 183 digitalWrite(42,HIGH); 184 digitalWrite(40,HIGH); 185 digitalWrite(38,HIGH); 186 187 } 188} 189
Downloadable files
Full schematic
Just conect wires and components as it is.
Full schematic
Full schematic
Just conect wires and components as it is.
Full schematic
Full image
Just conect as it is in image.
Full image
Comments
Only logged in users can leave comments
Anonymous user
5 years ago
can i know the disadvantages of the project
1abdulhamidmohammed
7 months ago
Can the temperature be controlled through a mobile app?