You are on page 1of 31

SOUTH AFRICAN ASTRONOMICAL OBSERVATORY

Dual Temperature Sensor

Date:

17 February 2012

Page |2

Contents

Introduction Objectives Block diagram Planning


Sensor circuit Amplifier circuit Offset circuit Regulator circuit

Components Circuit diagram Summary of Operation Testing Conclusion Appendix Datasheets Equations Source code

SAAO - Electronics Department

Dual Temperature Sensor

Page |3

Introduction
This report focuses on the development and construction of a dual temperature sensing system, which interfaces with the internet via the Sparkfun Pro Ethernet microcontroller.

Objectives
The objective of this task was to design and construct a circuit capable of sensing a temperature (from -10C to 50C) and displaying it online (via the Ethernet module of the Sparkfun microcontroller). However, the main objective was to familiarise ourselves with the Arduino code and use the Ethernet connection to display data online.

SAAO - Electronics Department

Dual Temperature Sensor

Page |4

Planning / Design and Calculations Block Diagram

Figure 1

SAAO - Electronics Department

Dual Temperature Sensor

Page |5

Planning
Sensor circuit
Since the circuit we are designing is to sense the temperature, temperature sensing ICs (integrated circuits) were necessary. Most temperature sensing ICs require a positive and negative supply voltage, this was not desirable as we planned to use a single power source (positive voltage). We decide on using the LM3351 IC as it measures in Kelvin, meaning it only operates with positive values. From the datasheet (LM335), the range of the output voltage is from +2.63VDC to +3.23VDC (-10C to 50C) with steps of 10mV per degree Celsius (0C is equivalent to 273K (+2.73VDC)).

Figure 2.1

[LM335 ICs]

SAAO - Electronics Department

Dual Temperature Sensor

Page |6

Amplifier circuit
Selecting the Operational amplifier (Op-amp) IC was challenging as most require a dual supply (positive and negative) for operation. Hence we chose the LM3242, 4 IC as it only requires a positive supply voltage. Because the output voltage range (LM335) is only 600mV (+2.63VDC to +3.23VDC), we decided to amplify this voltage to achieve a range from 0VDC to +5VDC. This was done to fully utilise the analog input voltage range of the Sparkfun microcontroller (0VDC to +5VDC). To calculate the amount of amplification (gain) necessary, the following formula is used (approximately). From this value, the necessary components for the amplifier circuit can be realised.

Figure 2.2

[LM324 IC]

SAAO - Electronics Department

Dual Temperature Sensor

Page |7

Offset circuit
In order to achieve a 0VDC to +5VDC range, +2.63VDC (-10C) had to be reduced to 0VDC. To do this, an offset of +2.63VDC was needed for each Op-Amp (one for each temperature sensor). The offset voltage adjustment circuit was implemented in conjunction with the amplifying circuit, to reduce necessary components and connections.

Figure 2.3

[Potentiometers for offset]

SAAO - Electronics Department

Dual Temperature Sensor

Page |8

Regulator circuit
A variable positive voltage regulator was needed (LM3173 IC was sufficient), due to the fact that the amplifier circuit must be able to output a maximum voltage of +5VDC. The necessary input voltage (from the offset circuit) was assumed to be at least +5VDC. However, through trial and error, it was found that the voltage input necessary was actually larger (+6.3VDC in our case). This input voltage brought about the desired maximum output voltage of +5VDC.

Figure 2.4

[LM317 IC]

SAAO - Electronics Department

Dual Temperature Sensor

Page |9

Components
Type IC LM324 LM317 LM335 Operational amplifier Positive voltage regulator Temperature sensor 1 1 2 4 Resistor 4K7 10K 200K 120 3K3 56K 6K8 100K 330K Single-turn Pot Multi-turn Pot Multi-turn Pot 1% Tolerance 1% Tolerance 1% Tolerance 1% Tolerance 1% Tolerance 1% Tolerance 1 2 2 1 2 2 2 2 2 16 Capacitor 10F 100F Polarised Non-polarised 2 4 6 Diode 1N4007 Connector 3-Way Molex 4-Way Molex 2-Way block 3 1 1 5 Total 30 Rectifier 2 Value Description Quantity

