2 analog controller and a relay

good day all it been 6 hours i am searching the web for something comparable to what i am trying to make and its hard to find...

I just need a sketch that will have a analog light sensor (sensor A1), an analog temp sensor (A0) and analog out relay on #9.

The light sensor looks if there is a can say over 30mV, if there is it will allow my relay on #9 to open and the relay on #9 will close once the temp sensor see something over 30 mV or 80 degrees C.

I dont have a problem with the algorithm for my sensors or programming separately but my problem is a the ''if'' stage when my relay in open, i cant get it to close at XXmV with the temp sensor

Thank you!

Break the problem down into parts

  1. Print the value returned by the light sensor when it is lit and covered. Now you know that it works
  2. Test the value returned by the light sensor and turn the relay on and off at appropriate levels. Now you know that works
  3. Print the value returned by the temperature sensor at various temperatures. Now you know that it works
  4. Test the value returned by the temperature sensor and turn the relay on and off as it goes past 80 degrees . Now you know that works

You should easily be able to find examples of each of these steps.

  1. Combine steps 2 and 4 above to turn on the relay at the right light level and wait for the temperature to reach 80 degrees and then turn off the relay.
  1. Combine steps 2 and 4 above to turn on the relay at the right light level and wait for the temperature to reach 80 degrees and then turn off the relay.

Now you know that it works.

and analog out relay on #9.

A relay is on or off. Banging it on or off at PWM speeds will wear the relay out in no time. You might as well save yourself the trouble of wiring it up. Just throw it away now.

Not to mention the noise that results from driving a DC coil with an AC or PWM (variable pulse width) signal... Also there is the issue of the back EMF developed every time the coil is energized/de-energized. When one powers up a coil the coil makes a magnetic field, storing the electrical energy as a magnetic field. When the power is removed/de-energized the magnetic field is converted back to electrical energy or ElectroMotive Force (EMF)

Doc

okay, thanks. i enterely agree with this concept! is there any way i could get a 24vdc valve to open when my light sensor is enable and to close when my temp sensor reads x degrees?

davesimon:
okay, thanks. i enterely agree with this concept! is there any way i could get a 24vdc valve to open when my light sensor is enable and to close when my temp sensor reads x degrees?

Yes, but I suggest that you start by turning an LED on and off to simulate the relay.

You will need extra circuitry to drive the relay and obviously a 24V supply.