Saturday, September 27, 2014

Powering a House

I did some preliminary assessment on the not-yet-smart-ish home's electrical system to get a better understanding of exactly what I'm working with.  One of the things that's nice about having worked on variety of projects over the years is that you run into familiar sights from time to time.  I should've known that DC power systems will look similar regardless of whether it's for a solar powered car or power generating kites, but it still was a pleasant surprise to peel back the layers and be presented with some vaguely familiar.

Main Inverter and Charge Controllers for the house
As the house is completely off-grid, it's basically a closed system consisting of batteries for energy storage, bunch of solar panels and a backup diesel generator for power generation, and an inverter to supply 110V AC for the house.  Even some of the names were familiar - Trace Engineering, which built the inverter used here, is owned by Xantrex whose chargers we used extensively back in the solar car days.

Lead Acid Battery Pack
The battery pack has nominal voltage of 48V, consisting of 3 parallel strings of 8 x 6V batteries.  I couldn't read any battery pack model numbers besides the maker (Deka) but the size of it looks to be about 300~350 AHr each.  So, across the 3 parallel strings, the rated capacity is probably just around 1000 AHr, giving it ~48kWhr for the entire battery pack (or enough to run a decently sized hair dryer for 24 hours!)

Measuring the voltages of the individual batteries showed some dead cells - since these are pretty old, beat-up, abused batteries, it's not surprising.  Some of the dead cells are on the top batteries from the two parallel strings closest to the battery connector - I'm guessing the relatively lower resistance due to shorter cabling probably resulted in imblanaced current draw.  I'll eventually have to replace them (with something like these - reading through some articles, the general recommendation seems to be to shoot for a single string of 2V batteries sized for the right capacity) but for the time being, I think just wiring them in a way to remove the dead cells and changing this to a 2 parallel strings while we try to get better power consumption numbers might be a way to go.  My rough guestimate is that we currently have ~24kWhr or usable storage capacity in these batteries.

It looks like there's enough solar panels for approximately 2kW of generation capacity.  Using the Solar Irradiance figures (put in California / San Jose / South South West / 53 degrees) shows a figure of 3.48 in December (least sun) and 6.63 in June (most sun), so we're generating about 7kWhr / day in an average sunny day in December, and 13kWhr / day in an average sunny day in June.  Assuming 24kWhr battery capacity, this means that it would take 3.5 days of full sun in December and 2 days of full sun in June to fully charge the battery pack even with degraded batteries and using only 2 strings in parallel.

To me, this seems like the solar panels are quite undersized for the batteries we have - it's interesting to see the trade-offs and engineering decisions made in a world of completely different economics.  When the system was put in place - probably 10+ years ago - solar panels were quite expensive and were likely to be the most expensive part of the system.  In comparison, batteries were cheaper and diesel at near $1 / gallon was probably a viable backup option in case of multiple days of cloudy weather.  In those days, it probably made sense to size the solar panels for about the average daily energy consumption around equinox.  This puts more cycle in the lead acid batteries, but that probably was an acceptable tradeoff to lower the cost of the solar panels.  And if it rained for a week or you get less sun during the winter, you'd just run the generator a bit to make up the difference

In 2014, you can buy ready to be installed solar panels for well under than $1 / watt while battery price has gone up and diesel price has quadrupled to $4+ / gallon.  These days, I think it makes much more sense to oversize the solar panels so that you put minimum number of cycles into (relatively) expensive batteries, and size the batteries to cover several days worth of energy consumption even with cloudy weather to minimize diesel generator having to kick in.

It's quite amazing just how far the solar module prices has come down, and how that completely changed the sizing of various components in the off-grid system.  And given this, for this house, the priority is probably to add more panels for generating capacity - probably at least triple the current capacity.

Saturday, September 13, 2014

Wifi Wifi Everywhere

Intel announced the Edison Module at the Intel Developer Forum this week.  To me, what's really exciting about the Edison is that this really is a full fledged computer (similar to Beagle Board families) with first class built-in support for wireless infrastructure in a tiny form-factor.  There's a huge difference in programming in an embedded quasi-OS environment like the Spark Core and having the full Linux environment available - it really opens up the world of software ecosystem that you can reuse.  Edison has two Silvermont cores and real storage (4GB eMMC) to go along with the connectivity - it really is amazing to see the technology being open and available at such small form factor and low price.

As far as I can tell, the cheapest and least fussy way to get the Edison is through Newegg - Sparkfun seems to planning a series of boards that could be plugged into enable various sensors and IO interfaces but for learning about the system and experimenting, it'd probably be hard to beat the Arduino interface board with 3.3V/5V tolerant I/Os.

At the other extremes, I came across the ESP8266 Wifi Module.  This seems to be something recently discovered by hacker community at large with minimum AT command documentation in Chinese and an information free website, but it's basically a very cheap, very simple Wifi modules available from AliExpress for well under $4 each including shipping.  The firmware that ships with the module exposes AT command set that can be accessed through the UART to use the module as a simple network device from a microcontroller.

What would be ideal, though, is to be able to run my application directly on the ESP8266 part instead of having another microcontroller interface it - it would allow cheap single board solution that can fit in wide variety of IoT applications.  There is a IoT SDK available, though it seems to provide secret bits in precompiled libraries.  From the makefile, I can tell that it's using Tensilica Xtensa core, which is similar to Nios 2, but on synthesizable for ASICs.

I'm trying to order some of the modules (payment verification is giving me some trouble) and once they're here, I'm hoping to figure out how to run my own code on the devices - this will be the perfect way to interface with the battery monitoring system!  The pictures of the module show a "Winbond" chip which I imagine is the serial flash that holds the code, so my plan is to try to tap into that directly and get the currently loaded firmware and to program updates directly to it.  But if I fail, I can always just stick a MSP430 or something to start gathering data from the battery monitor.

Picture from AliExpress - Serial Flash part
Between $4 ESP8266 and $50 Edison, my excitement with Spark Core has basically vanished.  Spark Core's "cloud software" doesn't interest me much (since you get so much more with full Linux running on Linux).  At $39, I can burn through 10 ESP8266 for the price of one Spark Core board.  What is clear, though, is that it's a pretty interesting time to be in this space!

Sunday, September 7, 2014

Wireless Connectivity for Smart-ish Home

There is a practical reason for my interest in Internet of Things, a personal itch that I'd like to scratch.  In the next year or so, I'll be moving to a completely off-grid house - not a single wire or pipe connects the house to rest of civilization.  Electricity comes from Solar with battery system, heating with firewood and propane, and water from a spring.  The house is in a dead zone as far as cellular service goes, so the only link out is through a Satellite internet connection.  It's little amazing that you could be less than 25 miles from the heart of Silicon Valley and be so isolated, but isolated it is.

There's a lot of little things to check to ensure that everything's running smoothly - when power or water goes out, you have no one to blame but yourself.  Right now, all the checks are done manually, but my plan is to automate as much of the monitoring as possible before the move-in date to make it easier to live there.

There's a lot of different random things to check spread over a decent area, and most of the places do not have power source, so ideal sensor network will be very low power, workable over longer distances (100+ meters) or at least mesh capable.  I still haven't figured out how to measure certain things either - it may require a camera pointing at a gauge in the worst case scenario, so even the required data rates aren't clear to me yet.

There is one system, however, that I think will be crucial to automate as soon as possible, and will be easy to do so.  The electrical system runs off of a bank of lead acid batteries at 48V, and there is a battery monitor installed within the house.  The monitor has a serial output at 5V signalling that can be used to get the various real time data including things like pack voltage, current / power being used, and battery state of charge.  As far as I can tell, the battery monitor is not independently powered, and runs from the 48V supplied directly from the batteries.  Since this battery monitor is located within the house, it should be within the range of the wifi router or a computer with a Bluetooth enabled.  Basically, what I need is the ability to wirelessly transmit the serial port contents to a computer somewhere.

On the bluetooth side, something like this will do the job, though it'll require a host computer to pull the data.  With Bluetooth Low Energy, it might be possible to get to much lower power levels, but I don't see an accessible and affordable development platform yet.  Broadcam has announced a low cost development kit that includes whole bunch of sensors that seems very interesting, but the documentation isn't quite there and I'm not certain if it's possible to crack one open to bring out the serial connections out.  But at $19.99, I figured I'd take a gamble. :-)  Once the part is here, I'll be able to open it up and see how extensible the fob is.  Even if it's not useful for this purpose, it might be interesting to have a battery powered Bluetooth Low Energy device with lots of sensors attached.

Going the wireless route seems to make more sense - having some sort of processing and computing ability at the battery monitor itself will help in dealing with things like buffering data in case of network outages and eventually being able to make decisions there.  Looking around for a wifi enabled development options, it seems like Spark Core would fit the need the best.  There's enough processing capacity and memory to do something interesting, and data can be sent directly to a server out on the internet to be stored and analyzed.  Unfortunately, it seems like the Spark Core's uart pins are not 5V tolerant, so I'll have to do something there.

But before I spend more time, money, and effort down the path, next time I head down to the house, I'll take the battery monitor apart to see exactly how the things are wired and use a computer to talk to the serial port on the battery monitor.  From the documentation, it's not clear if 5V rail is available on the header on the battery monitor, and whether there's enough current to drive a Wifi board on top.  If not, I'll have to find a DC-DC converter to bring the 48V pack voltage down to 5V.  Hrm, and that reminds me, I also need to figure out how the grounding is done in relation to the battery pack...  So many little details to figure out!

Monday, September 1, 2014

Software Defined Radio

I figured I'd spend more time reverse engineering and trying to build a custom SPI boot image, but then I came across the Quark SoC X1000 Board Support Package Build Guide which basically documents exactly what I was trying to do.  Good news is that the firmware update image (document calls it the capsule file) format was pretty much what I had found.  Well, next time, I'll try to RTFM harder. :-)

Lately, I've been tinkering with Software Defined Radio (SDR) based on Realtek RTL2832u part.  The chip seems to have an interesting backstory - originally designed for digital TV, someone found a debug raw output mode and reverse engineered it to make it a very low cost SDR platform.  I bought mine from Amazon for less than 9 dollars including shipping though it did take a while to get here from China.

Galileo board (with standoffs!) and the RTL2832u USB Stick
So far, I've been messing with individual tools from the rtl-sdr package and feeding airplane ADS-B data to FlightRadar24.  Airplanes equipped with the proper transponders will broadcast various data including the altitude, heading, ground speed, and GPS coordinates on 1090MHz.  It's been interesting to see the data captured by the radio as I see the planes fly by to land at SFO.

My short term goal is to get the ADS-B feed fully running on the Galileo - the rtl-sdr package relies on libusb package, so there shouldn't be any Linux kernel modules or changes required.  Ideally, I'd be able to basically take the 386 binary and run it on the Galileo, but we'll see how that works out. :-)  It also seems like the antenna that ships with the module is pretty crappy, so that'll eventually have to be resolved somehow.  Tuning to a local radio stations gives mostly muffled sound, though that might also be because I'm messing something up in the software.

RF and radios are something that I have very little experience with, and it's pretty exciting to jump into a field where everything is new and amazing!