0% found this document useful (0 votes)
11 views

Open-Source Light Meter

Uploaded by

david reyes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
11 views

Open-Source Light Meter

Uploaded by

david reyes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
2218122, 20:18 ‘Open-Source Light Meter ELECTRO SCHEMATICS ~ 0 ~— ndverisement Home (https:/fwwwelectroschematics.com) » Arduino (httos/wvww.electroschematics. com/category/arduino/) » ‘Open-Source Light Meter (httpsswmwelectroschematics.com/wp- content/uploads/2017/09/2-Hardware-Setup-e1505962513790,pg7fit-559%2C589) Open-Source Light Meter "1 HAREENDRAN (HTTPSU/MNWELECTROSCHEMATICS COM/AUTHOR/HAREENDRAN/) i et GOES dor te Ro al Race ok COORESEUNEDNS HOME o ceoMaatoan. Cookie Settings Accept Al hitpsshwuwolectroschematis.comlopen-source-ightmeter 1a Light meters, these days, are no longer a mystery: From home-improvement stores to eBay and Amazon you canfind have atleast afe HRD. SCHEMUAT IOS oveven sone nat you ‘won't find too easily. If such an expansible light meter cannot be bought, then why don’t we just build one ourselves? Well, here is an open-source, Arduino-based/light meter that allows you to measure the amount of light with the help of a digital ambient light sensor, the BH1750FVI (http://www.mouser.com/ds/2/348/bh1750fvi-e-186247.paf), from ROHM. Light Sensor Module ‘There are a few different BH1750FVI modules available on the internet, and the best part is that they’re all pretty much the same. For this project, used a GY-30 light-intensity module from eBay that is based on the same BH1750FVI digital ambient light sensor. The module is, in fact, a BH1750FVI breakout board with a built in 16-bit ADC, which can directly output a digital signal, so there is no need for complex math. The module, with PC interface, outputs data directly in lux (Ix). In addition to the well-calibrated light sensor, you can find a low- voltage regulator and logic-level translator components in the same module. The module can be powered from any 3.3- t05.0-V DC source. As you will have seen, the module has five pins, while we need two for power supply (VCC and GND) and two for F° interface (SCLand SDA). The extra pin (ADD) can be used to set the I°C address of the sensor; floating or connected to GND, the PC address will be 0x23 (default), and if connected to VCC, the address will be ox5C, 'BH1750 breakout board Microcontroller & Display ‘The rest of the hardware is based on an Arduino Nano and sports a 0.96-in. OLED display with a resolution of, 128 x 64, Luckily, eBay has tons of 0.96-in. OLEDs (with either SPI or PC interfaces) and Arduino Nanos (16 MHz @ 5) for a few dollars. Arduino Nano is very small; thus, it does not take up too much space. Furthermore, it has more than enough I/0 for our application and includes a USB port for easy programming — pretty great! ‘We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept {Af you consent to the use of ALL the cookies. However, You may vsit"Cookie Settings” to provide a controlled consent. Cookie Settings Accept Al hitpsshwuwolectroschematis.comlopen-source-ightmeter 23 2218122, 20:18 ‘Open-Source Light Meter ELE EMATICS Hardware wiring schematic The Code ‘That covers the hardware; now, onto the software. The code is simple, really; it’s amazingly short. lam using the excellent “u8glib library” to drive the OLED display. Take note: My OLED display doesn’t have a couple of PCaddresses, but it had a unique “hard-wired” (default) address ox3C (thanks to my home-brewed °C scanner). Here is a copy of the tested code: ‘We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept {Al you consent to the use of ALL the cookies. However, You may vsit"Cookie Settings” to provide a controlled consent. Cookie Settings Accept Al ana 2219122, 20:18 ‘Open-Source Light Meter . ELECTRO SCHEMATICS 0 Arduino Nano/Unot 8.96", 26x64, OLED (5501386) Display fxperinental Sketeh/vi.e Lux (1x) 4s the undt of Siuninance in the International System of Untts ($1) x Ss defined in terms of lumens per neter squared (In/n2) a sinclude 5 include “uaglt. UuacL16_ss013e6_228%64 use(UB6_12C_0PT_NONE | UBG_12C_0®T_DEY_0); ne SH07_adé = 0x23; // 120 aderess of sxx750 byte burFL2)5 void setup() ( wire. begin sH750_tnit(era7_add); delay (200); > vod 1ieht() ‘float val ue s08Font(ate_font_unifont); sg sexPrintres(@, 58); A (911750_Reas(GHA7 aa) == 2) { valé = ((OuFF[A] << 8) | bUFFLAD) / 2.25 AF (val ¢ @)uBg.petne("> 65535"); ‘We yg cookies on our website to give you the most relevant experience by remembering your preferences and repeat vs Al, You consent to the use of ALL the cookies. However, vou may visit "Cookle Settings" to provide a controlled consent. code eines Rese Ugsprint OTKGHAREENORAN");/7 Custom Text hitpsshwuwolectroschematics.comlopen-source-ightmetet By clicking "Accept ans 2219122, 20:18 ‘Open-Source Light Meter “= ELECTRO SCHEMATICS sg. print(*~ 0 ag. setPrintios(@, 48); Uug.orint(*Light Mater"); // Coston Text Ung setPrintPos(®, 68); sg print (Ci alt, DEC): Uuagsprint(™ Le/ST")s 17 ) elay(200); > vod 100p() vg FlrstpageQds aot aieneos } while (uBg.nextPage()); old SH7S@_ante(int adress) { ire. begintransnission address); wie wete( x9); wire endtransnission(); byte BHi7S@_ReaeCint address) ¢ ire. begintransnission(scdress); ire requestrron(address, 2); We téldtiesoavtieAiasit 6 give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept Al, you consent to the use of ALL the cookies. However, vou may visit "Cookie Settings” to provide a controlled consent. buté[1] = hire.read(); [Cookie Settings Accept Al psn croschomaticscom/open-sourcedight-mster 93 2219122, 20:18 ‘Open-Source Light Meter ‘cova, ELECTRO SCHEMATICS i ; Here is the prototype in action. At first, I used my trusty Arduino Uno (R3) to conduct the experiment. Look, my new Nano (v3) is waiting there in the wings! Hardware setup showing cferent light level readings Power Source Selection Ifyou prefer a portable light meter project, then you can enclose the finished project in a suitable, ready- made/3D-printed enclosure, of course, with a compact power supply. Because the Arduino Nano expects a 6- to 20-V unregulated power supply through its VIN terminal (pin 30), a safer solution would be to use a 2S Li- ion/LiPo battery (~7.4 V), which would be plenty to run the whole system, Shown below is the add-on circuitry for this modification with a socket for a DC barrel plug to connect the battery charger and a toggle switch to turn the system on and off. The DC socket is wired in a way that the battery supply is disconnected from the rest of the electronics when the barrel plug of the charger is inserted into it. If you want to run the light meter even while charging, you should add a suitable load-share circuitry (not included here) to fulfill the requirement. POWER Schematic to adda battery talow for portability Luckily, the Arduino Nano can be powered via the Mini-B USB connection, 6~ to 20-V unregulated external power supply (pin 30), or 5-V regulated external power supply (pin 27), and the power source is automatically selected to the highest voltage source, As I get a lot of questions about how to run an Arduino off of solar panels, Iwant to do abit of experimenting to come up with a simple way to run an Arduino even if we aren’t neara computer or a power outlet. I will look at the possibility of a project on this when I have a little more time. So please stay tuned to try my solar-power bank design for Arduino! ‘We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept Al, you consent to the use of ALL the cookies. However, vou may visit "Cookie Settings" to provide a controlled consent. Cookie Settings Accept Al hitpsshwuwolectroschematis.comlopen-source-ightmeter ens 2219122, 20:18 ‘Open-Source Light Meter RO SCHEMATICS Extensive Assomt ‘Automotive Electr 0 © woKo TECHNOLOGY LTD Previous Build Your OwnSmart__(httpsd/Wwwwielectroschematiescom/smart- Bike Battery Gauge bike-battery-gauge/) Next Weekly Rouncup~ Top (https:/wwwelectroschematics.com/weekly- Links for the 4th Week of September 2017 roundup-top-links- Related Tutorials ESP52 — Getting Started the Easy Way! (htps://www.electroschematics.com/esp32~easy-play/) Hacking a Camera Shutter with Infineon TLE94112LE and Arduino ~ Part 1 (https://www.electroschematics.com/hacking- camera-shutter-infineon-tleg4riale-arduino-part-1/) ‘SIMB00l ONE-CHANNEL SMS RELAY (https://www.electroschematics.com/sim80ol-one-channel-sms-relay/) IR Decoder & Encoder — Part 1 (https://www-electroschematics.comyir~decoder-encoder~part-1/) Recent posts + DIY Subsea Light (nttps:/mwwelectroschematics.com/subsea-light/) + Secret Power Switch (httpsu/wmwwelectroschematies.com/power-swite/) ‘+ Modbus RTU Relay Module (https:/mwwielectroschematics.com/modbus/) + BBC MicroBit Quick Refresher (https://wwwelectroschematics.com/microbit/) + XH.Mé03 Battery Charge Controller Module (https://www.electroschematics.com/battery-charge-module/) 6 Comments Join the conversation! You must be logged in (https://www. electroschematics.com/log-in/) to post a comment. ‘Weuse cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking"Accept AlltSroGivesinthisithselsbot! tb gerbhiotifieation soffollat ifpoberiertings tiawitmildivuleaarisasubscribe (https://www-electroschematics.com/comment-subscriptions/? Stp=13294 srk 49917252f13a91d5feeo7A5bbS51175cRsra=sRsrst ) without commenting, croschomaticscom/open-sourcedight-mster m3 2219122, 20:18 ‘Open-Source Light Meter by @ Weuse SSeRebSG WEB ELECTRO SCHEMATICS T.K.Hareendran 0 (@Adam Carlson: Yes, in order to reduce the current (low- level contrast) with the OLED on, we would have to write tothe register ox81. Very good suggestion indeed. As itis the time to add some more features to my light meter, Ijust started revisingall in order to come out with aclean slate! Poston September 271h207 | 1:18 a htps/tanectroschematlsonopen source kght-meter/tcomment- 1902922), ‘# Login to Repi (https: electroschematicscomn/wp-login phpeditect_to-https¥gAwaPKaFWwew electroschiematies.com#aFopen= source-light-meters2F) T.K.Hareendran @Adam Carlson: Thank You! As you might noticed, this 128*64 OLED display is controlled by SSD1306 (https://edn- shop adafruit.com/datasheets/SSD1306. pdf (iteps://ed-shop .adafruit.com/datasheets/SSD1306 pdf). It has 256-step (0 255) brightness/contrast control. Regarding the brightness/contrast control commands, | still need to dig in this part deeper. Poston September 22 2017|12:49 mnie nen ‘Login to Reply hips: electeoschematics. Pe Adam Carlson IcTooks like it would bea value write to address of ox81 proportional to the light coming in from the meter. You ‘would need a transfer function of the 16bit read of the sensor. In pseudo-code it might look like: schematics conopen-sorceHah-reter/#comment-1902918) smwp-login.php?redirect_fo-huipstsnsabhaF wu electroschematis comaFopen= sourcelight-meter#2F) arbi 10 display int_8 minoisplay setting = 58; //Value of wine 26 displaysrigntness; Value se ry and should be set at the lowest that 1s readable in Atsplayardghtness = buff{@) + sinptsplay; AF (Gisplaysrightness <255) ‘ wriver2c(ona1,tsplayBrightness); //use the appropriate command to write the value to the display > ‘ wrsver2c(oxa1,255); 1/50 to wax value for B bSt brightness control > Posted on Sepeber 2nd 2017 | 59 pm ps tneelectoschenates conopen-sourceihmeteseorment-902919) . Adam Carlson ‘TK, do you plan to mount the light sensor opposite of the OLED soas to reduce the light that might get transmitted from the sei esas la Ral peal eet SP RIAN SSR PRRE HPO Recepe All you cERREo Ke TREBRATE HE CDERALLY HVA LsHAT AN SCABRIE SRANAES HSPH ae HIN RATCSTBREE Cookie etn SviRsag NN 2017 | 1:19 pm tosutwonelecrorcromtic.comlope- source lene-meter/tcomment19029%3) psi croschomaticscom/open-sourcedight-mster ans 2219122, 20:18 ‘Open-Source Light Meter ‘Login to Reply (htsps:/aclectcoschematics com /wp-login.phpredirect_to-huipshaasaFKaFwww clectroschematies.com#2Fopen ELECTRO SCHEMATICS 8 ae , ” px I.K.Hareendran @Adam Carlson: Yes, it’s crucial to position the light sensor in such way that no other stray light is able to be incident on it. Regarding enclosure design, postion of the light sensor should be aa point much higher than the OLED display pane! Display intensity control, based on the ambient light level, is a smart idea. Thank You! [will take @look into the possibility when I've enough spare time, it cals fora few sturdy code lines though. Poston Saptemser 2152017 12:44 am ftps: wnenslectoschenatcscomiopen-seure ght tei#commen- 1902914) Pre Adam Carlson understand the spare time issue! I have not really played with these I displays. Is the intensity ofthe screen control based upon a digital value written to the screen, ors it PWM controlled? Poston Sepember 22nd 2017 | 1240 am htos/vweectroschemais convopen source igen tconvmant-1902925) Login Email Password ) Remember Me Register (htepsfwwwclectroschematis.comjregister) | Lost your password? (httpsffwvew electroschematicscomflostpassword) Latest Article Comments Single Pushbutton Run-Stop...(https://www.electroschematics.com/single-pushbutton-run-stop-circult/#li-comment- 1903918) think RI needs tobe corrected toa knot 10k. Ata 12v supply a 10k il iit toa point the” ‘Weuse cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept VRS SR aF the HARB Be Maer Control Tipe aie lectroschematies com reviaWoF the hie 88) -de-motor-control- cmansleiti-comment:1903917) ‘baleal: Thanks for your response. Now | am itlebit confused so share the link of CSM'5350" pss troschematics.com/open-sourcedight- meter! ona 2219122, 20:18 ‘Open-Source Light Meter roetirceatt con enehoes TAY SCHEMATICS" otro Marches ood RO" i ‘module/#-comment-1903915) “Hi, Hareendran, This"eryptic"5V linear regulator chip marked 2s MS350B isalow-power” HW-585 PC CPU Fan Speed...(https://www.electroschematics.com/fan-speed-controller/#li-comment-1903914) Thanks TK.I did change the resistors to 12K and it worked indeed! I've ordered two trimmers View More () Advertisement ‘We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat vs Al, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent. By clicking "Accept hitpsshwuwolectroschematis.comlopen-source-ightmeter son 2219122, 20:18 ‘Open-Source Light Meter ELECTRO SCHEMATICS 0 Recent Posts + DIY Subsea Light (nttps:/mww.electroschematies.com/subsea-light/) ‘+ Secret Power Switch (https:/wwwzelectroschematics.com/power-switc/) + Modbus RTU Relay Module (https:/mwwuelectroschematics.com/modbus/) ‘+ BBC MicroBit Quick Refresher (https://www.clectroschematics.com/microbit/) ‘+ XH1-M603 Battery Charge Controller Module (https://wwwelectroschematics.com/battery-charge-module/) Most Popular Tags ICDatasheet(httos:/ Www Electroschematics Con/Tagil-Datasheet Circuits LED (Https//WonwElectroschematics Con/TagiLee-Circuits/ We ue SSR Sir oUPWEBANENS ave you the Mut relevant ExpetenCe by Fememnbet hg your preferences and repeat visits. By clicking “Accept Alyssa naw a thn cRRKIES CRU RIRAYERHAGRY visit "Cookie Settings" to provide acontolled consent. Conn etiadorgers ets Wvnv Electroschematies Com/Tap/Batlery-Charger-Cieuits/) psi croschomaticscom/open-sourcedight-mster nna 2219122, 20:18 ‘Open-Source Light Meter invari ee AO, SCHEMATICS Solar Chargers (Https://Ww.Electroschematies. Com/Tag/Solar-Chahflr-Circuits/) AVR Tutorial (Https:/ Ww Electroschematics Com/Tag/Avr Tutorial) Led Flashers (Hetps:hWorw Electroschematies ConyTog/Led-Flasher-Citcuts) ‘Arduino Tutorial (Https/WwewElectroschematies Com/Tag/Arduino-Tutorial) LDR (Httpsu/ Wie Electroschematics Conv Tag/tdr-Circuits/ 409 (Httpsf wwe lectroschematies Com/Tag/4093-Circits) 4060 (Https/ Wa Electroschematies Com/Tag/4060-Circuits/) Water (tepsu/ WE letroschematies Com/TagiWater/) Top 10(Https:/Wwvn ElectroschematicsCom/Tag/Top-10-Circits/) Relay Httos:/NWwnwElectroschematies Com/Tag/Relay) Use (tttpsu/ Wie lectroschematics Com/Tag/Ush-Circuts/) 4017 (Hutps¢wwweElectroschematies Com/Tag/40417-Circits) ‘Automotive Https//Wwn.Electraschematics Com Tag/Automebile/) ASPENCORE NETWORK PRODUCTS: Electronic Products (https://www electronicproducts.com/) Datasheets (https://www.datasheets.com/) ‘TechOnline (https://www.techonline.com/} DESIGN: EDN (https://www.edn.com/) Electronics-Tutorials (https://wwwelectronics-tutorials.ws/) Planet Analog (https://wwwplanetanalog.com/) eWbauecactiegsn punnstelistaniueyesiihs most relevant experience be rememSr OR AGHE NEWS ANALYSIS: EE Times (httos:/imwweetimes.com/) EE Times Europe (httos://www-eetimes.cu/) Power Electronic News (https://www.powerelectronicsnews.com/) EPSNews (https://epsnews.com/) Elektroda.pl(https://mww.clektroda.pl/) The Channelist (https://thechannelist.com/) Toots: EEWEB (https://www.ceweb.com/) PartSim (https://www.partsim.com/) Product Advisor (http://www.transim.com/iot/) ‘AIF you consent to the use of ALL the cookies. However, you may visit "Cookre Settings’ ta provice a controlled consent Elecironies Know How (http:/electronics-know-now.com)) LOR kin Bristete (hetssHAAUcesign-zone.com) hitpsshwuwolectroschematis.comlopen-source-ightmeter ‘Schematics io (http://www.schematies.io/) Engage (https://www:transim.com/Products/Engage) aOR ae enna ein Y lcking-Accept ra 2219122, 20:18 ‘Open-Source Light Meter come won ronan cetines seins ome EE CTRO SCHEMATICS ov EE Times India (httos://www.eetindia.co.in/) eauest/d EE Times Tatwan (https://werweettaiwan.com/) EE Times Japan (http:/eetimes.p/) EDN Asia (https:/mwwnednasia.com/) connect Wiiius EDN Taiwan (https://www.edntalwan.com/) Facebook (httas://www.facebook.com/aspencoregroup/) ESM China {http://mwwvesmehina.com/) Twit (https:/twitter.com/AspenCoreGroup} EDN China (http://www.ednchina.com/) EDN Japan (http://ednjapan.com/) (nttps:aspencore.com/) Cons Usthtpsinperesrecentontcnl)AtaitUeftaniegenearcar!)_PaeyFoleyPtoe/isoeorecamithscyooiy) ers! ttepercrecaarmata] stebitonapss ‘We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat vs Al, you consent to the use of ALL the cookies. However, vou may vst "Cookle Settings" to provide a controlled consent. By clicking "Accept Cookie Settings Accept Al hitpsshwuwolectroschematis.comlopen-source-ightmeter sa

You might also like