Giter Site home page Giter Site logo

damionw / linux-pitop-battery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eduardojvr/linux-pitop-battery

0.0 0.0 0.0 65 KB

A loadable kernel module for exposing the Pi-Top battery over sysfs, etc. Also fixes the clock-stretching problem.

License: Other

Makefile 1.10% C 95.98% Shell 2.93%

linux-pitop-battery's Introduction

Installing

  • Run sudo apt-get install raspberrypi-kernel-headers
  • Add deb http://0xc9.net/apt-deb ./ to /etc/apt/sources.list
  • Run sudo apt-get update
  • Run sudo apt-get install pitop-battery-support
  • If you are running Raspbian instead of pi-topOS, please consider adding the stuff from @rricharz's pi-top-install repository.
    • There are debian packages available here. You can also use apt-get install pi-top-brightness pi-top-poweroff.

Manual install method

This way uses dpkg instead of apt, which means you need to install the dependencies yourself.

  • Run sudo apt-get install raspberrypi-kernel-headers dkms
  • If you want to check whether the proper kernel headers have been installed, see check kernel header version
  • Grab all the .deb files on the release page for the latest version.
  • Use dpkg to install i2c-gpio-param-dkms_1.0_all.deb and sbs-battery-dkms_1.0_all.deb
    • sudo dpkg -i i2c-gpio-param-dkms_1.0_all.deb sbs-battery-dkms_1.0_all.deb
  • Use dpkg to install pitop-battery-support_1.0_all.deb
    • sudo dpkg -i pitop-battery-support_1.0_all.deb

Getting it working

After doing the above, you need to modify the following two files:

NOTE: These files are for the default version of Raspbian Jessie (after running raspi-config, etc.). If you have other hardware configured, adjust accordingly.

/etc/modules

Comment out all the i2c modules:

#i2c-dev
#i2c-bcm2708

/boot/config.txt

Remove anything that might load the i2c1 driver.

Here is my file:

dtparam=spi=on
dtparam=audio=on
gpu_mem=256

# All these are commented out:
#dtparam=i2c_arm=on
#dtparam=i2c1=on
#dtparam=i2c1_baudrate=50000
#dtoverlay=i2c-rtc,ds3231

Adding a battery display to the standard Raspbian desktop (LXDE)

  • Right-click on menu bar and select Add / Remove Panel Items
  • Click on the Add button, select Battery Monitor and click Ok
  • Use the Up and Down buttons to position the Battery Monitor as you like
  • Click the Ok button
  • Right-click on the battery icon displayed
  • Set Alarmtime to 20 to be on the safe side for the Pi-Top battery

This will give you a warning on the LXDE desktop if the rpi is on battery power and only 20 minutes are left.

Setting up automatic shutdown when the battery gets low

You can install the UPower power manager to handle this:

  • In a terminal window, type sudo apt-get install upower
  • Edit /etc/UPower/UPower.conf:
    • Set IgnoreLid to true
    • Set UsePercentageForPolicy to either true or false
    • If true:
      • Set PercentageLow to 15
      • Set PercentageCritical to 10
      • Set PercentageAction to 5
    • If false:
      • Set TimeLow to 5400
      • Set TimeCritical to 3600
      • Set TimeAction to 1800
    • Set CriticalPowerAction to PowerOff
  • Save new settings and reboot

With the proposed settings, the Raspberry Pi will shut down if it is on battery power and only 1800 seconds or 5% are left. Unfortunately, it will do so without any further warning on the LXDE desktop.

Other I2C hardware

Here are some examples for adding other I2C devices without using device trees.

(For information about GPIO with the pi-top, see this post.)

Chronodot 2.1 Real Time Clock

I have an RTC connected to the hub, so I added this to /etc/rc.local:

# register the RTC (chronodot v2.1 connected to the Pi-Top Hub)
modprobe rtc-ds1307
echo ds3231 0x68 > /sys/class/i2c-adapter/i2c-1/new_device

Pi-Top Speaker

If the Pi-Top speaker has worked before switching to the bit-banging I2C driver, it should continue to work after the switch.

If it still doesn't work

Make sure that you have the headers for your kernel version.

Do you have raspberrypi-kernel-headers?

Try ls /lib/modules/$(uname -r)/build

If you get something like ls: cannot access /lib/modules/4.9.13-v7+/build: No such file or directory, then consider downgrading the firmware.

First, run tools/available_headers.sh. Pick the latest version and find it on this page.

For example, if the latest version is 4.4.50, then the commit you want will be called "kernel: Bump to 4.4.50"

Copy the git hash for the commit, and run sudo rpi-update GIT-HASH (for example, for 4.4.50 it would be sudo rpi-update 52241088c1da59a359110d39c1875cda56496764)

After rebooting, everything should work.

linux-pitop-battery's People

Contributors

rricharz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.