I have a project I am doing and I got the code sorted in the end but the hardware is causing me an issue.
I am replicating a cooling system and under 23 Degrees C the buzzer is on but as the temperature rises a pump and fan come on to simulate cooling but when my 5V submersible pump comes on at 23 degrees C and the fan at 25 Degrees C I have a spike on my LM 35 temperature sensor which then takes it above 28 Degrees C and then the circuit trips out the buzzer which it is meant to do but it isn't actually 28 degrees C it's the voltage spikes causing it. Also I have the problem when the pump or fan cuts out they also spike. I thought the motor shield would protect the LM35 from these peak voltages but now I am at a loss as how to stop them interfering with my LM35.
I did research this and found out I probably needed a motor shield as there was too much power being pulled through the board. So I got the Arduino motor shield that allows me to run two loads and connect a 9V battery. However this has not helped.
I have tried putting a capacitor 0.01uF across the -+ terminals of the LM35 to balance out the voltage and I have tried to put a ceramic capacitor on the outgoing analogue leg I put in a 75 ohm resistor and 0.22uF capacitor in parallel however none of what I have done has made a difference. I found this tip in another thread but it has not helped.
That just means your power supply is not able to keep the voltage stable.
A 9V PP3 battery is possibly the worst choice for powering motors. Get a proper power supply, or a pack of AA batteries or LiPo cells if you want battery power.
Thanks so much for getting back to me. I am totally new to this and when I was given a 9V fly lead with the motor shield I assumed that was the best way to go.
I have watched a couple of videos and I just have one other question please if you don't mind?
In the videos I have seen they have taken the 5V supply from the arduino board itself and put it through a LM431 Shunt voltage reference. Is it ok to use the 5V from the arduino to provide the power to LM431 or is there another way of providing an external ref power source to the AREF pin? For example having another batter pack and using that as an external reference?
Why use an external reference? The 1.1V reference allows you to use this sensor up to about 110°C.
The 431 I suppose is a 2.495V version, that is a way to create a reference voltage that is then supplied to the AREF pin. Of course it can be powered from the 5V, even if unstable. That diode is designed to produce a specific output voltage, just make sure you have an appropriate series resistor.
The simplest solution for external reference is to connect the 3.3V output of the Arduino (especially if unused this will be really stable) to the AREF pin as reference.