Electrics, part 1 of ∞

05 Jul 2015


Boat (27) 
Not the Boat (12) 


Recent articles

25 Apr 2017

Ubuntu 16.10 LXC host on ZFS Root, with EFI and Time Machine

Still completely unrelated to boats, but I needed somewhere to put this. Here is a blow-by-blow guide to installing a minimal Ubuntu 16.10 to a ZFS root, booted from EFI, which as used as a LXC host to act as an Apple "Time Machine" destination.
mike 25 Apr 2017 at 17:20
14 Mar 2017

How to connect any serial device to the internet

A completely generic script that will proxy serial devices over HTTP, turning USB-things into internet-things.
mike 14 Mar 2017 at 23:00

Design Overview

I gather there are two approaches to boat electrics, minimal and complex. It's fair to say I've gone for complex. I had several goals at the start of this project.

  1. I want to be able to get as much data as possible in an open format and crunch it. At the time that meant NMEA0183, as the protocol was easy to work with (and extend) with relatively simple hardware - I have a better understanding of NMEA2000 now and might make that decision differently if I were to do it again. It also means no single-purpose integrated devices (eg radar that only works with the manufacturers display). If it won't talk an open protocol, it's not going on the boat.

    Why? Partly because I'm a software guy and I like data. Partly because a well-programmed computer with enough data can help compensate for both lack of crew and lack of sleep. Like HAL-9000, but nicer.
  2. A corrolary to this is I'd rather spend the money to get the right sensors from the start; "right" here meaning high accuracy and low maintenance. It's a bit more up front but it will allow me to be lazy, one of my core skills. Automating stuff will enable my laziness, and this requires accurate information to do right. It's also easier to upgrade software than hardware, which means getting the raw data into the system. The analysis of that can be improved over time.
  3. I wanted electronically controllable switches - so I want to be able to turn stuff on/off electronically as well as with a physical button. This is partly geek vanity, and partly because if you have an electrically busy boat, being able to manage power is important. Again, it's all part of having the information available to act on - these guys went around the North Pole in a Corsair C-31 and at one point were losing power due to a stuck pump, which they didn't spot for some days. Not going to happen on this boat. Being able to turn on the fridge from your phone an hour before you get to the boat didn't influence this decision in any way.
  4. I don't want to be pulling this all out in 12 months time to do it again, so I'm trying to make the right decisions now. Partly that means doing it right - using the right wire, waterproofing where possible, partly that means going as cutting edge as I can (which involves taking a few risky purchasing decisions), and partly it means designing components that work together but can be replaced individually.

The Brain

Note most of this section is now outdated. Read the updated article

Here's the brain of the boat - this is a Hummingboard i2ex, a single-board computer in the same form factor as a Raspberry Pi but faster. It's in a 250x200mm IP68 enclosure along with an OpenUP2 and a Buck Converter to step 12V down to the 5V required to power the board. There's also a battery for the real-time clock poking out the bottom. I glued a sheet of industrial velcro to the box and have stuck it to the "ceiling" of the boat

The computer is running Linux (Ubuntu Trusty) and is plenty fast enough to run my Java-based server, which is talking to the rest of the boat via USB. The OpenUPS2 is not (yet) officially supported under Linux, but it does work with a bit of tinkering - install the standard Ubuntu NUT package (apt-get install nut) and create or modify the following files to look like this:


    #  openUPS2 Intelligent UPS 
    ATTR{idVendor}=="04d8", ATTR{idProduct}=="d005", MODE="664", GROUP="nut"




      driver = usbhid-ups
      port = auto
      productid = d005
      desc = "OpenUPS2"


    ACL all
    ACL localhost
    ACCEPT localhost
    REJECT all


      password = secret
      upsmon master
      allowfrom localhost


    NOTIFYCMD /etc/nut/notify.sh
    POWERDOWNFLAG /etc/killpower
    RBWARNTIME 43200
    MONITOR openups@localhost 1 upsmon secret master
    SHUTDOWNCMD "/sbin/shutdown -h now"

