Open main menu

T200 software

Revision as of 16:15, 10 August 2020 by Harry (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

You can refer to T208-Software also

sudo apt-get update

sudo apt-get install python-pip
sudo pip install Jetson.GPIO

sudo apt-get install libi2c-dev i2c-tools
sudo i2cdetect -y -r 1

pip install smbus

sudo apt-get install nano

# sample code

'#!/usr/bin/env python
import struct
import smbus
import sys
import time


def readVoltage(bus):

     address = 0x36
     read = bus.read_word_data(address, 2)
     swapped = struct.unpack("<H", struct.pack(">H", read))[0]
     voltage = swapped * 1.25 /1000/16
     return voltage


def readCapacity(bus):

     address = 0x36
     read = bus.read_word_data(address, 4)
     swapped = struct.unpack("<H", struct.pack(">H", read))[0]
     capacity = swapped/256
     return capacity


bus = smbus.SMBus(1) # 0 = /dev/i2c-0 (port I2C0), 1 = /dev/i2c-1 (port I2C1)

while True:

 print "******************"
 print "Voltage:%5.2fV" % readVoltage(bus)

 print "Battery:%5i%%" % readCapacity(bus)

 if readCapacity(bus) == 100:

         print "Battery FULL"

 if readCapacity(bus) < 20:


         print "Battery LOW"
 print "******************"
 time.sleep(2)
Add your comment
Geekworm Wiki welcomes all comments. If you do not want to be anonymous, register or log in. It is free.