Scaling Volt Readings on Gauges

I could use some insight on scaling the reading on the 3 gauges reading volts. Obviously when I put 5v on the analog pin I get 1023 reading, full resolution. Using a pot I can vary the reading but I would like to scale that down to 0-60v. I was thinking that a float statement and analog read dividing 1024 to the scale I want. Racking my brain at this point. Currently the gauges are handled by Cayenne not in the sketch.

Hi
I write the code for you.
What do you use for connecting to the cayenne (Arduino + Ethernet, Serial + Arduino)?

I’m using Arduino+Ethernet w5100 for now. Wifi will come later(ESP-12E)

Thanks!

Voltage 0-60V.txt (802 Bytes)

Awesome!!! Thanks!!

1 Like

In the code, you have a few bugs.
I’ll rewrite it.

Try this

voltege.txt (2.8 KB)

2 Likes

Thanks! That worked perfectly. Only thing I had to do was change some settings from digital to virtual as cayenne was taking care of those functions without the need of code. With people like you I am learning more and more about coding, it has been a difficult road. Now I can add more voltage inputs in the future.

Thanks Again! You Rock!

2 Likes