You must then unplug/replug the UPS or reboot to get the driver loaded with the correct group permissions for NUT - once done you can run upsc openups to display the UPS data, and the upsmon system daemon will automatically shut down the system when the machine is disconnected and the UPS batteries are close to flat. Estimated uptime (on 3 x 3.4V, 1500mAh LiFePo4 batteries) for this system is about 45 minutes, and that's while powering 8 USB devices including a hub. Here's the output of upsc - the batteries are fully charged at this point:

    battery.capacity: 100
    battery.charge: 100
    battery.charge.low: 5
    battery.charge.warning: 20
    battery.current: 0.980
    battery.mfr.date: ?
    battery.runtime: 3932100
    battery.temperature: 12.65
    battery.type: ?
    battery.voltage: 10.39
    device.mfr: Mini-Box.Com
    device.model: OPEN-UPS2
    device.serial: LI-ION
    device.type: ups
    driver.name: usbhid-ups
    driver.parameter.pollfreq: 30
    driver.parameter.pollinterval: 2
    driver.parameter.port: auto
    driver.parameter.productid: d005
    driver.version: 2.7.1
    driver.version.data: openUPS HID 0.1
    driver.version.internal: 0.38
    input.current: 0.814
    input.voltage: 488.11
    output.current: 0.000
    output.voltage: 355.00
    ups.mfr: Mini-Box.Com
    ups.model: OPEN-UPS2
    ups.productid: d005
    ups.serial: LI-ION
    ups.status: OL CHRG
    ups.vendorid: 04d8

Update: 22 January 2016

Ironically given my profession, the computer has caused problems. The Hummingboard did not work out: when enclosed in an an airtight case, it crashed intermittently. I eventually traced it to temperature - it's rated to a measly 40° (for comparison a Raspberry Pi is good to about 70°). Although it has no thermometer sensor, the mSATA flash I added does, and the a SMART readout showed the maximum recorded temperature at an astonishing 114°. That was not going to work out well.

I discarded the Hummingboard and went back to "Plan A", a Fit PC4. This is a lovely design, a bit more power hungry with a TDP of 8-15W. I currently have 4 USB hubs and about 20 USB devices plugged in and the whole system is drawing 14.4W. So imagine my surprise when this computer, too, started to crash unexpectedly - the logs showed the CPU freezing before the whole system hung. This was finally traced to the UPS, which is supposed to be able to deliver 5A at 12V. In practice I think the computer was being starved of power: once I removed the UPS everything started running properly again.

Ironic that a device designed to provide stability caused just the opposite. The moral of the story is if in doubt, more power. And more fresh air I suppose. But mostly it's more power.

Update: 30 March 2016

It's not the UPS. Removing it removed these symptoms for a while, but they're back. More investigation is required.

Update: 26 May 2016

I hate computers. More in this article

The Nervous System

Communication around the boat is with USB. Various buses were considered and discarded: wireless, too flakey. NMEA2000, too proprietary and single-purpose. I2C, too short range and doesn't scale nicely. USB is easily expandable, there's lots of cheap hardware and it can work in a star (or star of stars) configuration, so I can have hubs in key locations. This saves on cabling - I have a forward hub which talks to the depth sounder, log, masthead anemometer etc. and then relays this back to the primary USB hub fixed to the rear bulkhead. The USB spec allows up to 5 hubs to be chained, most computers implement at least one hub internally so you won't get to five - from the external USB ports on this particular computer I can chain two hubs, no more. USB3 is marginally more expensive but future proof.

Note this section is now outdated. Read the updated article

Here are the hubs I'm currently using - each of these takes a nominal 12V in and I've tested them to 14.2V, the first accepts bare wires and the other two take a 2.5mm barrel plug. There is a lot of crap masquerading as USB hubs on ebay, and also be careful of hubs that require a power button to turn on after power is applied - as useful as a window in a submarine. If a hub has a power button, avoid.

  • Startech 7 port hub - pricey 7-port USB2, steel case that screws to the wall.
  • Anker 68ANHUB-B10A - 9-port USB3 plus a charging-only port which puts out 2.1A - enough to run a small computer. To mount this I glued a sheet of foamboard to the back and screwed the foamboard to the wall.
  • Orico H727RK-U3 - 7-port USB3. This takes 12V input, not 5V as described on Orico's own site. Same story as above, glued it to a sheet of foamboard and screwed to the wall.

