I have a PIC18 that sends its Vcc level of battery charge on a mysql database. I was wondering if there is a script to display its battery-status on my website homepage. I mean something like a typical mobile battery icon to display over my website navbar. Sorry but my javascript knowledge is so limited. Thanks for answers.
Asked
Active
Viewed 266 times
-1
-
What is external device? – Khurshid Ansari Feb 01 '18 at 04:55
-
I think you want battery status of user, so use https://tutorialzine.com/2016/08/working-with-the-javascript-battery-api – Khurshid Ansari Feb 01 '18 at 05:00
1 Answers
0
To get battery status of user, use following javascript code to get battery status using javascript:
navigator.getBattery().then(function(batteryManager) {
// Get current charge in percentages. var level =
batteryManager.level * 100;
}).catch(function(e) { console.error(e); });

Mohammad Javad Noori
- 1,187
- 12
- 23

Khurshid Ansari
- 4,638
- 2
- 33
- 52
-
Thank you for the answer. I mean that i have a value in a database that indicates the battery level of a remote device so i want to put it in a script and display a battery logo with the real charge – Penny Wiz Feb 01 '18 at 07:36