Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Light Meter Programming

Status
Not open for further replies.

heberjm8

New Member
Hello. I’m hoping I can obtain some help with programming a circuit. I’m designing an ambient light sensor with a digital display showing the amount of lux detected. I have ordered a digital display that comes with a HD44780 chip included in it. Here is the webpage for the digital display I have ordered:

https://www.sparkfun.com/commerce/product_info.php?products_id=709

Well I have never programmed before and I’m hoping I can learn a few things from the people here at this forum. I’m not sure but is it just as easy as ordering a photo sensor and getting the correct program for it to communicate with the digital screen to display the lux? If so, can someone please recommend a possible photo sensor or schematic for my application?
If someone would respond I would GREATLY appreciate the help. THANK YOU SO MUCH.
 
Here's a start for you at Digitl-DIY.com: Irradiance Meter

It uses a Taos Light Sensor chip that's been on clearance at RadioShack and the Amicus Compiler. Amicus is a free, full version of Proton Baisc, limited to the PIC18F25K20 microcontroller. This language is very powerful and pretty simple to use. The 18F25K20 is installed on a low-cost TAP-28 application board.

The Irradiance Meter uses a Handspring Visor as an output device, but it's a good start to using the LCD display. There are a lot of tutorials and helpful information at Digital-DIY to help you figure out what you're trying to do.
 
Hi Guys,

I have a question about the photocell for my application.

I talked to a customer service person from sparkfun.com and ordered the following photocell:

SparkFun Electronics - Mini Photocell


SparkFun Electronics - Mini Photocell


Would you agree that this is a good photocell for my design. I'm just hoping its sensitive and accurate enough. I'm making a basic light sensor that will show the amount of lux on the digital screen. I figure my light meter lux max will be either 20k,40k,50k, or 100k lux. I looked at other light meters on the market and this is what they all maxed out at.



I also ordered a microprocessor from the customer service guys recommendation. Here it is:

SparkFun Electronics - Arduino Uno
 
photocell are not very good at what you want to do a plain old led would work better a nice clear red one and some real good coding. But for $2.00 I would get what jon posted and a LCD and and be done in ten minutes
 
Hello,

I’m hoping I can obtain some much needed help with the programming of a circuit. I have never programmed before so this is all new to me. Well I’m designing an ambient light sensor with a digital display showing the amount of lux detected. So pretty much, just a basic light meter with a digital display for the lux. Looking at other light meters on the market I believe I want the lux range to be from 0 to anywhere to 20k, 40k, 50k, or even 100k lux. The max lux range really doesn’t matter as long as it’s sufficient enough. With the help of a customer service member I have already ordered the main parts I believe I’ll need for this circuit. Those parts being a photocell, a LCD screen (HD44780 chipset), and a micro-controller(Arduino Uno). I already have a breadboard, resistors, etc. If someone would be so kind to help me out by telling me how the easiest way to start constructing and programming this circuit I would greatly appreciate it. Diagrams or similar projects with my components would be great too. Thanks again.
Here are the web pages to the parts I have ordered so far:
(Photocell)
SparkFun Electronics - Mini Photocell
(LCD Screen)
https://www.sparkfun.com/commerce/product_info.php?products_id=709
(Micro-controller)
SparkFun Electronics - Arduino Uno
 
Hmmm....u bought...
* ATmega328 microcontroller
* Input voltage - 7-12V
* 14 Digital I/O Pins (6 PWM outputs)
* 6 Analog Inputs
* 32k Flash Memory
* 16Mhz Clock Speed


To make a lightmeter. :D

Ok.....u got enuf CPU power to make a couple dozen. Or at least 6 (input limited) parallel meters.

Perhaps you could have posted your intention b4 u bought the stuff for better help.?

I haven't 'graduated' from PICs to the Ardi's yet. But a basic 16F series ADC Pic for around a buck could do the job. As a quick pick...I'd say the 16f688 would do a nice job here.

This page:
2-Wire PIC LCD Interface by Myke Predko

is a nice jump off point in getting your LCD going, then coding the ADC and math to display the info on the LCD is fairly straightforward.

You can get the math etc from piclist.com
 
Last edited:
Thanks for responding Mosaic. I appreciate it.

What do you mean by saying the 16f688 would do a nice job? I'm not sure what that is. This is my 1st time programming so I'm unfamiliar with a lot of the terms.

Also the math from piclist.com I was having a hard time finding. Would you help me understand it more?

THANK YOU SO MUCH!
 
