Unstable Temperature Sensor Reading

Hi everyone, I have just started playing around with Arduino recently. I want to hook up an industrial temperature sensor that I have lying around the house to the Mega and display temperature readings to a Nextion display. The sensor takes 25V dc and output a 0-5V to the Mega's analog pin. Everything seems to work fine when I have the sensor hookup to the board and runs the code. However, as soon as I wire up the Nextion Display, the temperature would fluctuate and would be off by several degrees Celcius. As I am hoping to hook up several sensors and relays, any help on how to fix this would be great.
p.s I am supplying power to the Mega via usb cable.

analogRead() would produce the following readings:
572.00
572.00
573.00
572.00
569.00

When I plug in the Nextion Display
598.00
605.00
632.00
648.00

Do not use Serial (USB) for the display. You have 3 other hardware serial ports for that.

If that does not help, post your code. Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

"A 0-5volt sensor output" could mean that you are using the potentially unstable Arduino 5volt supply as reference.
Then any variation in the 5volt supply (caused by the display) will also be seen in the temp readout.

You could switch to one of the stable internal references of the Mega (1.1volt, 2.56volt) in setup(),
and bring sensor output down to this voltage with a voltage divider.

If you want more help, then post your code, with code tags, and post a link to the temp sensor.
Leo..

Wawa:
"A 0-5volt sensor output" could mean that you are using the potentially unstable Arduino 5volt supply as reference.
Then any variation in the 5volt supply (caused by the display) will also be seen in the temp readout.

You could switch to one of the stable internal references of the Mega (1.1volt, 2.56volt) in setup(),
and bring sensor output down to this voltage with a voltage divider.

If you want more help, then post your code, with code tags, and post a link to the temp sensor.
Leo..

Thanks for the quick reply WaWa. Indeed, if I power the Nextion display from an external 5v power source, the problem goes away. I am interested in trying out the internal reference 2.56volt if that gets me more stable and reliable readings. What voltage divider do I need to step my sensor output down to 2.56? Is there a way to do this more efficiently if I have multiple sensors?

Your fritzing doesnt show power supply to the arduino.

The internal reference depends on which arduino you are using as different models offer different internal reference.

My page here will show you how to reduce the voltage from the sensor to match the reference.

so if you are using a UNO, MEGA, or nano you will have a 1.1V reference; if you are using a Micro Pro or other 32U4 based board, a 2.56V reference.

I have just tried this on my Uno; the Uno & nano have a 3.3V output you could use as a reference. Its looking very stable by comparison with the internal 1.1V reference. I'm getting a value of 3181mV with a standard deviation of 2.5