Laptop with Raspberry Pi Inside Learns to Speak Battery

Early in November we took a look at a one of the best Raspberry Pi laptops we had ever seen, using the shell of a Sony VAIO. Laptops used to be hulking beasts, and that played into [Frank Adams’] hands as he got rid of the motherboard and had enough space to replace it with a Raspberry Pi and a few other support boards. This took advantage of the laptop’s screen, keyboard, LEDs, etc. But what’s a laptop without battery power? [Frank] hadn’t cracked that nut until now.

Inside of Sony VAIO laptop turned Raspberry Pi computer
VAIO battery and charging PCB seen to lower left

Adding battery power is trickier that it sounds, but [Frank] managed to get the Raspberry Pi to talk to the original Sony VAIO internal battery. His work on the project is shared, but this part of the story is best found starting on page 29 of his PDF project details.

Using the original battery is a good move since it’s designed to fit and has a charger ready to interface with the port on the laptop case. But these batteries have logic inside them, and there’s the rub. Communications use the 2-wire System Management Bus (SMBus) which is well documented. But the when trying to use the Pi’s I2C [Frank] couldn’t figure out to send a repeated start command.

He ended up writing his own C program that bit-bangs the communications he needed and now has the Pi speaking to the battery and listening to what it hears coming back. Reading through his description of this is fun since he includes his observations from a logic analyzer captures. He suspects an occasional bad read is due to Linux interrupting code execution. He watches for and catches these bad reads in software and can now reliably read all the battery vitals.

The hack leaves him with a system that functions in much the same way the original computer did: plug it in and it charges. He did add some hardware that lets him take a voltage reading from the battery using an ADC on the Teensy that was already present to control the keyboard and case LEDs. This adds a small constant draw on the battery, but for now he doesn’t leave the battery connected when the laptop is not in use.

If you’d like to read our original coverage of this laptop, here it is.

4 thoughts on “Laptop with Raspberry Pi Inside Learns to Speak Battery

  1. >But the when trying to use the Pi’s I2C [Frank] couldn’t figure out to send a repeated start command.

    Blegh. Peripherals. You’d think something like the Raspberry Pi would have this sort of thing worked out, but you never know where you’ll find quirks and small hardware errata. It seems like it’s always the peripherals where those end up.

    Hey, does this sound familiar? “Errata: In order to , must be set.”

  2. Not to take away from Frank’s work (which is awesome!) but why the hell do we need to go through all of this mess to add batteries with fuel gauges to our hobbiest embedded projects. A raspberry pi would be infinitely more valuable if it included some darn proper power management. I’ve tried every UPS shield and board (sparkfuns lipo babysitter is about as close as it gets) and nothing seems to work. PLEASE PLEASE PLEASE UNTETHER ME FROM THE 5v MARSHMALLOWS AND LET ME READ THE DARN BATTERY STATE FROM THE SOC. /half thought out rant.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s