Thanks Jon. I'd really like to use the parts I got now since I just picked them up and spent the money for them. If I get into a time crunch just before for the due date then maybe I'll ditch my items for the ones you recommended. I've heard this light meter project is not that difficult to get working. I'm really hoping that's true. Thanks again.
 
Well, you already bought the dev system for the ardi...so I can't help much there.

For simple applications like the light meter, => a sensor, an MCU, a Display and perhaps a switch to switch ranges/ units can be done with more economical MCUs such as the Microchip family of 16FXX or perhaps even the 12Fxx which have fewer capabilities but are in tiny 8 pin packages.

The 16f688 is a microchip MCU which can be programmed by the Pickit2 LPC dev board. In fact since the dev. board comes with a 16F690 for free...you could use that as well, but it costs just under $2.

Now if your application is a one off exercise I suppose using a $6 MCU like the Ardi is ok....but for effective designs matching the MCU to the task is the better way to go. Of course, only after u get some experience in doing MCU based systems will u understand what u need and be able to specify the most cost effective MCU for the job.

If you wish to use C or BASIC as a programming language (which is a good way for a noob to start programming) the ardi isn't bad at all, or perhaps the PIC 18F family. These more powerful MCUs have the MIPS to crunch thru non optimised code and get the job done fast. Noobs don't do optimised code. An expensive compiler for the C or BASIC would do a decent job of makng your code faster by efficient compiling. The free compilers have some limitations there. You can use C or BASIC on any MCU once u have the compiler for the MCU family.

For time sensitive apps, like running a video game on a CRT screen, assembly (asm)language tends to give the best results as u can actually count the instructions to determine the time each bit of code takes as the PIC family of chips have standard timing for the instructions.


Also your IDE (Integ. Dev. Environment) should have a decent simulator so you can follow your code and learn from mistakes.

The key thing when programming is divide and conquer. Always code in sections (subroutines) which can be isolated and debugged b4 moving on. Always comment your routines so that a month from now u can understand what it does.
Read the spec. sheet for your MCU as each MCU has its custom abilities and quirks.
When asking question here try to have a bit of code to post so we can see your challenges. If u solve a problem, share it with us so others reading the threads can learn too.

After you have done some coding and want to move off the dev board to a standalone circuit, you will realise that leaving MCU pins unassigned or 'floating' isn't a good thing. Therefore always consider the unused pins when coding and protoyping.
 
Thanks be80be. That looks like a great webpage to help me out.
I'm definetly going to read over the •LCD: blog post on using an HD44780 based LCD.
Can you reccommend anymore or other sites that will help me get this project together? Thanks again!
 
Thanks be80be. That looks like a great webpage to help me out.
I'm definetly going to read over the •LCD: blog post on using an HD44780 based LCD.
Can you reccommend anymore or other sites that will help me get this project together? Thanks again!

That one there had the best links you can find all on one page

If you use C you can find code that shows you how to use the lcd and ADC to read your cls (photocell)

Get this **broken link removed**

And head over to here Arduino - Software
 
Hmm, not sure what the linear range is on a Cds cell which is a bit slow or even an LED. Perhaps you should consider a photodiode with a decent spec sheet giving u linearity or your code will have to compensate. Besides Cds cells are toxic and can't be used in commercial stuff much these days unless its military or aerospace.

You'll need a moving avg on your data to compensate for the 60Hz frequency emitted by AC lighting.
 
I have done a lot more research about programming and feel more comfortable with the terms now. I have my arduino board and my computer up and now communicating. Anyways, I was wondering if someone could send me or create a similar code for my design (light meter displaying the amount of lux on a lcd screen) that I could edit to my needs. I haven't been able to find a good code to start with yet, so I'm hoping someone can help me out with that. I appreciate your help so much. THANKS!!!
 
Hello,

I was hoping you could help me out. I have a question about the coding. I've attached a video and code for a light meter below. I was wondering if you could tell me for that code that someone has posted if that's all the code you need for it to work. I was talking to someone at school today about it and he wasn't sure but he was telling me about how that's not an entire code. (Even though the person who posted it said it was.) He talked about the beginning of the code and how it starts with "Serial.begin (9600) " He was telling me there is a code for that alone and I would need it along with the code that got posted. Something about a library code. I was confused with what he was saying. To me it looks like an entire code but then again I don't really know nothing about coding. Can you clear anything up for me? Thanks!!!


**broken link removed**

YouTube - light sensor lcd
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top