Select Page

The Eyedro EYEFI-x models include a built in web server that you may query with the /getdata command to retrieve the instantaneous measurement values.

While the EYEFI module is not provisioned for the internet (the out of the box configuration), you may only use the /getdata command locally by first connecting direct to the module WIFI network. Eg. EyedroWifi [00B-12345] will appear in your WIFI options list. While connected directly to the EYEFI module accessing the /dashboard, and /settings pages, and the /getdata command are the same format.

http://192.168.1.1/dashboard
http://192.168.1.1/settings
http://192.168.1.1/getdata

After the EYEFI module is provisioned for the internet (SSID, Security, Password are configured per Quick Start Guide), then it will connect to your local network and will be assigned a new IP address from your local network. For this blog post I am using IP address 192.168.0.134 but your IP address will most likely be different, and can be found by logging into your router to see a list of connected devices and their respective IP address.

While the EYEFI module is provisioned for the internet it will communicate with the MyEyedro cloud service 24/7. The module will open a second network port at port 8080 that can be queried in parallel. The format of the /getdata command is shown below. Please note that you’ll replace the IP address (192.168.0.34) with your own.

http://192.168.0.34:8080/getdata

The output of the command is in JSON format. The example response below is from querying an EYEFI-2 (2 sensor model).

{
  "data": [ [988, 11665, 11800, 1360, 0], [989, 11665, 4854, 560, 0] ]
}

The ‘data’ array includes 2 elements, one for each sensor (A first, B second, etc). Each sub-array includes 5 values that are:

1st: Power factor in milli-units meaning ‘988’ = 0.988
2nd: Voltage in cV meaning ‘11665’ = 116.65V
3rd: Amperage in mA meaning ‘11800’ = 11.8A
4th: Wattage in W meaning ‘988’ = 988W
5th: Ignore. Used by factory only.

When viewing the /dashboard page you’ll see that it updates itself every few seconds. It is running a small piece of javascript code that calls the /getdata command as part of the update. The below html and javascript code example can be used as a starting point to create your own software. Save the file to your PC with an .html file extension, edit to replace the IP address with your own, then open the html file in a browser. The javascript should run in the background and update your simple html table with data values.

<!DOCTYPE html>
<html>
<head>
<title>Eyedro Sample Code: EYEFI-x /getdata command</title>
<style>table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
</head>
<body>
<header><h2>EYEFI-x /getdata command</h2></header>
<table>
<thead>
<tr><th></th><th>Power<br>Factor</th><th>Voltage<br>(V)</th><th>Current<br>(A)</th><th>Power<br>(W)</th></tr>
</thead>
<tbody>
<tr><td>Sensor A</td><td id='0f'></td><td id='0v'></td><td id='0i'></td><td id='0p'></td></tr>
<tr><td>Sensor B</td><td id='1f'></td><td id='1v'></td><td id='1i'></td><td id='1p'></td></tr>
</tbody>
</table>
<script>
window.onload=function(){
	var data=[[1,2,3,4,5],[1,2,3,4,5]];
	update=function(data){
		var WattageSum=0;
		for (var j=0;j<2;j++){
			var PowerFactor=data[j][0]/1000;
			document.getElementById(j+'f').innerHTML=PowerFactor.toFixed(3);
			var Voltage=data[j][1]/100;
			document.getElementById(j+'v').innerHTML=Voltage.toFixed(3);
			var Amperage=data[j][2]/1000;
			document.getElementById(j+'i').innerHTML=Amperage.toFixed(3);
			var Wattage=data[j][3];
			document.getElementById(j+'p').innerHTML=Wattage.toFixed(0);
			WattageSum += Wattage;
		}
		var timer=setTimeout(function(){
			var xhttp=new XMLHttpRequest();
			if (xhttp==null){
				timer=setTimeout(function(){ location.reload(true); }, 3000);
				return;
			}
			xhttp.onreadystatechange=function(){
				if (this.readyState==4){
					if (this.status==200){
						var json=JSON.parse(this.responseText);
						update(json.data);
					}
					else{
						alert('Error ('+this.status+') requesting data from server.');
					}
				}
			};
			xhttp.open('POST', 'http://192.168.0.134:8080/getdata', true);
			xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			xhttp.send();
		}, 2000);
		window.onunload=function(){
			if (timer!=null){
				clearTimeout(timer);
			}
		}
	};
	update(data);
};
</script>
<br>
<footer>Copyright © 2009-2019 Eyedro Green Solutions Inc.</footer>
</body>
</html>

Please contact us at Eyedro Support (support@eyedro.com) if you have questions, comments, etc.