Devices & Components
Arduino Mega 2560 Rev3
1N4148 – General Purpose Fast Switching
Project description
Code
Diode thermometer based code
arduino
Load this code in your arduino and in the serial plot you can see the temperature read uy the diode
1/* 2 3 Thermometer based on 1n4148 silicon diode used as temperature sensor.The thermometer is based on the diode characteristic that the increase of the temperature its forward voltage (VF) is lowered by 2,2mV / ° C. 4Fixing the value of Vf = VF0 at ambient temperature t0, the temperature value 5t is calculated with the following formula: 6 7t= t0 - [vf(t)- vf0]* K 8 9with K = 1 / 2,2mV 10 11The value of Vf (t) = dtemp -vf0 is obtained by averaging values of 1024 by acquiring as many vf values 12 13The result of t is shown on the serial monitor 14*/ 15 16 17// set pin numbers: 18 19const int in = A0; // used to bias the diode anode 20const int t0 = 20.3; 21const float vf0 = 573.44; 22// variables will change: 23 24int i; 25float dtemp, dtemp_avg, t; 26 27void setup() { 28 Serial.begin(9600); 29 pinMode(in, INPUT_PULLUP); // set the pin IN with npull up to bias the diode 30 31} 32 33void loop() { 34 dtemp_avg = 0; 35 for (i = 0; i < 1024; i++) { 36 float vf = analogRead(A0) * (4976.30 / 1023.000); 37 //Serial.println(vf); 38 dtemp = (vf - vf0) * 0.4545454; 39 dtemp_avg = dtemp_avg + dtemp; 40 } 41 t = t0 - dtemp_avg / 1024; 42 Serial.print("temperature in Celcius degree) = " ); 43 Serial.println(t); 44 45 delay (1000); 46 47}
Diode thermometer based code
arduino
Load this code in your arduino and in the serial plot you can see the temperature read uy the diode
1/* 2 3 Thermometer based on 1n4148 silicon diode used as temperature 4 sensor.The thermometer is based on the diode characteristic that the increase of 5 the temperature its forward voltage (VF) is lowered by 2,2mV / ° C. 6Fixing the 7 value of Vf = VF0 at ambient temperature t0, the temperature value 8t is calculated 9 with the following formula: 10 11t= t0 - [vf(t)- vf0]* K 12 13with K = 1 / 2,2mV 14 15The 16 value of Vf (t) = dtemp -vf0 is obtained by averaging values of 1024 by acquiring 17 as many vf values 18 19The result of t is shown on the serial monitor 20*/ 21 22 23// 24 set pin numbers: 25 26const int in = A0; // used to bias the diode anode 27const 28 int t0 = 20.3; 29const float vf0 = 573.44; 30// variables will change: 31 32int 33 i; 34float dtemp, dtemp_avg, t; 35 36void setup() { 37 Serial.begin(9600); 38 39 pinMode(in, INPUT_PULLUP); // set the pin IN with npull up to bias 40 the diode 41 42} 43 44void loop() { 45 dtemp_avg = 0; 46 for (i = 0; i < 47 1024; i++) { 48 float vf = analogRead(A0) * (4976.30 / 1023.000); 49 //Serial.println(vf); 50 51 dtemp = (vf - vf0) * 0.4545454; 52 dtemp_avg = dtemp_avg + dtemp; 53 } 54 55 t = t0 - dtemp_avg / 1024; 56 Serial.print("temperature in Celcius degree) 57 = " ); 58 Serial.println(t); 59 60 delay (1000); 61 62}
Downloadable files
electric scheme
The scheme is very simple: It is needed to connect the diode directly to the pins of the Arduino board: In particular connect the anode at the pin A0 and the catode at the GND pin
electric scheme

Comments
Only logged in users can leave comments