Seli MOD503 Скачать руководство пользователя страница 6

sudo apt-get update
sudo apt-get install python-pip

2. Install Jetson GPIO library:

sudo pip install Jetson.GPIO

3. Install the I2C development library:

sudo apt-get install libi2c-dev i2c-tools
pip install smbus

4. Install Nano editor on Ubuntu:

sudo apt-get install nano

5. Sample code for reading battery voltage and battery percentage

#!/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:

Содержание MOD503

Страница 1: ...5 Introduction Designed for Jetson Nano Developer Kit this advanced uninterruptible Power supply UPS module provides up to 5 1V 8000mA backup power for Jetson Nano board With intelligent power managem...

Страница 2: ...utomatic startup complete shutdown from software advanced power path management I2C bus communication and onboard LED indicators for monitoring battery capacity It is powered by six 18650 batteries Sp...

Страница 3: ...s the button turn on press and hold the button for at least 3 seconds turn off Power loss or power adapter fault detection LED and GPIO indication On board XH2 54 power output connector for powering o...

Страница 4: ...Electricity Electricity The number of LED lights on 0 25 1 26 50 2 51 75 3 76 100 4 Connect with Jetson Nano by 10Pin Correctly install six 18650 batteries to the Jetson Nano UPS power board and conne...

Страница 5: ...to turn off the UPS short press once to turn on the UPS Battery power and voltage can be read by software 1 First install the pip of Python3 on the Ubuntu system Please run the following command as t...

Страница 6: ...ng battery voltage and battery percentage 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...

Страница 7: ...y bus if readCapacity bus 100 print Battery FULL if readCapacity bus 20 print Battery LOW print time sleep 2 Create a new Bat py file and then run the command in the terminal sudo python Bat py Now yo...

Отзывы: