Sobasically, ifthetemperatureisbelow, a certainlevelofthelightisgreen.
If a typicalgoesabove a certainlevel.
Butthelightisred, right?
That's thetypeofprojectyoucould d'ohwithanart.
Weknow.
Butoneoftheproblemscomesupiswhathappensifthere's not a usertheretovisuallyseewhatevertypeofnotificationthatyou'retryingtopresent.
Sowhatifsomebodyisnotlookingat a Webbrowsertosee a notificationevent?
Whathappensif a userisnoteveninthebuildingtoseeanledturnonorturnoff?
Wouldn't itbeniceifyou'regood?
Weknowprojectcouldsendyou a notificationusing S M T p basicallyusingemailserviceissowhateveremailclientyouhave, whetheryouhave a desktopcomputer, whetheryouhavesomekindofsmartphoneorwhetheryouevenhave a smartwatch, youcangetnotificationsnomatterwhereintheworldyouare, whattimeofdayitissoonandsoforth.
Andsotheprojectthat I'm goingtoshowyouhowtodotodayiswe'regoingtouse a simpleandalongtemperaturesensor.
Andwhenthetemperaturegetsabove a certainlevel, what's goingtohappenisourArduino, youknow, withWiFiisgoingtopostto a PHPscripton a server.
I amgoingtobeusing a simpleandalongtemperaturesensor.
Now.
Itisimportant, understand?
I usetheanalogtemperaturesensorbecauseit's just a veryeasysensortouseon.
Giveitthresholdsforcodewithintheartery.
No, butrealizeyoucanuseanysense.
Orbasically, youcanstateif a sensortriggersorthevaluegetsto a certainyouknow, heightorsearchinglow, youcantriggeraneventtohappen, soitisimportanttorealizethat.
Butsowe'reusingtheartery.
No, no, no.
We'reusing a basicanalogtemperaturesensor, andthenwhatwe'regoingtouseiswe'regoingtousethepostfunctionwithinthepostabilitywithintheartery.
NounaWiFitopostuptoAPAPscripton a sharehostingplant.
Soitisimportantunderstandwiththisprojectthat I amusing a sharedhostingplanfromGoDaddy.
Andthere's a reason I'm using a sharedhostingplanfromGoDaddy.
Inordertosendouttheemail, we'regoingtouse a PHPfunctionsimplycalledmail.
Soifyou'reusingthePHPscriptinglanguage, thereis a functionthatyoucoulduseColdMale, andwhatthatmalefunctiondoesisyougiveitthevariablesthatyou'regivingit, andthenituseswhateverthedefaultemailserviceforthatserveristobeabletosendoutthe e mails.
Whenyou'rebuildingyourWebserver, youinstall a Paki, youinstallmysequel.
SowhenyoucallthemalefunctionwithinPHP, itsimplyusesallthattosendoutthe S and T P.
Massive.
Sowhatisimportanttounderstandthatifyoudecidetobuildyourownlampservertodothisproject, you'regoingtohavetoinstallyourownemailserviceis, andthatcouldbe a paininthebutt.
Tobepolite, itcouldbe a paymentabout.
Thisisoneofthosetimes, especiallyifyouarelearningyou'renotplanningtoputthisinto a productionenvironment, I wouldhighlyrecommendyousimplyspend $5 a monthfor a sharedhostingplanagain, Whetherit's go, Daddy, Daddy, yourhostGator, I don't carewhoitis.
Spend a coupleofdollarssothatyoudon't havetobuildyourownserverforthisparticularproject.
Butthisisjustsomethingtokeepinmind.
Soevenifyouhave a lampserver, evenifyouhave a fullWebserverwithPHPinstalledifyousaidtheposttothatservertothescriptonthatserver, thatserverwillnotbeabletousethemailfunctionunlessyouhaveconfiguredtheemailserviceisontheserver.
Sojustkeepthatinmind.
Withthisproject, we'regoingtobeusing a sharedhostingplan, andthat's what I wouldhighlyrecommendforyou, especiallyifyou'relearning.
Andhonestly, evenifyou'renotlearning, ifthisisn't likethisis a highsecurityisnothighsecuritytypemessageandthatyou'redoinghonestly.
I justpay $5 a monthfor a shareofhostingplan, justso I don't havetoworryaboutit.
Butyeah, that's mesothatlet's goover, take a look, howtophysicallybuildthisproject, andthen I willshowyouthecode.
Sowe'regoingtobewriting a sketchfortheArduinoandthenforoursharehostingserver.
We'realsogoingtoberightin a p A P script.
Sothisisagainoneofthereasonswhy I laughsohardwhenpeopleaskwhatonewhatone?
Thelanguagetheyshouldlearniftheywanttobe a coder, becauseinreality, evensomethingassimpleaswhat I'm showingyoutodayactuallyusesmultiplelanguagesinordertomakethisthingwork.
So I reallywantyoutostartrealizingthatwhenyoustartthinkingaboutCodyandwestartthinkingaboutthecoyoteworld, it's notaboutlearningoneproductoronelanguage.
It's gonnabe a post, sowe'regonnasayPostandthenthisiswhereweputinthefolderstructureandthescriptthatwe'reactuallypointingat.
So I havecreated a foldercalledTestonFailnormaldotcomandthenPHPscriptweweresendingthispostdatatoisemailscriptdotPHPandtheyweresimplysayingis a T T p 1.1.
Solet's gooverandtake a lookattheemailscriptNowagain, Wheneveryou'redealingwithPHP, doyourealizeyoucansimplywritePHPinanykindoftexteditoryouwant?
Ah, lotoftimes, especiallyfortheseprojects, I willshowyouthisin a basictexteditorbecause I thinkit's easierandmorecomfortableforespeciallynewpeopletoworkwith, butyoucanuse I deeseorwhateverus.
Butliterally, I'm simplyusingtextediton a Macinordertowritethis.
I sometimessimplyuse a puretimevariablejustfortroubleshootingpurposeistomakesurethingsareautoupdatingwhere I'llputthetimevariableinthere.
Yes, so I canseethenumberchangeseverytime I refreshthepagelikebecausethat's all I careabout.
Butoneofthethingsisintherealworld, youmayactuallyhavetohavetimeinin a formatthatmakessenseto a normalhumanbeing.
Andsowhatwe'regoingtodohereisthatwe'regoingtocreatethetimestampvariabletimestampvariableisgoingtobeequaltothere's somethingcalledthedatefunctionset a datefunctionandinthedatefunction.
We'regrabbingthevaluethathasbeenpostedfromtemp, andwe'returningthatintothevalueforthevariabledollarsignTip F thenpassedthatwe'regoingtogodown, andwehavetogivethemalefunctionthevaluesforvariablesthatitneeds.
Here I havethisprintscriptrantime, andsoforprint, thisactuallyprintsoutto a webpageso I cangodirectlytothisscript.
Andif I godirectlytothescript, itwillfireoffthescript, and I'm usingthisas a troubleshootingtooljusttomakesurethisscriptisactuallyfiring.
I'llshowyouthatsecond, butthisisthecodethat's requiredfourforthisparticularprojectsothatletmeletmeletmeactuallypoweruptheboardanduploadthecode, and I'llshowyouhowthisworks.
Okay, so I'veuploadedthescriptand I'vepowereduptheboard.
Thisisbasicnormalthingthatgoesthroughthan a fewseconds, willgetournicelittle I P addressand I'llstartspittingoutthetemperature's okay, s s i d istest I p addresses 1 72 16 42 5 Nowoneofthingsthat I'vedonehereis I'veturnedontheshowtimestampagain.
Soif I gooverhereand I putmyfingeronthetemperaturesensor, wewillthenseethetemperaturegoesup, goesup 78.23 Andthenonceitgoesabove 80 nowweseeitsays e mailsent.
Nowagain, I willwarnyouifyou'regoingtobedoingthisprojectifyouIfyoudon't have a serverthat's builtwithemailfunctionalityalreadysetup, I wouldhighlyrecommendyoujustuse a sharedhostingplatform.
Sharedhostinginsistserver.
Getthreebucks.
Fivebuckswhateverpermonth, I thinkwillmakeyourlife a hellof a loteasier.
Hostingservermightmakeyourlife a hellof a loteasierto, becauseifyou'rerunningthrough a sharehostingserver, youdon't havetoworryaboutpowersuppliesfailing.
Youdon't worryabout a lotofweirdthingsgoingon, sothisisjustsomethingtokeepinmindnow, issuesthatyoumayrunintousingthemalefunctionon a sharedhostingserverisdependingonhowstringentyourantispammeasuresarewithinyourenterpriseoftheseemailmessages.
Itmayjustsimplydeleteit, forwhateverreason, againbecause, as I showedyou, itcouldbe a phishingattack.
Rememberthatfromthatfromallthatfromisistext I couldputinwhateverthehell I couldputinsupportatBankofAmericadotcom.
Sothere's a reasonwhy a spamsystemwouldsimplydeletethistypeofthing, becauseliterallywhat I justshowedyoucouldbecouldbe a typeofphishingattackifyouwantedtobuilditthatway.
Soone.
Ifyou'reusing a strangeit's Pamsystem, justrealizeyoumaynotgetyouremailmessagesortwo.
Butagain, ifyougowith a simplegowith a clean a cleanof $5 a month, goDaddy, yourhostgatororwhateversharinghostingplanandthismalefunctionshouldworkfineforyou.
Now, ifyouareworriedaboutSpanishuseoranythinglikethat, youremailmessagesnotgoingthroughoneoftheclasseswherethevideoswewilldowhenthefutureisusingsomethingsuchaslike a sendgridap I ordersent e mails.
Butthenthatrequiresusthey'regoingtodothis, integrate a p I andsaidfor a sin, Greatempire.
Soonethingthat I wouldtellyou, ifyou'rethinkingaboutusingsomethinglikethisandagain a productionenvironment, I wouldreallysayTakethetimeandenergytolearnhowtointegrate.
SentBigRed, I thinksendGridisfreeforupto 100 emailmessages a day.
Somethinglikethat.
I wouldargue, if I wasgonnadothisinproduction, I wouldprobablyintegrate.
Send a gridintothesystem.
You'llprobablygetbetterresultsforbeingabletosendout e mailsandmakesureeverythingisisgoodandyoudon't runintoanykindofweirdproblems.