I am interfacing a PIC16F877 with a 5V DC relay. I hooked up the relay to the same 5v that power up my PIC with the appropriate transistor, diode, voltage to power up an LED to NC and LED to NO, I hooked up an LM35(Tempreature sensor) to my PIC and an LCD to check what is going on, i wrote my code and everything is working perfectly.
However, when i try to switch the relay with my pic the reading on the LCD changes dramatically, so if Room tempreature is about 20C it will show 2C or 3C.
EDIT: I tried to hook up the LCD to a different voltage source and same behavior happened, then i tried to make a current buffer with an UA741 and 2n2222 and same behavior.
When i run the simulation everything is working fine, but in real hardware its outputting a different Temperature on the LCD than when i remove the relay.
IDEAS?