-1

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.

1 Answers1

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