The power cabling is almost all 1.5mm² twin-core cable, mainly Alphawire (a few of the heavier circuits use 2.5mm² or 4mm², and the battery cables are 25mm²). I don't know how much is in exactly, but I'm onto my fourth 30m reel, which is horrifying. This is all run through 38mm conduit, which was a special order through the local electical wholesalers. The 25mm conduit you can buy from your local retailer becomes impractical beyond about 6 cables, although you could get more through if you don't use twin-core and run each wire individually. I'm labelling each wire with the cheapest label printer I could find (a Brother PT-1000), heatshrink over the label, dip the stripped wire in "NoAlox" then crimp on a ring or 6.3mm connector (variously called "faston" or just a crimp connector) with heat-shrink insulation - these are so much nicer, you can get them on eBay or from various stores, then shrink it all with a heat gun.

The Heart Battery

Giving up on the body part themed subtitles. Driving the boat electrical system is the battery, which is a home-rolled LiFePo4 battery.

There's a whole page on this so not much detail here - this is an overview article, so I'll just cover how it fitted in with the whole. Mainly I needed a place to put it, and at 16kg I can place the battery further aft than I would with a 50kg lead acid. So I glassed in a shelf in the starboard quarter: the battery box (seen here in brown) fits neatly on top and will be bolted down.

Power Distribution

When I went into this process I hadn't imagined the monstrous hydra of cabling that would ensue. Here are the power circuits I ran:

Circuit Current1 Notes
Masthead Light 200mA This is a NASA marine Supernova LED light - power one way for all-round white, reverse the current for a red/green/white tri-colour2
Port/Starboard lights 160mA Two Hella NaviLed Compact LED lights at the end of the bowpole, drawing a marvellous 80mA each
Stern Light 80mA Hella Naviled Compact, another 80mA. The masthead all-round white, bi-color and stern lights on seperate circuits are (I think) the minimum required to meet the COLREG requirements for a motorsailer < 12m long 3
Cabin Lights 10A I've got these on two circuits for redundancy and load sharing - 10A is a theoretical peak draw if every light was turned on to maximum. Unlikely, especially as I will have them on dimmer circuits
Deck Flood Light 6A 2 x 36W LED flood lights mounted on the spreaders. An ebay special from China
12V AUX 10A A cigarette lighter socket to plug in anything - laptop charger, emergency pump etc. There's actually two of these, one forward in the head. They're also not regular cigarette lighter sockets, which have to be the worlds worst design for a mating electrical connection. The Blue Sea devices linked to will accept a standard 12V plug, but also a compatible locking plug which will not shake loose, giving me the best of both worlds.
Computer Display 2A I plan to put in an IP65 daylight-readable touchscreen in the bulkhead, where you'd normally find a chartplotter. I've yet to find one I'm happy with so this is pending.
Computer 1.5A This is the primary computer described above, running all the time. Typical draw is measured at about 1A4
Water Pump 4A A Whale Watermaster FW0814 to extract water from the primary water tank in the bow
VHF 5A A Lowrance Link-8. Recommended fuse is 8A, expected draw will be less than that but is unmeasured5
Transducers 1A Specifically this is a depth sounder (Airmar DT800), log for water speed (Airmar CS4500 ultrasonic - extravagance number one) and masthead anemometer for wind speed/direction (LJ Capteurs CV7 ultrasonic - extravagence number two. See paragraph two on this page for my justification)6
Fridge 8A This is a bog-standard Danfoss BD35 compressor. I had this fused at 8A, it kept tripping so I have increased it to 10A, which is roughly where the current spikes as the compressor starts up before settling back to about 5A. Also includes my whizz-bang custom controller.
Stereo 4A Decent tunes are a critical part of this operation. I'm a big fan of the Tripath T2020 amplifiers which deliver a lot of bang for very little buck. Not measured the power draw yet, 4A is an overestimate I expect.
Hob 8A I've put in a Wallas 85DT diesel-powered hob, which I'm yet to fire up. If I was doing this again I might look at alcohol-fired hobs, which I gather have come a long way since I recall trying to ineffectively boil water on them years ago. I'm told the Wallas is at its best when used from a single dedicated fuel tank, which is my setup. One nice thing about the Wallas is it comes with a blower lid to heat the cabin. Another nice thing is it's not propane...
AIS Transmitter 2A I have installed a Garmin AIS-600 transceiver. My VHF includes AIS receive functionality, so this will likely be powered up only when I want to transmit, i.e. at night/fog/on passages. Incidentally I went with this unit because it has an integrated antenna splitter which functions while powered down. A splitter was a must for me as ISAF Cat 2 offshore requires a masthead AIS transmitter. With a single mast this means sharing the antenna, as two adjacent VHF antennae would quickly fry the second device when the first started transmitting.
Radar 2A Not installed, but I have a covetous eye on a BR24 broadband radar for the future
Autopilot 2A Not installed, this will likely be a custom design which I'm still working through. 2A is estimated.
Hot Water Pump 2A I'm not sure if this system will see installation, but I do have an unfeasibly complex and still untested hot water system. Why? Because unlike an inboard diesel, an outboard motor doesn't generate hot water as a byproduct. I didn't think of this until later, so squeezing one in required a bit of... lateral thinking. "Eccentric" covers it nicely. If it does go in, it will need a pump.
  1. this means estimated max continuous current, rather than the size of the fuse. Quality of estimatations may vary.
  2. you might question the usefulness of a masthead tri-colour on a rotating mast. It's a backup, a requirements of the ISAF Cat 2 offshore regulations. If it gets to the point I need them I can always prevent the mast rotating
  3. under power: port/starboard light and masthead white. under sail: port/starboard light and stern white. anchor: masthead white.
  4. this includes my vast array of USB-powered devices - barometer, roll/pitch sensor, water-tank level sender, GPS, wifi ...
  5. there's a secondary GPS on this circuit as well.
  6. you might question the usefulness of a masthead anemometer on a rotating mast. Yes, it will require a device to compensate for the rotation. I have the board designed, yet to test.

I'll concede there are a few non-essential items on this list but I don't think it's that silly: yet somehow it still comes to 19 individual circuits (lighting is split over two). Many of these have multiple devices on them, i.e. the lighting, transducers, and the various USB hubs lumped in with the main computer. The minimum practical allowable thickness for any circuit under ISO10133 is 1.5mm² - technically it's 1.0mm², or 0.75mm² for twin-core cable, but these gauges are harder to find and once you start bundling them you have to derate their capacity, so 1.5mm² is a more practical minimum. Click the image to the right for my fun-filled print-out-and-keep guide to current carrying capacity!

Anway, the point is this adds up to an awful lot of wire, and I haven't included USB cables, speaker cables, NMEA0183 data cables, or the main cables to the battery, motor, solar or 240V charger. Conduit doesn't seem like overklil now does it? Neither does Nigel Calder's suggestion of an electrical bus, which I admit I raised an eyebrow at when I read it. Not any more.

There's also no dedicated bilge pump, which I'm a still a little troubled by even though I've been advised by those that know better than me, twice, that a positively buoyant boat without a lead keel doesn't strictly need one. I don't have a bilge so I suppose there's nowhere to put it anyway. I will be installing a shower pump (plugged into the forward 12V AUX) and will rig a bilge switch to allow it to double as a forward pump should I spring a leak. I refer you to Ian Farrier's unsinkability test photos for further justification, along with his observation that Sinking Is Not A Very Good Safety Characteristic. Hard to argue with that.

To be Continued

Expect more on this in the future, including details on how these 19 circuits are switched, and fused, without running this obscene mass of cabling to the living quarters of the cabin. Here's a taster: