Friday, September 30, 2016

Driving Lights

My wife's biggest concern about me riding is the safety aspect - namely that others can't necessarily see (or register that they're seeing) me on the bike. I wear a bright yellow jacket, and add a reflective vest at night, but that's just not quite enough. After setting up my auxiliary power circuit (, I decided to tackle driving lights.

I'm not a cheapskate, but I don't like to spend money where it's not needed. So while my first thought was to spring for a set of Denali driving lights (north of $200), I decided to give something more affordable a try, first. Enter the Lylla headlamp: $26 on The lamp ships with a switch (which I've set aside and saved for another project) and two LED lamps. A few days after I ordered, the lamps arrived. They were, well, larger than I expected!

As always, the first challenge was where to install the lamps. They ship with a bracket, but the default configuration requires the bracket be mounted to a round bar which is perpendicular to the direction of travel. It meant I couldn't use the engine guards, and the generous fairing on the Strom also meant I couldn't use the handlebars. Eventually I realized the fender bolt would be perfect:

With the destination selected, the next step was to slightly modify the bracket--the shoulder on the fender bolt is a tiny bit larger than the hole at the base of the light frame:

The benefit of cheap Chinese metal is that it files quickly.

Once I modified the base of the bracket, it was simple to get installed:

With the frame mounted, it was a simple matter of installing the light and closing up the frame:

 Finally, I wired up everything to a power lead I pulled up from the fuse block in the back, and presto - there was light!

Auxiliary Power Mod

I wanted to add a variety of auxiliary power components to my '08 Suzuki V-Strom (DL650), way back when I bought it. I've been sitting on this project ever since - here's the write up (with a few photos).

The V-Strom has one or two spare, switched circuits (with an amperage rating of 10 amps or so). On a bike that'll eventually have driving lights, USB power, 12v power, GPS, perhaps heated grips and/or seat, that extra circuit or two won't go far - you'll end up making a choice: "Do I want warm hands, or do I want my GPS?" I don't believe in a world of 'or' - I'm always living life in a world of 'and' (it drives my wife crazy sometimes). So I quickly recognized a separate series of circuits would be necessary in order for me to stack on new features. And thus my project was born.

I started out by buying a marine-grade fuse block. My first was a 12-circuit block, which I quickly realized was going to be too big (I had originally planned on installing the block near the battery under the seat). So I downsized to the six circuit fuse block:

I bought this back in February, and it's sat unused taking up room in my drawer ever since.

Next, I knew the fuse block had to be direct-connected to the battery. It couldn't pull power for everything it'd support from any existing circuits. But I also knew I didn't want to risk parasitic (or accidental) power drains and a dead battery, so I knew it had to be 'switched' with the motorcycle's ignition. Therefore, my next requirement was clear: I needed a relay connected to the ignition, which would close the circuit from the block to the battery.

A Little Bad Weather Can Be a Good Thing

In late September, my wife had a trip scheduled with some friends. I planned to take my own trip, riding the Strom down to Canyonlands, then returning to Salt Lake via Colorado and Dinosaur National Monument. As the trip date neared, the weather forecast worsened. While my destination basked in 80-degree sunshine, the route there was experiencing Utah's version of biblical floods (ie, 2" of rain in a 24-hour period). I chose not to go (and I was grumpy!). As Saturday passed, the weather cleared and I hopped on the bike to visit my friend and "elmer" (amateur radio speak for 'mentor'). Chuck and I tackled the install, and I'm tickled pink with the results.

The Install

Fuse Block Location

Our first task was to find a location for the fuse block. I ultimately chose to put it where the factory tool bag is stored. It's accessible, but well-secured:

Relay Setup

After choosing the location for the fuse block, our next task was picking a circuit to power the relay with. It could honestly be any circuit, but we noticed in the fuse box that there is a "spare" circuit which is actually wired and functional (as opposed to just being an empty space in the fuse box):

We pulled the fuse box out, removed the fuse box for the starter motor so we had some room to work, and simply tee-ed off the "spare" wire and ran that to the relay. We ran a wire from the relay to ground, flipped the ignition, and heard that beautiful sound of the relay closing. Successful step 1!

Putting it Together

Finally, we needed to get the actual power from the battery to the fuse block. We connected a second ground and ran it straight to the fuse block's ground pole. We then ran power from the battery to the relay and from the relay to the fuse block's power pole. It looks a bit confusing, but again - it works.

Here's a shot of the fuse block (no fuses installed and nothing connected - but it powers up great):

And again - the final installation:

Thursday, September 29, 2016

Happy Trails Center Stand

I've had my eye on a Murph's Kit center stand (, but he stopped carrying them (to his credit, he recently pointed me elsewhere, but I'd already purchased one elsewhere). With SW Motech and other stands coming in well over $200 (as much as $280) for my '08 Wee, I started hunting the forum. I came across a reference to Happy Trails (, which is located just north of me in beautiful Boise, Idaho.

I put my order in for their affordable center stand on Monday - it arrived today and was installed in about 20 min over my afternoon work break. Here's my report.

Installing is literally a snap. Four bolts, some spacers and a few washers. The directions are well-written and it's easy to follow along (provided you are even somewhat mechanically inclined). The only thing I recommend is to dry-fit each of the four bolts. My Wee had paint and grime in the lower bolt holes, which made threading the bolt a bit difficult. Also keep in mind that the top bolt on the right side is simply a beast to get to. Accept it--as the Tao says, take the path of water... Some patience and you'll get it.

The item was well-packaged and arrived without damage and with all of its parts. Unlike some center stand kits, the springs are pre-installed, making the overall installation quick and (relatively) easy. Once the bolts were sorted out (large 10mm bolt on bottom, smaller Allen-head 8mm bolt on top on both sides), I performed the install.

Oh--unless you like redoing things, I recommend some blue Thread-Lok on the bolts.

The left side is the side recommended to start with. It went pretty easy, once I learned to pre-thread the bolts. I started with the top bolt, then installed the bottom bolt. Snugged everything up real tight.

Here's where patience comes in. Start with the bottom bolt, and add both of the extra washers for spacing. Snug it up, but not too tight - you want the bottom bolt to align the bracket, but not to hold it too rigidly.

Next, carefully insert your left hand into the miniscule space between the wheel and the exhaust pipes (obviously don't do this while the pipes are hot). Slide the 8mm bolt in through its hole, then carefully slide each washer and the spacer over it. Align the bolt and through some sort of voodoo, start threading it. I used a very long 7mm allen wrench. It didn't align well, so I went carefully. If you have a wobble-head (round-head) allen wrench, all the better. I've yet to invest...

As you can see, the "fit" is tight (it's not really a fit - had to pull the allen wrench out with vice grips). But eventually you'll get that top bolt tightened. Grab your torque wrench and torque everything down (BTW: 17 foot pounds is 23.5 NM and 34 foot pounds is 46.5 NM).

Next up: learning the balance point. It was a struggle to get this on the stand the first time. I'm glad I have it now - lubing the chain should be a lot easier (instead of chasing it all around the garage and driveway).

Tuesday, August 9, 2016

Tablet as GPS

I've been building up a stock 2008 Suzuki VStrom 650, into a more comfortable, better equipped adventure bike. One of the modifications I have made is to add the ability to use an old Nexus 7 wifi tablet as my GPS unit. I'm kind of a cheap guy, so as usual that means I've needed up spending more than necessary, in an effort to keep the investment cheap.

The first need was power. You can't take a multi-day ride with a tablet on maximum brightness and not have aux power. I purchased what looked like a rugged 12v USB socket from Amazon--unfortunately, it died before I could use it (no clue why--the wires show no sign of heat damage, the inline fuse is fine, and it has never been wet because I garage my bike at all times). At the time of this writing, I am back to the drawing board on this step.

The next challenge was the mount--how to secure a tablet to the bike. The tablet I have chosen, the Nexus 7 wifi, is really light. I purchased a rugged case for it, but even then it's well under a pound. My first effort was to try to hack a cup-holder phone cradle to work--I tore it apart till I just had the stem, but couldn't find a way to install it without 1) compromising safety and 2) damaging the very visible cockpit area. Finally, I bit the bullet and purchased a RAM Mount marine mount as well as and Adventure Tech GPS mount ( The mount install was painless and the RAM mount seems really secure. (NOTE: I had to push the photos quite a bit to get them lit up enough to see, so they're grainy):


The next challenge was mounting the tablet to the RAM Mount. The case I purchased has a rubber cover for the tablet, with a hard plastic back which separates from the rubber cover. I matched up the RAM mount mounting plate holes to the vertical and horizontal center of the rigid plastic back, drilled holes, and used some flathead automotive mounting posts to fix the plastic to the mounting plate.

Now I have a ruggedized tablet fastened to a RAM Mount, just above my instruments, which it is visible but not distracting. Using Bluetooth, I can connect my Sena headset to the tablet, where I receive turn-by-turn directions as well as music (the Sena can connect multiple devices, so I also have my phone connected, in order to take calls).


Why a tablet, instead of the Garmin GPS most riders carry? Price, convenience, and functionality.
  • The Garmin GPS is $500-$600 new. I already own the tablet.
  • The tablet has a camera which will take shots (still and video) right through the windscreen, so it's a great way to capture snippets from the road.
  • The tablet allows me several options in terms of GPS apps.
  • I can run Rever on my tablet, which is how I plan, track, and share rides with others.
  • The tablet also allows me to write and assemble blog entries.
  • With the tablet, I can connect to and pull content off my Nikon J5 as well as my GoPro, to enhance blog entries.
  • The tablet is lighter than a Garmin, but has a larger screen and much higher resolution.
  • With an Android device, I can keep in touch via social media whenever I stop. If I'm not somewhere where there is wifi, I can use my phone as a hotspot.
I proved this out on the road recently, riding from Salt Lake City to Ely, NV to Wendover and back to Salt Lake City. The tablet is a bit heavy - the VStrom fairing moves quite a bit already, but it's obvious there's additional weight on it. Nonetheless, the system worked quite well. Once I get the power issue resolve, this will be a great solution.

Friday, April 1, 2016

IoT Excitement - NodeMCU Pushes the Weather

If you read my previous post, you know I've been messing around trying to decide what IoT stack to use as I build out a variety of projects. I've  been messing with NodeMCU a lot lately, in fact I've been able to connect it to a BMP085 sensor and publish intranet web pages with temperature and barometric pressure.  In the process, I've learned a few things about NodeMCU (a few additional things).

Basically, I find NodeMCU to be great at doing very little. No, I mean that literally - if there's something IoT really small you need to do, NodeMCU might be the right device. Might...

  • Ironically, in my previous post I discussed how NodeMCU could be programmed via Arduino. I was worried it might take up more memory, though, than programming in Lua. According to this blog, however, the opposite is true. Lua, being an interpreted language, sucks up tons of memory. I found that to be true - my original code attempted to open two connections in the same function. It couldn't run due to memory errors. 
  • I've mentioned before, but using NodeMCU is a kludgey experience. The device is awesome in principle, and it's only in its infancy, but connecting and disconnecting the USB cable to reset the device time after time... It gets old after a while. 
  • Lua is a relatively straightforward language, but it has its drawbacks (including taken up memory for comments).It took me two separate evenings to figure out how to successfully make an http connection. 
Regardless, let's jump in... The mission was to connect my IoT device to the cloud. The goal was to publish data to Weather Undeground - goal achieved:

I decided to connect to Adafruits IOT site, as well, just to make a little spiffy control out of it:

To upload data, I'm using a simple init.lua script, then the bmp180.lua script (standard), then the wu_lite.lua script I wrote:

-- BMP085 and NodeMCU Weather Underground
-- Submits temp and pressure to WUnderground

   alti=1509 -- set correction for your altitude location in meters
   sda=4   -- GPIO2 connect to SDA BMP180
   scl=3   -- GPIO0 connect to SCL BMP180
   pres=0    -- pressure
   temp=0    -- temperature
   oss=0   -- over sampling setting

--load BMP module and read sensors
function ReadBMP()
   bmp180 = require("bmp180")
   bmp180.init(sda, scl)
   pres = (bmp180.getPressure()/100+alti/8.43)/33.86388667
   temp = ((bmp180.getTemperature()/10)*9/5+32)
   --fare = (temp*9/5+32)
   --print("Pressure:    "..string.format("%.1f",pres).." inches")
   --print("Temperature: "..string.format("%.1f",temp).." deg C")
   --print("Temperature: "..string.format("%.1f",fare).." deg F")
   --print(" ")

   -- push to WUnderground
   host = ""
   param = "/weatherstation/updateweatherstation.php?ID=<WU_ID>&PASSWORD=<wu_password&" ..
 "dateutc=now&tempf="..string.format("%.1f",temp).."&baromin="..string.format("%.1f",pres) ..

   print(host .. param)
   sendRequest(host, param)
   -- host = nil
   -- param = nil
   -- ******************************************************************
   -- adafruit io
   -- create http client
   -- ******************************************************************
   host = ""
   param = "/api/groups/weather/send.json?x-aio-key=<Adafruit_IO_key&temperature="
   sendRequest(host, param)
   -- release module
   bmp180 = nil

function sendRequest(host, param)
   conn = nil
   conn = net.createConnection(net.TCP, 0)
   conn:on("receive", function (conn, payload)
               success = true
   -- once connected, request page
   conn:on ("connection", function(conn, payload)
   conn:send("GET " .. param.. " HTTP/1.1\r\nHost: " " Connection: close\r\nAccept: */*\r\nUser-Agent: Mozilla/5.1 (compatible; esp8266 Lua; Windows NT 5.1)\r\n\r\n")
   conn:on("disconnection", function(conn, payload) print(' \nDisconnected') end)
   conn:connect(80, host)
   -- release connection objects
   conn = nil
   payload = nil
   --host = nil
   --param = nil

-- First reading data
-- Periodic reading of the sensor
tmr.alarm(1,300000,1, function()ReadBMP()end)

I had a lot of logic issues as I went along, then ran into memory issues which forced me to refactor (which in and of itself wasn't necessarily bad - I drove some efficiency into my programming).

The next step is to set this up outdoors and let it roll for a day or to. Then I need to figure out how to insert a time stamp (Adafruit's IO site doesn't calculate it for you). Once I'm done with that in Lua, I'll build the same functionality in Arduino and see how much better it runs.

Thursday, March 17, 2016

Pi vs Arduino vs NodeMCU vs ???

It's official - the Internet of Things has a lot of, um... things. So many options! Consider this: my friend and I are working on a weather station. Of course, it can't just be a simple weather station, it eventually needs to be a cluster of stations that can be used to measure differences in micro-climates. More on that later, LOL.

The initial goal is to put a weather station on a roof, without wires. With so many little devices, the question is simple: which is the right device for the job?

  • I started in on this the other day when I started messing around with the GPIO pins on the Pi. In about 10 min, I was reading in temp and barometric pressure data and thought "Dang, that's easy!". The Pi is awfully powerful and, now with the Pi 3, wifi-enabled.
  • And then there's NodeMCU. Very cool little wifi-enabled device that can take signal on a variety of analog, digital and serial-dedicated pins. And then it can run Lua to actually form that data into "IoT" capable packages, like HTML pages or JSON packets. Finally, it can be a rudimentary http server, so data can be retrieved (conversely it could be written as a client, to push data directly into the cloud). Seemed to me to be the perfect solution.
  • My friend Chuck is a strong advocate for using the Pi with an Arduino on a Pi alamode board. The arduino collects the data, the alamode board pushes that data into the Pi, and the Pi processes it.
My take? I see four viable solutions for getting the data off the Sparkfun weather shield and into "a consuming sink" such as the cloud, a data aggregator like a database, or published to the web.
  1. Weathershield to Pi via GPIO interface
  2. Weathershield to Pi via Arduino
  3. Weathershield to NodeMCU
  4. Weathershield to Arduino with WiFi chip
Each solution has advantages and disadvantages, and that's what we're doing to explore now.

Weather Shield to Pi via GPIO

This is an elegant solution - it requires the Weather Shield, some connecting wires, and a Raspberry Pi. It's elegant in that there are few moving parts - wire it up, good to go. Right? Wrong. Not all of the Weather Shield components seem to have Python libraries available, which means the coding would need to be done in C. Not impossible, but not necessarily straightforward.

Acquisition cost: 
  • Weather Shield: $39.95 + shipping
  • Raspberry Pi 3: $35.95 + shipping
  • Misc parts: $5
  • Total: $80
Development effort:
  • Moderate to high

Weather Shield to Pi via Arduino

This is the easiest solution to build, frankly. The weather shield runs great on the Arduino, all sorts of libraries and sample code abound on the Internet. 

Acquisition cost:
  • Weather Shield: $39.95 + shipping
  • Raspberry Pi 3: $35.95 + shipping
  • Raspberry Pi Alameda: $35.00 + shipping
  • Misc parts: $5
  • Total: $115 + shipping

Weather Shield to NodeMCU

By far the most elegant solution, holy cow... Suspend disbelief briefly and take a walk with me... You have a weather station on the roof, which feeds data into a Sparkfun weather shield. That shield, in turn, feeds data into a NodeMCU chip - tiny, quarter-size chip with wifi on it. The NodeMCU does three things: 1) it pushes the data to a cloud service, every N minutes; 2) it serves the data up via JSON string to anyone on the local network, and 3) it serves up data via formatted HTML on the local network. Awfully cool, and the cost? Nominal.

What's the issue? Simple - the libraries for the components of the weather shield only exist in part, and it's a process of porting them to Lua to make them work. The other problem: NodeMCU only has a single analog pin, whereas the weather board uses three or four.

--> Caveat: the NodeMCU *can* be programmed via Arduino, using Arduino libraries. I need to look into this more; not sure if there's enough memory to do it, though. And the Arduino environment has convoluted support for outputting HTML. I think I just need an afternoon to figure it out though. But still, the bottom line is it's not the right tool for this job.

Acquisition cost:
  • Weather Shield: $39.95 + shipping
  • NodeMCU: $15.00 + shipping
  • Total: $55 + shipping

Weather Shield to Arduino with Wifi Chip

This solution is honestly just a variant on the above solution - the weather shield speaks to an Arduino (great library support) and the Arduino uses a Wifi chip on a shield to publish the data. 

Slightly more expensive than the standalone NodeMCU solution:
  • Weather Shield: $39.95 + shipping
  • Arduino Uno $24.95 + shipping
  • Ada fruit Huzzah wireless shield: $39.95 plus shipping
  • Total: $105 + shipping


The cheapest possible solution, using the Weather Shield with NodeMCU, is not possible because NodeMCU only has a single analog pin and the weather shield needs multiple. That doesn't mean NodeMCU isn't a useful tool - I have a couple of other projects it might be perfect for. It does mean, however, that it's the wrong tool for this job.

From a financial perspective, the lowest cost solution is the Weather Shield plus the Raspberry Pi. It presents some problems - probably not insurmountable, but there'll be some effort to integrate the Weather Shield natively into Pi via Python or C. The time spent may not be worth the money saved over the alternatives (which both make use of an Arduino to read and interpret results).

So a little research is needed, to see how well the Pi can work with the Weather Shield's components. That's how to solve this specific application, but making a global rule overall? Globally I think it's easy to say that the NodeMCU is a low-cost solution but will almost alway have a steep implementation curve, at least until the dev community matures and catches up with Arduino. Overall from a sheer convenience perspective, the best solution is either 1) Arduino with Pi or 2) Arduino with wireless.

Bottom line: my buddy Chuck is right. When I insisted I take some time to look into building this solution with something other than Arduino, he told me I was wasting my time. I *was* right in that it would be more elegant, but he is right from a practical perspective. Everything is just "there" and ready to use, if Arduino plays a role in the solution.

Wednesday, March 16, 2016

NodeMCU for the Absolute Beginner - Lessons Learned

About a year ago, a buddy of mine who knew I was really into Raspberry Pi and Arduino encouraged me to look into NodeMCU. It's an IoT hardware platform with an onboard Wifi chip as well as a linux-based OS which is programmable in Lua. I messed around with it long enough to see it connect to the web and download a test page from Adafruit, but honestly? I was starting my own business and absolutely swamped.

Fast forward a year. A long year. A year of almost no hacking - Arduino, Pi, nothing... On a whim, I broke out my Pi and started messing with the GPIO interface and soon had a BMP085 sensor connected to a Python script, writing temp data into a csv file. Pretty cool! Not included to quit while I'm ahead, and finding myself waiting on a couple of clients (and therefore with some 'flexible' time), I decided to break out the NodeMCU. Turns out, someone had gotten the BMP085 working on NodeMCU. After several hours across a couple of days, and running into a steep learning curve, I finally got my BMP085 working on NodeMCU as well!

NodeMCU - This Ain't a Piece of Pi (or Arduino)

OK so you want to jump aboard the IoT craze and get involved. You're familiar with Arduino but you want something lighter, faster, and network enabled. That fancy NodeMCU dev board has been calling you, right?

All in all, it's a nifty idea and it works well (once you get past the learning curve). But if you're coming in from Visual Studio, from Xcode or even from Arduino Studio, be warned: this is not a polished experience. In fact, it's pretty ugly and dirty. Lots of flashing, formatting, serial communications await you before you actually have a working application. It is definitely not for the faint of heart, but if you persist, you'll get there.

Not a Tutorial

This article isn't a tutorial, per say, but a collection of things I picked up over the past few days. Really, there are 3-4 'gotchas' that I'm going to document. There are plenty of tutorials out there, but many of them skip over the 'what the heck do I do now' scenarios. Hopefully I can fill in the gap for you a bit:
  • Flashing can be tricky. Use Windows.
  • Establish a serial connection as the Node device powers up, so you can see any error messages.
  • Debugging is a pain - you need to check for messages as soon as the device boots.


I did most of my work on my Raspberry Pi--not really sure why except that it's a throw-away environment where I'm always in screen or minicom, so I wasn't overly concerned about messing things up, and I had all the tools I needed. It might be faster to work elsewhere (I'm running a Pi 3 B+ so it's actually not heinous). There's even a fancy flashing tool (esptool) available for Linux. However... don't do it. I ran into a really weird issue where I saw symptoms like:
  • Device showed up online, but worked 'wonky'
  • I could program it in Arduino studio with the NodeMCU plug in
  • I could not connect to it on Linux over serial comm, unless I tried 115200, but even then things were just weird.
I tried refreshing it with the esptool, which appeared to succeed, but which in the end actually failed.

The answer? Use the Windows flasher tool to flash the build. I spent a good 2 hours one evening digging around trying everything I could think of and finally powered up a Windows machine, flashed it and <poof> everything worked great.

Don't. Seriously, just don't flash it on Linux. Use Windows. It's worth the time you'll save.

Establish Serial Quickly

When the NodeMCU powers up, it very quickly spits some diagnostics to the serial port. It's important that you catch those diagnostics, to be sure you see any messages that might crop up, oh, if your code has a syntax error or such. There is NO INTELLISENSE and NO DEBUGGING on this platform. If you write a mistake, you're not going to catch it any other way besides 1) manual code review or 2) catching the Node as it boots. So be quick on the "screen /dev/ttyUSB0 9600" command, as soon as that device boots.


I said it above, but... I created a web page to serve up my inside temp information. I had some syntax errors on the page (not surprising, since I was editing in Leafpad and had some rather convoluted HTML code). I tried three ways from Sunday to get the thing to run. I rebooted it 15 times, but each time I tried to connect, Safari or Android Chrome responded with a connection reset error. I could ping the device (and get responses), but it just wouldn't serve a page.

So then I remembered my point about establishing serial quickly. The next time I powered up, I opened up a serial console ASAP and sure enough - the device spat out some error message about malformed HTML. Fixed it and I was good to go, but I lost a couple hours on this.


I see a lot of great uses for the NodeMCU devices. Remote weather stations no longer need wires. You can put moisture sensors in the far corners of your damp basement. I'm even planning to use one for model rocket telemetry information. It's really a clever device, and the Lua language is rather fun to use. This is going to be a fun device in my arsenal. Keep an eye, by the way, at my other blog because I have a feeling the NodeMCU device is going to come in handy on penetration tests and such.