Figure 3

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 10

Circuit Diagram

Figure 4
SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 11

Summary of Operation
In order for the voltage regulator to output a regulated voltage of +6.3VDC, a minimum input voltage of +7.8VDC is needed. For this reason we decided to use a +9VDC power supply as it is commonly found in electrical stores. A 9V power supply feeds the regulator which outputs a regulated voltage of +6.3VDC (this in turn becomes the secondary supply voltage which powers all other components). The temperatures sensors senses the temperature and outputs a temperature dependant voltage. This voltage is then offset by +2.63VDC and then amplified by a factor of 8.3. This amplified voltage is then sent to the analog inputs of the microcontroller. The microcontroller then interprets the voltage(s) in steps, ranging from 0 to 1023 where 0 is equivalent to 0VDC and 1023 is equivalent to +5VDC. The source code within the microcontroller then converts the steps back to an analog voltage. This voltage is then inserted into an equation5 which calculates the temperature as a measurement of Degrees Celsius (C). The calculated voltages and temperatures are then displayed on a webpage.

Figure 5

[Sparkfun Pro Ethernet microcontroller in-use] Dual Temperature Sensor

SAAO - Electronics Department

P a g e | 12

Testing
To test the operation of the amplifier circuit, we needed to ensure that the input and output voltages corresponded. For an input of +2.63V, 0V should be output. For an input of +3.23V, +5V should be output. To ensure a 0V output, the 200K potentiometer (as seen below) must be adjusted. According to the equation; [Refer to figure 6.2] Gain = 4.089 The reason the gain does not equal 8.3, is because the resistor values used for a gain of 8.3 yielded incorrect results (outputs). To calibrate the sensor, the room temperature needed to be known. The Fluke Thermocouple Module (80TK) was used to sense the room temperature.

Figure 6.1

[Thermocouple Module] Dual Temperature Sensor

SAAO - Electronics Department

P a g e | 13

Once this value was known, it was possible to calculate the voltage which should be output from the sensor. The equation was as follows;

Sensor output = +2.9565VDC [If room temperature = 22.5 C] The value being output may, at some point, be incorrect due to the fact that this IC has a tolerance of 0.5C.

Figure 6.2

[Sensor and amplifier circuit]

Displaying the data on a webpage was challenging for three reasons: 1. We had no prior HTML knowledge 2. The USB-to-Serial connector only supplied +3.3VDC, which was insufficient. 3. The microcontroller was unable to upload pictures from the computer to the webpage. The problem, with regard to the HTML knowledge, was easily resolved as there are many helpful resources available online6.
The USB to-Serial connector problem was resolved once we noticed +5VDC may be supplied to the

microcontroller by jumping certain pads below the connector. The reason pictures were not able to be uploaded was because we were under the impression that the microcontroller could get the file from the computer and display it online, which is not possible. This issue was resolved by uploading the images to an image hosting website7, from which the microcontroller would get the file and display it.

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 14

Figure 6.3
SAAO - Electronics Department

[Final Webpage] Dual Temperature Sensor

P a g e | 15

Conclusion
In conclusion, the final constructed circuit performed well with respect to theoretical expectations. At times, the error of half a degree was negligible, as the displayed temperature was accurate to one tenth of a degree. From testing, we found that the temperatures were able to be displayed online which meets the objective of this project.

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 16

Appendix
References

[1] Datasheet: LM335 IC (Pg. 20-23)

[2] Datasheet: LM324 IC (Pg. 24-25)

[3] Datasheet: LM317 IC (Pg. 17-19)

[4] Datasheet: Operational amplifier circuits (Pg. 26)

[5] Equation:

[6]HTML Tutorials: http://www.htmlgoodies.com/

[7] Image Host: http://imagehost.co.za/

Source code (Pg. 27-31)

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 17

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 18

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 19

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 20

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 21

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 22

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 23

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 24

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 25

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 26

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 27
/*********************************************************** Dual Thermometer (online) February 2012 By: Anees Omar and Adrian Wyngaard ***********************************************************/ //Libraries------------------------------------------------#include <SPI.h> #include <Dhcp.h> #include <Dns.h> #include <Ethernet.h> #include <EthernetClient.h> #include <EthernetServer.h> #include <EthernetUdp.h> #include <util.h> //---------------------------------------------------------//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC (Media Access Control) address of the Ethernet Board //EthernetClient client; EthernetServer server = EthernetServer(80); ////Bit Definitions------------------------------------------#define T1 A0 #define T2 A1 // Temperature sensor 1 output // Temperature sensor 2 output // Port select (port 80 is default for HTTP)

//----------------------------------------------------------

//Variables-------------------------------------------------

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 28
float tempV1; float tempV2; float temp1; float temp2; String s; //---------------------------------------------------------// Temperature in volts // Temperature in volts // Temperature in degrees // Temperature in degrees

//Initialisation-------------------------------------------void setup() { Serial.begin(9600); Ethernet.begin(mac); server.begin(); Serial.println(Ethernet.localIP()); } //---------------------------------------------------------// Baud rate (bps) // Start the Ethernet connection and the server // Enables the server (Ethernet board) to start listening to clients // Display the Ethernet boards IP address

//Loop-----------------------------------------------------void loop() { client = server.available(); // listen for incoming clients

if (client) {

while (client.connected()) {

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 29

if (client.available()) {

// wait for data coming from the server

//Calculations--------------------------------------tempV1 = analogRead(T1)/204.8; // Read sensor 1 voltage tempV2 = (analogRead(T2)/204.8) + 0.02; // Read sensor 2 voltage

temp1 = ((tempV1/7.4)*100) - 10; // calculate temperature 1 temp2 = ((tempV2/7.4)*100) - 10; // calculate temperature 2 //---------------------------------------------------

//HTML Code-------------------------------------------------------------------------------client.println("<html>"); client.println("<head>"); client.println("<TABLE ALIGN=\"center\" BORDER=\"5\" BORDERCOLOR=\"green\">"); client.print("<TR>"); client.print("<TD>"); client.println("<title> Arduino Online Thermometer </title>"); // Page title client.println("<meta http-equiv= \"refresh\" content= \"1\">"); // Refresh page every 1 second(s) client.println("</head>"); client.println("<body align= \"center\" style= background-color:#000000 TEXT= #00FF00>"); //Heading---------------------------------------------------------------------------------client.println("<h1 align= \"Center\"> SAAO </h1>"); client.println("<h2 align= \"Center\"> ELECTRONICS DEPARTMENT THERMOMETER </h2>"); //Data Table------------------------------------------------------------------------------client.println("<TABLE ALIGN=\"center\" BORDER=\"5\" BORDERCOLOR=\"green\">");

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 30
client.print("<TR>"); client.print("<TD></TD>"); client.print("<TD align=\"center\" > Analog Voltage </TD>"); client.print("<TD align=\"center\" > Temperature </TD>"); client.print("</TR><TR>"); client.print("<TD align=\"center\" > Outdoor Temperature </TD>"); client.print("<TD align=\"center\" >"); client.print(tempV1); client.print(" V"); client.print("<TD align=\"center\" >"); client.print(temp1); client.print((char)223); client.print("C"); client.print("</TR><TR>"); client.print("<TD align=\"center\" > Indoor Temperature </TD>"); client.print("<TD align=\"center\" >"); client.print(tempV2); client.print(" V"); client.print("<TD align=\"center\" >"); client.print(temp2); client.print((char)223); client.print("C"); client.print("</TR>"); client.print("</TABLE>"); //Footer--------------------------------------------client.println("<h3 align= \"Center\"> By: Anees and Adrian </h3>"); //End of page----------------------------------------

SAAO - Electronics Department

Dual Temperature Sensor

P a g e | 31
client.println("<br>"); client.print("</TR>"); client.print("</TABLE>"); client.println("</body></html>"); // End of the web page //--------------------------------------------------//delay(1); client.stop(); //} } } } // wait 1 milliseconds before closing connection // close the connection

SAAO - Electronics Department

Dual Temperature Sensor

You might also like