Escolar Documentos
Profissional Documentos
Cultura Documentos
About
Projects
Learn
Library
Blog
Store
Forums ladyada.net
Search
April27,201211:17
Overview FSR Photocell Temp. Tilt PIR T-Couple IR decode Thermistor DHT BMP085 TSL2561 Buy sensor Forums
WhatisaPIRsensor?
PIRsensorsallowyoutosensemotion,almostalwaysusedtodetectwhetherahumanhasmovedinoroutof thesensorsrange.Theyaresmall,inexpensive,lowpower,easytouseanddon'twearout.Forthatreason theyarecommonlyfoundinappliancesandgadgetsusedinhomesorbusinesses.Theyareoftenreferredtoas PIR,"PassiveInfrared","Pyroelectric",or"IRmotion"sensors. PIRsarebasicallymadeofapyroelectricsensor(whichyoucanseeaboveastheroundmetalcanwitha rectangularcrystalinthecenter),whichcandetectlevelsofinfraredradiation.Everythingemitssomelow
levelradiation,andthehottersomethingis,themoreradiationisemitted.Thesensorinamotiondetectoris actuallysplitintwohalves.Thereasonforthatisthatwearelookingtodetectmotion(change)notaverage IRlevels.Thetwohalvesarewiredupsothattheycanceleachotherout.IfonehalfseesmoreorlessIR radiationthantheother,theoutputwillswinghighorlow. Alongwiththepyroelecticsensorisabunchofsupportingcircuitry,resistorsandcapacitors.Itseemsthat mostsmallhobbyistsensorsusetheBISS0001("MicroPowerPIRMotionDetectorIC"),undoubtedlyavery inexpensivechip.Thischiptakestheoutputofthesensoranddoessomeminorprocessingonittoemita digitaloutputpulsefromtheanalogsensor. Formanybasicprojectsorproductsthatneedtodetectwhenapersonhasleftorenteredthearea,orhas approached,PIRsensorsaregreat.Theyarelowpowerandlowcost,prettyrugged,haveawidelensrange, andareeasytointerfacewith.NotethatPIRswon'ttellyouhowmanypeoplearearoundorhowclosethey aretothesensor,thelensisoftenfixedtoacertainsweepanddistance(althoughitcanbehackedsomewhere) andtheyarealsosometimessetoffbyhousepets.Experimentationiskey!
Somebasicstats
ThesestatsareforthePIRsensorintheAdafruitshopwhichisverymuchliketheParallaxone.Nearlyall PIRswillhaveslightlydifferentspecifications,althoughtheyallprettymuchworkthesame.Ifthere'sa datasheet,you'llwanttorefertoit Size:Rectangular Price:$10.00attheAdafruitshop Output: Digitalpulsehigh(3V)whentriggered(motiondetected)digitallowwhenidle(nomotion detected).PulselengthsaredeterminedbyresistorsandcapacitorsonthePCBanddifferfromsensor tosensor. Sensitivityrange:upto20feet(6meters)110x70detectionrange Powersupply:5V9Vinputvoltage, BIS0001Datasheet (thedecoderchipused) RE200Bdatasheet (mostlikelythePIRsensingelementused) NL11NHdatasheet (equivalentlensused) ParallaxDatasheetontheirversionofthesensor Morelinks! AgreatpageonPIRsensorsfromGLOLAB\\ NYUsensorreport
Howdoesitwork?
PIRsensorsaremorecomplicatedthanmanyoftheothersensorsexplainedinthesetutorials(likephotocells, FSRsandtiltswitches)becausetherearemultiplevariablesthataffectthesensorsinputandoutput.Tobegin explaininghowabasicsensorworks,we'llusethisrathernicediagram(ifanyoneknowswhereitoriginates plzletmeknow). ThePIRsensoritselfhastwoslotsinit,eachslotismadeofaspecialmaterialthatissensitivetoIR.Thelens usedhereisnotreallydoingmuchandsoweseethatthetwoslotscan'see'outpastsomedistance(basically thesensitivityofthesensor).Whenthesensorisidle,bothslotsdetectthesameamountofIR,theambient amountradiatedfromtheroomorwallsoroutdoors.Whenawarmbodylikeahumanoranimalpassesby,it firstinterceptsonehalfofthePIRsensor,whichcausesapositivedifferentialchangebetweenthetwohalves. Whenthewarmbodyleavesthesensingarea,thereversehappens,wherebythesensorgeneratesanegative differentialchange.Thesechangepulsesarewhatisdetected.
[Citationneeded]
ThePIRsensoritself
ImagefromRE200Bdatasheet Youcanseeabovethediagramshowingtheelementwindow,thetwopiecesofsensingmaterial
Lenses
PIRsensorsarerathergenericandforthemostpartvaryonlyinpriceandsensitivity.Mostoftherealmagic happenswiththeoptics.Thisisaprettygoodideaformanufacturing:thePIRsensorandcircuitryisfixedand costsafewdollars.Thelenscostsonlyafewcentsandcanchangethebreadth,range,sensingpattern,very easily. Inthediagramuptop,thelensisjustapieceofplastic,butthatmeansthatthedetectionareaisjusttwo rectangles.Usuallywe'dliketohaveadetectionareathatismuchlarger.Todothat,weuseasimplelens suchasthosefoundinacamera:theycondensesalargearea(suchasalandscape)intoasmallone(onfilmor aCCDsensor).Forreasonsthatwillbeapparentsoon,wewouldliketomakethePIRlensessmallandthin andmoldablefromcheapplastic,eventhoughitmayadddistortion.Forthisreasonthesensorsareactually Fresnellenses:
ImagefromSensorsMagazine TheFresnellenscondenseslight,providingalargerrangeofIRtothesensor.
ImagefromBHlens.com
Hereyoucanseethemultiplefacetsections
ImagefromIRTEC
ConnectingtoyourPIR
MostPIRmoduleshavea3pinconnectionatthesideorbottom.Thepinoutmayvarybetweenmodulesso triplecheckthepinout!It'softensilkscreenedonrightnexttotheconnection.Onepinwillbeground,another willbesignalandthefinalonewillbepower.Powerisusually35VDCinputbutmaybeashighas12V. Sometimeslargermodulesdonthavedirectoutputandinsteadjustoperatearelayinwhichcasethereis ground,powerandthetwoswitchconnections. Theoutputofsomerelaysmaybe'opencollector'thatmeansitrequiresapullupresistor.Ifyou'renot gettingavariableoutputbesuretotryattachinga10Kpullupbetweenthesignalandpowerpins. AneasywayofprototypingwithPIRsensorsistoconnectittoabreadboardsincetheconnectionportis0.1" spacing.SomePIRscomewithheaderonthemalready,theonesfromAdafruitdon'tasusuallytheheaderis uselesstoplugintoabreadboard. Bysolderingin0.1"rightangleheader,aPIRiseasilyinstalledintoabreadboard!
MostpeoplewanttopositionPIRsinaparticularlocationandoftentimesthatsfarfromtheotherelectronics, inwhichcasewireswillworkjustfine.
TestingyourPIR
OnceyouhaveyourPIRwiredupitsagoodideatodoasimpletesttoverifythatitworksthewayyou expect.Thistestisalsogoodforrangetesting.Simplyconnect34alkalinebatteries(makesureyouhave morethan3.5VDCoutbutlessthan6Vbycheckingwithyourmultimeter!)andconnect groundtothepin
Retriggering
Changingpulsetimeandtimeoutlength
Therearetwo'timeouts'associatedwiththePIRsensor.Oneisthe"Tx"timeout:howlongtheLEDislit afteritdetectsmovement.Thesecondisthe"Ti"timeoutwhichishowlongtheLEDisguaranteedtobeoff whenthereisnomovement.Thesearenoteasilychangedbutifyou'rehandywithasolderingironitiswithin reason. First,letstakealookattheBISSdatasheetagain
can'reverseengineer'themfromtimingthesensorandsolving! ForthesensorintheAdafruitshop: Txis=24576*R10*C6=~1.2seconds R10 =4.7Kand C6=10nF Likewise, Ti=24*R9*C7=~1.2seconds R9=470KandC7=0.1uF Youcanchangethetimingbyswappingdifferentresistorsorcapacitors.Foranicetutorialonthis,seeKeith's PIRhackingpage
Projectexamples
AsimpleroomgreeterthatplaysthesupermariobrothersthememusicwhentriggeredbyaPIRinahacked airwickfreshenerunit.
AUSBpoweredsingingandblinkingMariomushroom(there'savideoonthesite!)
RainUmbrellas
TestingaPIRsensorforinterfacingtoMax/MSPforaninteractivegarden
AhomemadesecuritysystemusingPIRsensors(whichisbuiltintoaStartTrekpanel!)
PIRsensor+Arduino+Servo=automaticcatdoor!
A2PIRmotiontracker byLuckyLarry
APIRbasedremotecameratrigger(alsobyLuckyLarry!)
AninterestinghackwherebythePIRsensorisused'raw'totrackmovement
ReadingPIRsensors
ConnectingPIRsensorstoamicrocontrollerisreallysimple.ThePIRactsasadigitaloutputsoallyouneed todoislistenforthepintofliphigh(detected)orlow(notdetected). Itslikelythatyou'llwantreriggering,sobesuretoputthejumperinthe Hposition! PowerthePIRwith5Vandconnectgroundtoground.Thenconnecttheoutputtoadigitalpin.Inthis examplewe'llusepin2.
p i n M o d e ( l e d P i n ,O U T P U T ) ; p i n M o d e ( i n p u t P i n ,I N P U T ) ; } S e r i a l . b e g i n ( 9 6 0 0 ) ;
/ /d e c l a r eL E Da so u t p u t / /d e c l a r es e n s o ra si n p u t