pico status V1.0 tool

Various Python Tools that helps handling of the UPS PIco

pico status V1.0 tool

Postby Pimaster » Sun Aug 30, 2015 11:00 pm

Hi,

Please find here below the pico_status.py tool. This tool will be updated with more parameters soon.

Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
# improved and completed by PiModules Version 1.0 29.08.2015
# picoStatus-v3.py by KTB is based on upisStatus.py by Kyriakos Naziris
# Kyriakos Naziris / University of Portsmouth / kyriakos@naziris.co.uk


import smbus
import time
import datetime



i2c = smbus.SMBus(1)

def pwr_mode():
   data = i2c.read_byte_data(0x69, 0x00)
   data = data & ~(1 << 7)
   if (data == 1):
      return "RPi"
   elif (data == 2):
      return "BAT"
   else:
      return "ERR"

def bat_level():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x01)
   data = format(data,"02x")
   return (float(data) / 100)

def rpi_level():
   time.sleep(0.1)
   data = i2c.read_word_data(0x69, 0x03)
   data = format(data,"02x")
   return (float(data) / 100)

def fw_version():
   time.sleep(0.1)
   data = i2c.read_byte_data(0x6b, 0x00)
   data = format(data,"02x")
   return data

print " "
print "        pico status V1.0"
print "***********************************"
print "*","UPS PIco Firmware:",fw_version(),"          *"
print "*","Powering Mode:",pwr_mode(),"             *"
print "*","BAT Volatge:", bat_level(),"V","            *"
print "*","RPi Voltage:" , rpi_level(),"V","            *"
print "***********************************"
print " "




picostatussimple.JPG
picostatussimple.JPG (34.56 KiB) Viewed 1657 times


Warmest Regerds
PiM
Warmest Regards
PiM
---
Designing with Mentor Graphics PADS - www.pads.com
Please read and follow the PiForum rules
http://www.forum.pimodules.com/viewtopic.php?f=13&t=196
---
Pimaster
Site Admin
 
Posts: 1617
Joined: Fri Sep 14, 2012 7:50 am

Return to PIco Python and other Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron