Two of the gauges on my Dashboard are for displaying the voltages of two different power supplies. The main reason I decided to monitor the voltage was for verification that the supplies are on. Occasionally, I have had circumstances where the power supply that drives the 2 meter Mirage amplifier trips out. Usually, if this happens I will notice the loss of receive signal strength when the pre-amp that is built into the amplifier drops out. But, in case I do not, the voltage gauge will reflect it to me.
The second voltage gauge monitors the voltage of the power supply for my EchoLink Node. Both of these supplies are installed on my communications rack, which is located in my garage. So even when I am home and not operating from a remote location, I monitor the voltage readings on the Dashboard. Both supplies should be giving 13.8 VDC as an output.
To begin this project, I needed the following supplies, one for each measuring device:
- Micro USB 5V power supply
- ESP8266 Arduino
- Stemedu DC0-25V Voltage Sensors
- Bread board jumper wires
- 18 Gauge wire
The first step is the basic setup of the device. The DC0-25V Sensor has 3 male pins on one end and a two wire screw terminal on the other end.

The pins are clearly labeled and can be connected to the ESP8266 by using a bread board jumper:
S = For the signal line, to be connected to the A0 pin on the ESP8266
+ = To be connected to a 3.3 VDC pin on the ESP8266
– = To be connected to a GND pin of the the ESP8266

On the other side of the sensor, the screw terminal is clearly marked as VCC and GND. Obviously VCC connects to the “+” and GND to the “-” of whatever line you are going to be measuring.
Prior to connecting it to a live power supply, I set out to get the Arduino side of it working. I set it up, to read out the sensor value to me via serial monitor on the Arduino using the source below.
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 320.0);
// print out the value you read:
Serial.println(voltage);
delay(5000);
}
I was away in the hotel for work, so I did not have a real way to calibrate it at the time. Nonetheless, I was so excited to get it going and see if it worked, so I borrowed a spare smoke detector battery from the front desk. I then constructed my own wire with aluminum foil.


As you can see, it worked! Although it was far from accurate, I was getting a value and that is all I cared about at the time.
When I got back home, I was able to hook it up to a more stable source and calibrate it with the assistance of a multi-meter. To calibrate it, I adjusted the value (320.0) on this line:
voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 320.0);
It just took a little trial and error to get it dialed in fairly well, as I didn’t need it extremely precise due to the fact the gauge values were going to be rounded numbers. Once that was done, it was time to start getting the values in a more useful form. To do that, and to get the data to my Raspberry Pi, which hosts the Dashboard, I wanted it to return a JSON compliant string.
#include <ESP8266WebServer.h>
// echolink voltage monitor
const char* ssid = "xxx";
const char* password = "xxx";
ESP8266WebServer server(80);
void setup() {
Serial.begin(115200);
Serial.println("Connecting to ");
Serial.println(ssid);
//connect to your local wi-fi network
WiFi.begin(ssid, password);
//check wi-fi is connected to wi-fi network
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected..!");
Serial.print("Got IP: "); Serial.println(WiFi.localIP());
server.on("/", handle_OnConnect);
server.onNotFound(handle_NotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}
String buildJSON(String voltagereading){
return String("{\"EchoLinkVoltage\":" + voltagereading + "}");
}
void handle_OnConnect() {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 320.0);
server.send(200, "application/json", buildJSON(String(voltage)));
}
void handle_NotFound(){
server.send(404, "text/plain", "Not found");
}
With that running on the Arduino and it hooked up to one of the power supplies – we get this when opened in a web browser:

I then mounted up both of the devices to my rack, hooked them up to the power supplies and powered them up. The next step was to take the JSON data and turn it into something useful.

The first script in the process of fetching, caching and then displaying the data, is below. It connects to the Arduino and fetches the JSON data.
#!/usr/bin/php
<?php
$data = file_get_contents('http://192.168.86.51');
file_put_contents('/var/www/htm/arduino_voltage_echolink_cache.txt', $data);
?>
It then places the data into the text file, found at /var/www/html/arduino_voltage_echolink_cache.txt . The contents of that text file, looks like this:
{"EchoLinkVoltage":13.77}
This script runs every minute under the root users cron, by adding this line to the crontab:
* * * * * /var/www/html/voltage_echolink_aurdino_cache.php
Now, at this point, some of you may be questioning why it was done this way – taking the data from the Arduino and placing into a text file and not just reading it directly when the Dashboard loads. The issue was, that the amount of time it takes the Arduino to generate the JSON string was causing the whole Dashboard to hang up. With the amount of gauges trying to load, and get data, it was causing issues with the gauges not loading correctly.
Finally, we then take the text file and make it into a website that can be viewed on my home network at **pi’s-ip**/arduino_voltage_echolink.php The below script does that.
<?php
echo(file_get_contents("/var/www/html/arduino_voltage_echolink_cache.txt"));
?>
The Dashboard (/var/www/html/index.php) pulls the JSON value from the above page.
$.getJSON("arduino_voltage_echolink.php", null, function(result) {
var EchoVolts = result['EchoLinkVoltage'];
EchoVoltsGauge.set(EchoVolts);
});
The gauge then builds itself off of the supplied value from the getJSON script.
//EchoLink Volt Gauge
var target = document.getElementById('echo_volts_gauge'); // your canvas element
var current_size = document.getElementById('current_echo_volts'); // your canvas element
var opts_echo_volts = $.extend(true, {}, opts);
opts_echo_volts['staticLabels']['labels'] = [0,10,12,13,14,15,16];
opts_echo_volts['staticZones'] = [
{strokeStyle: "#F03E3E", min: 0, max: 10}, // Red
{strokeStyle: "#FFDD00", min: 10, max: 12}, // Yellow
{strokeStyle: "#30B32D", min: 12, max: 14}, // Green
{strokeStyle: "#FFDD00", min: 14, max: 15}, // Yellow
{strokeStyle: "#F03E3E", min: 15, max: 16} // Red
];
var EchoVoltsGauge = new Gauge(target).setOptions(opts_echo_volts); // create sexy gauge!
EchoVoltsGauge.setTextField(current_size);
EchoVoltsGauge.maxValue = 16; // set max gauge value
EchoVoltsGauge.setMinValue(0); // Prefer setter over gauge.minValue = 0
EchoVoltsGauge.animationSpeed = 32; // set animation speed (32 is default value)
// pull the values for the gauges on page load.
updateGauges(AmpTempGauge, AmpCurrentGauge, garageTempGauge, cpuTempGauge, EchoTempGauge, EchoVoltsGauge);
// keep updating the gauges every ten seconds
setInterval(function() {updateGauges(AmpTempGauge, AmpCurrentGauge, garageTempGauge, cpuTempGauge, EchoTempGauge, EchoVoltsGauge);}, 10000);
We end up in the end with this nice finished product.

The other voltage measuring device, for the Mirage 2 meter amplifier, uses the exact same process. In the future, I may play around more with this platform, maybe make my own portable device for measuring voltages, or incorporate it with a project I am going to be doing for my fishing boat this winter.