• No results found

Remote Temperature Monitoring of Electronic Systems: Remote Temperature Monitoring of Electronic Systems

N/A
N/A
Protected

Academic year: 2022

Share "Remote Temperature Monitoring of Electronic Systems: Remote Temperature Monitoring of Electronic Systems"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)

 





RemoteTemperature

MonitoringofElectronic

Systems











MEREAMELͲRUBAIY







This thesis is presented as part of Degree of Bachelor of Science in Electrical Engineering

Blekinge Institute of Technology September 2016

Blekinge Institute of Technology

Department of Applied Signal Processing

Supervisor: Dr. Josef Ström Bartunek, Tekn.lic. Kristian Nilsson Examiner: Dr. Sven Johansson

(2)











































(3)



Abstract



Temperaturemonitoringisusedindifferentapplicationsaroundtheworldinindustriessuch

as the plastic industries, automotive industries, medicine, and food processing. Adding

flexibilityandcosteffectivenesstotheregulartemperaturemonitoringdevicescanexpand

the applications and provide more security to the production and processes for the

industries. Digital temperature sensors provide more accuracy and a wider temperature

detection spectrum; adding the flexibility of remote monitoring and data storage, a more

robusttemperaturemonitoringsystemcanbebuilt.Inthisthesiswork,anArduinodevice

and a digital temperature sensor are used to build a physical temperature monitoring

system. Arduino IDE and Processing are used due to their flexibility in terms of their

operating system, IDE, and cost effectiveness, to program and configure the system. To

tackle the problem of common bad practices used around programming Arduino devices

andotheropensourcedevices,bestpracticeswithinprogrammingandbuildingthephysical

systemareillustrated. 

(4)





Contents





Abstract... ...2

TableofFigures... ...4

1. Introduction... ...5

1.1. TemperatureMonitoring...5

1.2. DigitalProbes:TemperatureSensors...6

1.3. FlexibleandReprogrammableEnvironments...6

1.3.1. Processing...7

1.3.2. ArduinoUno...7

2. Methods... ...8

2.1. TemperatureReading...9

2.2. Alarming... .10

2.3. TheWebInterface...10

2.4. Functionone:LiveTemperatureRepresentationandPlotting...10

2.4.1. DataStorageandRepresentation...11

2.4.2. ProgrammingandSoftware...11

2.5. Functiontwo:Dataloggingoftemperature...13

2.5.1. DataStorageandRepresentation...13

2.5.2. ProgrammingandSoftware...13

3. Results... ...15

3.1. FunctionOne... 15

3.2. FunctionTwo... 16

4. Discussions... ...19

4.1. FunctionOne... 19

4.2. FunctionTwo... 20

5. ConclusionandFutureWork...21

5.1. FutureWork... 21

6. Bibliography... ...22

AppendixA... ...23

AppendixB... ...28





(5)





TableofFigures



Figure1.1:SMT16030TOͲ92casingtemperaturesensor:...6

Figure2.1:ArduinoCircuitBoardDesign...8

Figure2.2:CircuitSchematic...9

Figure2.3:FlowofthetasksdonebytheArduinoBoard...12

Figure2.4:FlowofthetasksdonebytheArduinoBoard...14

Figure3.1:Processingtemperatureplot...15

Figure3.2:TemperaturereadingsloggedintheSDcard...16

Figure3.3:CoolTermcapturewindow...17

Figure3.4:Excelsheetdatarepresentation...18



 

(6)

1. Introduction



Theaimofthisthesisworkistooptimizetemperaturemonitoringandcontrol,intermsof

speed, simplicity, and accuracy, using a simple openͲsourced hardware and software; this

will help in illustrating best practices to be kept under consideration while using such

environments. Within this chapter, the theories behind the methods used are explained,

andthenthehardwareandsoftwarecomponentsareintroduced.

This project can be used by developers in the field of software development, embedded

systemsthatwouldliketomigratetheirworkintotheArduinoenvironment.Theworkcan

alsobeusedbyamateurprogrammersandfirsttimeusersoftheArduinoenvironmentto

starttheirownembeddedsystemsprojects.

Duetothetimelimitationsonthisproject,heatsinksarenottakenintoconsiderationasa

temperaturecontrolmechanism.Also,Javaandotherprogramminglanguagesthatcanbe

usedtoincreasetheattractivenessandthereadabilityofthewebinterface,andthesecurity

ofthewebpagewerenotconsideredduringtheproject.





1.1. TemperatureMonitoring



The need for sophisticated and robust temperature monitoring systems is increasing,

especially for businesses and organizations within the healthcare, food products, and

electronics sectors [1]. Such organizations utilize temperature monitoring technologies to

monitor the temperatures of their products and processes; this is especially important to

safeguardtheirproductsandmeetregulatorystandardswithintheregiontheyaresituated

in [2].   A sophisticated and robust temperature monitoring systems can be defined as

systemsthatincludeandintegratethefollowingcomponents:

1Ͳ Relativelyaccuratedigitalprobes

2Ͳ Thermalbuffers

3Ͳ Flexibleandreprogrammablemeasurementdevice

4Ͳ Datastorageandrepresentation

5Ͳ WellͲdevelopedsoftware.

6Ͳ Alarming:Indicationofabnormalities.

Temperaturemonitoringcanbealsopartofpreventativereliability.Thisisimportantwhen

a system is not performing high temperature processes, yet can be at the risk of

overheating.







(7)

1.2. DigitalProbes:TemperatureSensors



Industries can use the sensors for cold chain integrity, medical monitoring, equipment

monitoring,andenvironmentalmonitoring.Thereareseveralkindsoftemperaturesensors

that are available in the market; thermocouples, RTD’s, thermistors, and semiͲconductorͲ based sensors. The different types of temperature sensors can be utilized for different

applications within different sectors due to their different features in terms of

responsiveness, accuracy, and temperature ranges.  A semiͲconductor based temperature

sensor(SMT160Ͳ30),showninFigure1.1,isused.

 

Figure1.1:SMT16030TOͲ92casingtemperaturesensor:

The temperature sensor has several features that were useful in the project, such as its

energyefficiency,widetemperaturerange,lownoiselevels,lowcurrent,longtermstability,

directinterfacewithmicrocontrollers,andthesmallpackaging[3].

 

1.3. FlexibleandReprogrammableEnvironments



Inthisproject,differenttypesofenvironmentswereresearchedtoidentifycheapandeasy

hardware and software to implement the project and finally get the results desired. The

researchedenvironmentswere:

1Ͳ PinguinoPIC32

2Ͳ STM32

3Ͳ MPS430LaunchPad

4Ͳ ArduinoUno

5Ͳ Processing™

Yet, only two of the above environments, Arduino and Processing™, were used in the

projecttoimplementthetemperaturemonitoringdevice.Arduinoisrelativelycheaptobuy,

hasawellͲroundedcommunitytohelpprogrammers,abundantinEurope,andfeaturesan

openͲsourceIDEwithawiderangeoflibraries.WhileprocessingiscompletelyfreeͲtoͲuse,

andalsofeaturesacommunitythatassistsprogrammersatalllevelsintheirprojects.More

detailsfollowin1.3.1and1.3.2.





(8)

1.3.1. Processing™



ProcessingisaflexibleandopenͲsourcesoftware,sketchbook,andlanguagethatisusedby

students and developers in the field of software development and visual arts.  The

ProcessingsoftwareisopensourceandfreefordownloadontheirwebsiteProcessing.org

[4].  The software can be used to read from serial ports in the computer, timestamp the

data,logthedataintoachosenfile,andthenreadandplotitifrequired.Thecapabilitiesof

thevisualplatformofProcessingcanbehelpfulforprogrammerstoshowresultsusingplots

programmatically.

1.3.2. ArduinoUno



Arduino is an openͲsource prototyping platform based on relatively easyͲtoͲuse hardware

and software. Arduino boards are able to read inputs from both digital and analog ports,

andalsooutputsignalsfromanaloganddigitalports.TheArduinoenvironmentisusefulfor

lowͲbudget projects that require flexibility [5]. The low price and the cross platform

dependency of the Arduino hardware and IDE, as shown in Table 1.1, proved helpful in

buildingandprogrammingthesystemintermsoftimeandresourcelimitations.



Table 1.1 shows features of the Arduino that were useful for the project, such the low price, the

crossͲplatformflexibility,theflexibleIDE,andtheextensiblesoftware.

Pricing Arduino boards are relatively inexpensive

compared to other microcontroller

platforms.Theleastexpensiveversionofthe

Arduinomodulecan beassembledbyhand,

and even the preͲassembled Arduino

modulescostlessthan$50

PlatformDependency The Arduino Software (IDE) runs on

Windows, Macintosh OSX, and Linux

operating systems. Most microcontroller

systemsarelimitedtoWindows.

Theenvironment TheArduinoSoftware(IDE)iseasyͲtoͲusefor

beginners, yet flexible enough for advanced

userstotakeadvantageofaswell.

TheSoftware The Arduino software is published as open

source tools, available for extension by

experiencedprogrammers.Thelanguagecan

be expanded through C++ libraries, and

people wanting to understand the technical

details can make the leap from Arduino to

the AVR C programming language on which

it'sbased.Similarly,youcanaddAVRͲCcode

directly into your Arduino programs if you

wantto.

(9)



2. Methods



In the following sections, the two different methods that are used in the project are

highlightedandexplainedthoroughly.Themethodsaredividedintotwofunctions;thefirst

function includes the project with live temperature representation using Processing, while

thesecondfunctionincludestheprojectwithdataloggingusingaterminalandanSDcard.

Also,thereasonsbehindchoosingthemethodsareemphasizedwithineverysection.Note

thatforbothofthefunctions,thetemperature willberepresentedliveonawebpagefor

easeofaccessoftheuserfromanywhereasexplainedin2.3.Figure2.1showsthedesign

oftheArduinoboardusedasatemperaturemonitoringdevice.





Figure2.1:ArduinoCircuitBoardDesign

To make it easier for the user to understand the ports used in the board and the

connections done, and assist in writing a clearer code in terms of communication and

memory,aschematicsofthedesignismadeasshowninFigure2.2.

(10)



Figure2.2:CircuitSchematic

2.1. TemperatureReading



ThetemperaturesensorreadingalgorithmisthesameforbothFunctiononeandFunction

two.Thishassimplifiedthecodingprocessanddesign.TheSMT160Ͳ30temperaturesensor

hasadutycycleoutputthatwasdirectlyinterfacedwiththeArduinoBoardwithouttheuse

of any extra components in between. The output is a square wave with a wellͲdefined

temperatureͲdependentdutycycle.Ingeneral,thedutycycleoftheoutputsignalisdefined

by:

ܦܥ ൌ ͲǤ͵ʹ ൅ ͲǤͲͲͶ͹ ൈ ܶ(2.1)



whereDCistheValidDutyCycle,TisTemperatureinCelsius;theconstants0.32and0.0047

arespecificfortheSMT16030andarederivedfromthedatasheet.IfTissettoZero,then

the Duty Cycle is at 32%, while at T=130°C, the Duty Cycle is at 93.1%. This shows the

spectrum of the duty cycle utilized by the temperature sensor. Temperature then can be

derivedbythedutycycleby:

ܶ ൌ ஽஼ି଴Ǥଷଶ଴Ǥ଴଴ସ଻ ൌ ʹͳʹǤ͹͹ ൈ ܦܥ െ ͸ͺǤͲͺͷǤ(2.2)



(11)

SincethedigitalinputoftheArduinoboardisusedtomeasurethetemperaturefromthe

dutycycleprovidedbythesensor,onlythehighͲcountcanbederivedfromthedigitalport.

Thustheequation(2.2)isthenchangedintheArduinoprogramto:



ܶ ൌ

೓೎೑

ೞೞ೑ି଴Ǥଷଶ

଴Ǥ଴଴ସ଻ (2.2)



Here, hcf is high count and ssf is the sampling count. Also it is noted that the higher the

samplingcountorsamplingrate,themoreaccuratethemeasurementsare.Thisistruedue

tothemaximumfrequencyofthetemperaturesensor,4KHzwhilethesamplingfrequency

shouldbearound8KHztoreducethenoiseandtheinformationloss.

The temperature sensor is placed in the middle of the laboratory to measure the

fluctuationsoftheambienttemperaturealongtheday.Themeasurementistakenevery2

minutestoavoidoverflowingthememoryoftheArduinodeviceandtoeasethereadability

ofthetemperatureusingtheserialport.

2.2. Alarming



In this project, three different alarming techniques were studied; visual, audio, and audio

video,yetonlythevisualalarmingsystemwillbeutilized.Thevisualalarmingiscomposed

of three LED lights, each representing a temperature where the RED LED represents

dangerously high temperature, GREEN LED represents normal temperature and that the

deviceisworkingproperly,andtheBLUELEDrepresentingdangerouslylowtemperatures.

2.3. TheWebInterface



Part of a robust temperature monitoring device is the facilitation of remote control and

monitoring. This is done in this thesis work by implementing a simple web interface that

wouldallowtheusertoviewthetemperature.Theaccesstothewebpageisrestrictedto

usersonlywithinthenetworktoavoidanyunauthorizedaccess.HTMLandC++wereused

within the Arduino code to build the web interface and refresh the page every second to

updatethetemperaturedata.



2.4. Functionone:LiveTemperatureRepresentationandPlotting



For this function, the temperature is measured and then represented remotely on the

webpage and on a live plot that is done using Processing. The alarming system is used to

alert whenever temperature abnormalities occur. The estimated response time of the

systemis10nsasitisrelativetothemicrocontrollerprocessingspeed.

 

(12)



2.4.1.  DataStorageandRepresentation



InFunctionone,thedataissentbyapredefinedserialport(RS232)totheProcessing(which

isusedasaterminal)torepresentthedatagraphicallyliveandalsotoincludeatimestamp

to the data. The data will also be represented on the webpage.  The Arduino code in

Appendix A and the processing code in Appendix B show the coding algorithm used to

communicatebetweentheArduinoandtheprocessingintheserialportchosen.Processing

code shows that first, the serial communication is started, then the data is received as a

string and then changed into an integer type. This is done because the string reading is

fasterwithinprocessingfromtheserialport.Thishelpsinreceivingthedataasfastasthe

baudrate,hence,moresamplesarereceived.Withinthisfunction,datawillonlybestored

intheterminalforapproximately6months;relativetotheharddisksizeoftheterminal.



2.4.2. ProgrammingandSoftware



InregardsoftheprogrammingofthecodeusingtheArduinoandProcessingEnvironment,

Figure2.3illustratestheflowoftheprogrambetweentheArduinoandProcessingandhow

eachtaskistakendependingonthetemperature.

After the data is received by Processing, a code is written to include a timestamp to the

temperaturedataandthenplotitliveonawindowtothescreenfortheuser.Theplotwill

show historical data depending on the size of the window and the sampling rate of the

temperaturesenttotheterminal.



(13)



Figure2.3:FlowofthetasksdonebytheArduinoBoard







(14)

2.5. Functiontwo:Dataloggingoftemperature



Function two is identical to function one in terms of temperature measurements and

webpage representation; yet, the main difference is the additional feature of logging the

temperatureontheSDcardoftheArduinoandonthecomputerterminalwithtimestamps,

explained in section 2.5.1. Later the temperature data can be plotted to illustrate the

temperaturefluctuationsthroughouttheday,whichisexplainedinsection2.3.



2.5.1. DataStorageandRepresentation



InFunctiontwo,thedataisstoredonaSDcardthatisattachedtotheEthernetShieldofthe

Arduino Board.Afileclassisusedtoprintthedataintoa textfilewithcommaseparated

dataforeaseofconvertingtocsvfileandthentoanillustrativegraph.Also,CoolTermwas

used as a terminal software to read the data from the serial port and timestamp it, then

append the data in a chosen file in the computer hard disk. The SD library from Arduino

librarieswastoimplementthecodeforthecommunicationbetweentheArduinoUnoand

theSDcardattachedtotheEthernetShield.Withinthislibraryfunctionsareusedtocreate

files within the SD card to append data into the files. After each appended temperature

reading,anewlinecommandwasinsertedtoindicateanewreadingtobeappendedinto

thefile.ThecodeinAppendixA,showsthecodefortheSDcardfilesappending.



2.5.2. ProgrammingandSoftware



WhenitcomestoprogrammingthecodetologthedataonanSDcardattachedandonthe

terminal,twoextrastepsareaddedandalibraryfortheserialcommunicationandtheSD

cardcommunicationareused.Figure2showstheflowofthecodewrittenforFunctiontwo.

(15)



Figure2.4:FlowofthetasksdonebytheArduinoBoard





(16)

3. Results



The results aim to show the output of the experiments in the thesis work. This section is

dividedintoresultsfromFunctionOneandFunctionTwo.Theresultswillassistinreaching

the proper conclusion and discussing different methodologies in implementing Arduino

codes. The results from Function One includes the live graphical plotting, webpage

presentationofthetemperature,andvisualalarming,whiletheresultsfromFunctiontwo

includes the temperature logging on the SD Card and the terminal, the webpage

presentation of the temperature readings, the visual alarming, and the graphical

presentationonexcel.



3.1. FunctionOne



ByenteringthespecifiedIPaddressintheURLfieldofawebbrowser,theusercanmonitor

thetemperaturelive.Thereadingsandtherefreshrateofthepagecanbesetbytheuserin

thecodeshowninAppendixA.Figure3.1showstheplotofthetemperaturereadingstaken

by Processing from the serial port.  The code for function one takes up to 75% of the

microprocessor’smemoryandthecompilationtookapproximately6seconds.





Figure3.1:Processingtemperatureplot







(17)

3.2. FunctionTwo



First,thetemperaturelogfromtheSDcardisretrieved.Thememorycardisremovedand

insertedinthecomputerterminal.Figure3.2showsthetemperaturelogfromtheSDcard

file.



Figure3.2:TemperaturereadingsloggedintheSDcard















(18)

During the temperature monitoring, the computer terminal software CoolTerm is running

andtimestampdataisaddedtothetemperaturedatareceivedbytheserialport.Figure3.3

showsthetemperaturelogonthecomputerterminal.





Figure3.3:CoolTermcapturewindow













(19)

Finally,thetemperaturelogsfromtheSDcardandthecomputerterminalarecomparedto

checkifthedatamatchandthenexcelsheetisusedtoreadthedatafileandplotthedata.

Figure3.4showstheexcelsheetpresentationandthegraphplottedusingexcel.Thecode

for function two took 84% of the microprocessor memory and took about 10 seconds to

compile.





Figure3.4:Excelsheetdatarepresentation





















(20)

4. Discussions



The discussion section focuses on providing the best practices based on the results in the

previous chapter. Within Function One, best practices around Arduino coding and usage,

visual alarming, usage of html to present the temperature remotely, and using Processing

for data representation are discussed. Within Function Two, best practices for using SD

cardsandcomputerterminalsoftwarewithArduinoarediscussed.





4.1. FunctionOne



Using Arduino Uno memory alone to implement the html code is challenging due to the

limitedmemoryspaceoftheArduinodevice.Theexpansionofmemoryforcodingusingan

external SD card attached to the Ethernet shield of the Arduino device assists in building

moresecureandbetterlookingwebpages.Alsousingawebpagetoremotelyrepresentthe

temperatureprovidesmoreflexibilityfortheusertomonitorthetemperaturewhileaway

fromtheofficeorlaboratory.Iwasabletoreadthetemperatureregularlyduringtheday

withouthavingtobearoundthedevice.

Using visual alarming, or LED lights, to alert the user of temperature abnormalities was

relativelyeasytoimplement.Buildingthealarmingcircuitandwritingitscodewasrelatively

simple.Abestpracticeforimplementingvisualalarming,istodedicateoneoftheLEDlights,

preferablythegreenlight,tobeonatalltimestoindicatethatthedeviceanditssoftware

areworkingproperly.Itisalsoabestpracticetoindicatethatthetemperaturemonitoring

deviceisworkingproperly.

Asmentionedin.2.3,ProcessingwasusedinFunctionOnetographicallyrepresentthedata

liveonthecomputerscreenoftheuser.UsingprocessingissimpleforArduinousersdueto

the similarities in the IDE, and the parallels in the coding and compilation process. This is

due to the fact that the Arduino IDE is primarily based on the Processing software. The

ProcessingCommunityandthewebsiteprovidesapproximately100librariesfortheusersto

use to expand the usages of Processing within any application. In this thesis work, five

librariesintotalwereusedtoassistinwritingabettercodeintermsoffunctionalities.While

workingwithprocessingtoreceivedatafromArduino,itisimportanttochecktheCOMport

utilizedbytheArduinoboardbeforerunningthecode.Thecheckmustbedonebecausethe

portchanges randomly everytimethe computerrestarts,thusa failureincommunication

occurs.

UsingtheArduinoenvironmenttoimplementthefunctionalitiesoftheprojectwashelpful

intermsofidentifyingbestpracticesincodingandcompilingthecode.Structuringthecode

using functions and classes, was helpful in preserving memory, compilation speed, and

increase the readability of the code. This can help in the replicability of the code and the

project, and in troubleshooting any bugs within the code. Also, the Arduino forums and

(21)

communityprovideslibrariesthatarespecificforanyapplicationrequired.Thishelpedalot

inwritingacodethatmeetstheArduinoStandards.Atfirstadelayfunctionswereusedin

thecodetogivetimeforsomefunctionstoimplementwithinthefunctionalities.Butthen,

it was noticeable that the microprocessor clock would miss some samples and the timing

gets affected negatively causingsome lags and misinterpretation of the analog and digital

pinsreadings.Hence,theremovaloftheDelayfunctionisremovedfromcode.Itisabest

practice to set up a timer in the back instead of using the delay function. This assists in

havingmoreaccuratemeasurementsandutilizingthefullcapabilitiesofthemicroprocessor

intheArduino.



4.2. FunctionTwo



The expansion of the Arduino memory using the SD card was especially helpful in logging

moretemperaturevaluesalongtheday,thusincreasingthesamplesize.Theusercanread

thetemperaturevaluesbyeithergoingthroughthecsvfileorgraphicallyplottingthevalues

usingMicrosoftExcelasaplatform.Also,threedifferentterminalprogramswereusedas

terminals to receive and timestamp the data, yet only CoolTerm provided the flexibility

needed in terms of timestamping, file appending, and the easyͲtoͲuse graphical user

interface.

UsingFunctionTwoasatemperaturemonitoringplatformcanbeconsideredmoreflexible

andprovidesmoreinsightontheambienttemperatureinthesiteorlaboratory.Byreading

thevaluesonexcelsheetattheendoftheday,Iwasabletoidentifythetimeoftheday

wereitisthewarmest,andthecoolest.Incertainapplications,thiscanbeimportantinsite

surveyingtoinstallnewheatingorcoolingsystems.



(22)

5. ConclusionandFutureWork



Inconclusion,thethesisworkisimportantduetotheintroductionofnewandmorerobust

temperature monitoring techniques and the comparison between them. It also helped in

providing new best practices for first time and experienced users within the embedded

systemsenvironment.Thisalsohelpedinbuildingarobustandsophisticatedtemperature

monitoringdevice.

Itisimportanttoidentifythedifferentfactorsthatbuildsarobusttemperaturemonitoring

device, such as the different temperature probes, programming environments, terminal

programs, and visual alarming hardware and software. Identifying those factors at the

beginninghelpedmapaproperplanforthethesiswork.Itisalsoimportanttounderstand

theexactfunctionalityofthetemperaturesensorbeforewritingdownthecodetofacilitate

thethesiswork.

Within this thesis work, two functions were built to identify the differences between two

approaches of temperature monitoring. Arduino, Processing, and CoolTerm were used to

buildthetwofunctions.AnSDcardwasusedtologthetemperaturevaluesexternally.Also,

bestpracticesforalltheenvironmentswereprovided.

5.1. FutureWork



Due to time limitations, some functionalities of a temperature monitoring devices were

excluded.Iftimeandresourceswerenotanissue,javaandotherprogramminglanguages

wouldbeusedtoincreaseattractivenessofthewebpageandoptimizethesecurityofthe

html page. Also, FPGA can also be used to add an extra functionality to the thesis and

identifybestpracticesinusingVHDLorLabVIEWprogramming.TheparallelismintheFPGA

design can be helpful in building a stronger temperature monitoring device in terms of

speedandlogging.Finally,anRTCcircuitcanbeattachedtotheArduinoboardtoprovide

live time stamps for the temperature values. This can increase the readability and reduce

thedependabilityonProcessingandcomputerterminalsfortime.

 

(23)

6. Bibliography



[1]Y. S. X. H. Z. Y. Z. Z. Guangwen Fan, "LargeͲScale Wireless Temperature Monitoring System for

LiquefiedPetroleumGasStorageTanks,"Sensors,vol.15,no.9,p.23745–23762,2015.

[2]V.Raab,"Temperaturemonitoringinmeatsupplychains,"BritishFoodJournal,vol.113,no.10,

pp.1267Ͳ1289,1996.

[3]C. Terry, "Four Most Common Types of Sensors," Ametherm, 16 December 2015. [Online].

Available: http://www.ametherm.com/blog/temperatureͲsensorͲtypes/. [Accessed 14 June

2016].

[4]Processing.org,"Overview.AshortintroductiontotheProcessingsoftwareandprojectsfromthe

community.,"Processing,2016.[Online].Available:https://processing.org/overview/.[Accessed

14June2016].

[5]arduino.cc, "What is Arduino?," Arduino, 2016. [Online]. Available:

https://www.arduino.cc/en/Guide/Introduction.[Accessed14June2016].





 

(24)

AppendixA



ThisappendixincludesthecodeusedfortheArduinoIDEtoprogramitandconfigureitas

temperaturemonitoringdevice.Thiscodeincludesfunctionstosendtemperaturedatavia

theserialinterfacetoProcessingandacomputerterminal,andafunctiontopresentthe

temperaturedataonawebinteface



#include<SD.h>

#include<SPI.h>

#include<Ethernet.h>

unsignedlongnow;

unsignedlonglastSample;

unsignedintsampleSize;

unsignedinthighCount;

unsignedlonglastOutput;

unsignedlongpreviousMillis=0;

floattemperature;

floathcf,ssf;

intsensorPin=2;

constintchipSelect=4;

//EnteraMACaddressandIPaddressforyourcontrollerbelow.

//TheIPaddresswillbedependentonyourlocalnetwork:

bytemac[]={

0x90,0xA2,0xDA,0x0E,0x9F,0x27

};

IPAddressip(192,168,1,3);



//InitializetheEthernetserverlibrary

//withtheIPaddressandportyouwanttouse

//(port80isdefaultforHTTP):

EthernetServerserver(80);



(25)

voidsetup(){

//Openserialcommunicationsandwaitforporttoopen:

SD.begin(chipSelect);

Serial.begin(9600);

while(!Serial){

;//waitforserialporttoconnect.NeededfornativeUSBportonly



pinMode(sensorPin,INPUT);

pinMode(8,OUTPUT);

digitalWrite(8,LOW);

digitalWrite(sensorPin,LOW);

lastSample=0;

sampleSize=0;

highCount=0;

lastOutput=0;

temperature=0;

}





//starttheEthernetconnectionandtheserver:

Ethernet.begin(mac,ip);

server.begin();



}





voidloop(){

unsignedlongcurrentMillis=millis();

//Serial.println(currentMillis);

if(currentMillisͲlastOutput>=50000){

hcf=highCount;

(26)

ssf=sampleSize;

previousMillis=currentMillis;

lastOutput=currentMillis;

temperature=((hcf/ssf)Ͳ0.32)/0.0047;



sampleSize=0;

highCount=0;

}

if(currentMillisͲlastSample>100){

sampleSize++;

highCount=highCount+digitalRead(sensorPin);

lastSample=currentMillis;

}





StringdataString="";//makeastringforassemblingthedatatolog:

dataString+=String(temperature);

//listenforincomingclients

//ifthefileisavailable,writetoit:

FiledataFile=SD.open("datalog.txt",FILE_WRITE);

if(dataFile){

dataFile.println(temperature);

dataFile.close();

}

//printtotheserialporttoo:

EthernetClientclient=server.available();

if(client){



booleancurrentLineIsBlank=true;

while(client.connected()){

if(client.available()){

(27)

charc=client.read();

//ifyou'vegottentotheendoftheline(receivedanewline

//character)andthelineisblank,thehttprequesthasended,

//soyoucansendareply

if(c=='\n'&&currentLineIsBlank){

//sendastandardhttpresponseheader

client.println("HTTP/1.1200OK");

client.println("ContentͲType:text/html");

client.println("Connection: close");  // the connection will be closed after completion of the

response

client.println("Refresh:5");//refreshthepageautomaticallyevery5sec

client.println();

client.println("<!DOCTYPEHTML>");

client.println("<html>");

//outputthevalueofeachanaloginputpin

client.println("</html>");

client.print(temperature);//herethecommsbetweenarduinoandthewebserver

Serial.println(temperature);//herethecommsbetweentheprocessingandarduino



client.println("</html>");

break;

}

if(c=='\n'){

//you'restartinganewline

currentLineIsBlank=true;

}elseif(c!='\r'){

//you'vegottenacharacteronthecurrentline

currentLineIsBlank=false;

}

}

}

(28)

//givethewebbrowsertimetoreceivethedata

//delay(100);

//closetheconnection:

client.stop();

}

if(temperature<100)

digitalWrite(8,HIGH);

}













































(29)

AppendixB



AppendixBincludesthecodeusedinProcessingtoreceivethetemperaturedatafromthe

serial interface and plot it on a graph on the computer screen. It includes functions for

convertingthedatafromintegertostring,tofacilitateitsreadingbyProcessing,andthen

fromStringbacktoIntegerforplotting.



importprocessing.serial.*;

SerialmyPort;

intcurrent;

floatinByte;



int[]yValues;

intw;



voidsetup()

{

size(640,360);

w=widthͲ10;

strokeWeight(3);

smooth();//ornoSmooth();

yValues=newint[w];



myPort=newSerial(this,"COM6",9600);

}



voiddraw()

{

//Herearesimplificationspossible

//Probablywithread()http://processing.org/reference/libraries/serial/Serial_read_.html

//AndgetridofthisStringͲStuff

StringinString=myPort.readStringUntil('\n');

(30)



if(inString!=null){

inString=trim(inString);

inByte=float(inString);

current=int(map(inByte,0,1023,0,height));

println(inByte);

background(55);



for(inti=1;i<w;i++){

yValues[iͲ1]=yValues[i];

}



yValues[wͲ1]=current;



stroke(255,200,0);

line(w,current,width,current);

strokeWeight(1);

line(0,current,width,current);

strokeWeight(3);



for(inti=1;i<w;i++){

stroke(220,75,yValues[i]);

point(i,yValues[i]);

}

}

}











References

Related documents

The aim of this paper was to introduce and use the online workbench for electrical experiments created at BTH for the students at Katedralskolan in Lund. The remote lab gives

We disregard other pairing candidates as unlikely for reasons given elsewhere 3-51 .These are shown on a cuprate lattice below and we will now discus how we can obtain a low

In this section the nonlinear least squares problem that is solved in order to find the smoothed estimates of the vehicle motion is formulated. In other words, the vehicle.. states

Re-examination of the actual 2 ♀♀ (ZML) revealed that they are Andrena labialis (det.. Andrena jacobi Perkins: Paxton &amp; al. -Species synonymy- Schwarz &amp; al. scotica while

Similarly to the global mean response, the magnitude of the latitudinal and regional temperature responses per unit sul- fur emission is substantially larger in the 0×EU experiment

Samtidigt som man redan idag skickar mindre försändelser direkt till kund skulle även denna verksamhet kunna behållas för att täcka in leveranser som

The development of this project includes the production of a set of tools and components, such as the METERON Robotic Services (MRS), the METERON Operations Software (MOPS)

• User is out in the city and wants to show pictures stored in a home device • Using a mobile phone, user accesses the home device with the photos • The mobile phone can also be used