# light dimmer and thermostat

Status
Not open for further replies.

#### dawson

##### New Member
Hi,
I would like to start a project but dont know where to start.

What I would like to achieve is to be able to turn a light buld on over a period of time (lets say an hour) have it on for a variable amount of time and then have it slowy turn off again (over an hour) creating a sun rise sun down effect.

I would also like a thermostat with a digital display showing current temp where if the temp goes above a variable set temp it will dim the light again untill it drops below the set temp.

It goes more in depth but I think If i can get something like that then its a good starting point?

I think it can be split into 2 projects and then be merged later?

say I start with the basics of how to make a digital clock turning an output on and off?

Then making a thermostat to display a temprature?

I figure some kind of programming will be required to be able to change the variables?

so any ideas of where to start with this? what parts will be required etc?

Thanks

#### gaspode42

##### Member
Hi

An interesting project. I would use the following:-

PIC for the central control unit with LCD
DS18S20 temperature sensor
For the light I would use PWM from the PIC together with suitable circuitry.

How accurate do you need the times to be?
How closely do you want the temperature measured?

There are may ways to do this but we really need more information

#### dawson

##### New Member

Im not sure about time accuracy, what I was thinking was having a real time clock and say at 7am the sun starts to come up by 8am it is at full brightness. during daytime hours the thermostat should then take over dimming/brightneing the lamp as required then at night time say 9pm the sun starts to go down dimming the lamp until 10pm when it is turned off completely.

as for tempratute I would like it to be as accurate as possible with a margin of +/- 1 degree C to start dimming/brightening again, but again as the project starts to grow I would like to add another variable so that this 1 degree can be changed.

I can give full details of what I want the final project to be likeif u wish? I just thought it might take me ages to write it and it would be far to complex for my skill level to start it.

a note on my skill level: I am a qualified electrician however do not really work on the electronic side I have done basic electronics in college but that was a long time ago.

#### gaspode42

##### Member
Dawson

Do you have any programming experience and if so in what languages?

#### dawson

##### New Member
I have done a little bit of basic and c in the past.

As a hobby I create websites so know html, css and php. I know this is not relevant but I would think it should give me basic grounding to be able to learn enough of whatever language is required?

#### gaspode42

##### Member
Dawson

Yes you should be fine. Have you played with PIC programming before?
I agree that this would be best achieved as a number of small projects that will give you the knowledge to bolt them all together as a working system in the end. I would suggest that you have a look at one of the introductory books, such as this and then start by trying to just flash an LED. This will give you a good introduction that you can then build on. You will also need to get some hardware to program your PIC and one or two other bits and pieces to get you going.

#### dawson

##### New Member
No I have not and to be honest I had never heard of it until I starting looking around for this project.

I agree with your suggests, starting small is necessary. I will look into PIC programming and buy some hardware.

Could you recomend any hardware that will get me started and see me through this and hopefully other projects? Also where could I buy it from? I see you are based in the UK aswell. would Maplins be any good?

Thanks again for all the help

##### Well-Known Member
Dawson, you are in for a bit of fun with microcontrollers. I thought it might be useful to mention that, while the PIC series is the most popular and the obvious first choice for many, you might also consider its competitor, the Atmel AVR series.

I fell into this stuff through the AVR series partly because I had a bit of exposure to the development environment. When you are doing your first project, the programmer hardware might be a lot more expensive than the rest of the project, so you might want an inexpensive solution. I started a few years ago with the Atmel STK500 progammer which costs around US$92 at Digikey, but then found that you can get by with something less like the ISP2 (ATAVRISP2 at Digikey) which is US$41. Then I had to give those to someone else and so built my own scratch made programmer interface using my computer's parallel port. That cost almost nothing and worked fine.

With these chips, you program them "in circuit". In other words, you build your application circuit with the chip, but include a 6 wire programming connector in the design (easy to figure out how). Progamming is as simple as plugging in your development-PC interface (the programmer hardware) to this connector, and then you turn on the power to your application circuit and begin a program download. It is all automatic from there. You can do this process over and over thousands of times without wearing anything out. So programming, and debug too, is "in circuit", that is in your application circuit.

I'm no programmer and have no C training, so I started with a Basic language system called BASCOM-AVR from a company in Germany. It is free and works well in my simple projects, and works with my home-made hardware interface. Heres a link to BASCOM. Most people use C however.

Home - MCS Electronics

#### dawson

##### New Member
Thanks for your input. Does either chip series have an advanage over the other? If the AVR has no gain on the PIC then I think I would prefer to start with the PIC as all this is new too me.

I am just having a bit trouble deciding what to buy I have seen programming boards range from £5 - £500 and also found a few tutorials showing how to build your own. The problem is I do not know what chip I will be using and I guess the lower priced boards will limit me as to which I can choose?

#### Nigel Goodwin

##### Super Moderator
Thanks for your input. Does either chip series have an advanage over the other? If the AVR has no gain on the PIC then I think I would prefer to start with the PIC as all this is new too me.
Nothing to choose between them, but the PIC is far more popular and has much more support available - it's been around a lot longer.

##### Well-Known Member
Nothing to choose between them, but the PIC is far more popular and has much more support available - it's been around a lot longer.
This is quite true. I've found plenty of user support for the AVR for my purposes, but the volume of info on AVR pales in comparison to the massive user community involved with the PIC series.

If you have any friends doing microcontroller projects, you might just use what they use.

Last edited:

##### Well-Known Member
Normally I would advise a hobbiest to avoid working with dangerous voltages, including line voltages, but I see you are an electrician so perhaps you can appreciate the safety issues better than most. In this project, consider how to isolate the low voltage circuits from the dimmer functions. Perhaps a simple optical isolator would be fine for this. Ideally there would be no metallic connection at all between low voltage and high voltage circuits so that any HV fault could not propagate back to the LV side.

#### dawson

##### New Member
Ok, so I think thats deffinately decided it then, the PIC it is. can anybody help out more with which hardware to choose for programming though?

RadioRon, Yes keeping Lv and HV seperate will be a concern however I think its a bit early in the project for me to be worrying about this.

Last edited:

#### stevez

##### Active Member
A point worth some consideration is the amount of light intensity that represents normal sunlight and how well you might want or need to duplicate that. I honestly don't know if it matters to you or not - just a point to consider.

The light spectrum that is "natural" will be different than that of an incandescant (or other) light source. A normal levels it's different than sunlight and the difference may or may not be of concern. Note also that as you dim an incadescant light the filament is cooler therefore the light output is different. It may or may not correspond well to voltage or power to the filament.

I am sure that natural light is quite variable too given that cloud-cover, smog, reflectance and other things profoundly impact the light that arrives at any given point. What I've mentioned could be tricky to manage or could also be added complexity that really doesn't matter much at all. Just wanted to share so you could give due consideration.

#### dawson

##### New Member
Thanks stevez,
You have made an interesting point, however it does not matter for this project. What I intend to do with this project is create a reptile habitat and therefore will be using the correct lamps for the given reptile. This is simply because the shop bought devices are very poor/ do not cater to my needs.

Status
Not open for further replies.