Configuring My First XBee Radios

by January 25, 2012 11:36 AM

XBee Radios

These are my first three XBee radios. Two of them are already connected to SparkFun XBee Explorers and the one in the middle is tagged with a note to remind me which one is configured as the coordinator (I did the connecting and tagging of course - they don't come like that).

If you don't know already, a ZigBee network consists of exactly one coordinator and any number of routers and end devices. Get the book or read about it on Wikipedia if you want the full story - my aim isn't to reveal everything the book has to offer, but rather document my personal journey into embedded devices.

Firmware

The first step according to the book is to use a program called X-CTU (free from Digi) to ensure the firmware is up to date. So one at a time, I used the xbee explorer to connect the radios to my computer via USB. All three were already configured with the latest firmware so that was easy.

Time to configure and do the first test

X-CTU Configuration

The next step is to choose a terminal program that I can use to connect to the radios and issue AT commands to configure them. Since Windows no longer ships with a terminal program, I chose to just use the terminal tab in X-CTU. The author suggested picking a stand alone terminal program for various good reasons, but I just wanted to get to the good stuff.

The idea for the initial configuration and test is to set up two of the radios such that they can talk to each other wirelessly. This means putting both radios on the same network, or setting the PAN address (PAN = Personal Area Network), and then setting each radio's destination address as the other radio. The PAN is a number between 0 and 0xFFFF that you arbitrarily pick. A radio's address however is globally unique and printed directly on the xbee (or you can type ATSH/ATSL to get the high and low parts of the address from within the terminal program).

In the image you can see my configuration for the coordinator. I had already configured the router (using the information from ATSH and ATSL in the screenshot). The "+++" is how you enter into command mode where you can issue AT commands. Outside of that everything you type is sent directly to the radio and transmitted wirelessly. Notice how I had to type ATDL twice? That's because I took too long between issuing the ATDH command and issuing the first ATDL command. Basically the radio times out after 10 seconds and returns to transparent mode where it transmits everything typed instead of looking for commands. I knew it had timed out on me when it didn't return the red "OK". So I typed "+++" again and then reissued the ATDL command followed by the ATWR command to save the configuration permanently.

After that I waited until it timed out and then typed that last line. And sure enough, when I turned around and looked at my laptop (where the router was plugged in), there was the sentence that I had typed on my PC. Super basic and easy but still very cool!

What's Next

Like I said in my first post, I've already devoured the book. Instead of following along in order, I'm going to skip the doorbell and romantic lighting projects and jump to something I find more interesting: Simple Sensor Network (remote temperature sensors). I currently have three radios, so I'll have one connected to my PC as the coordinator and will put the other two at various points around the house. Exciting stuff!

Building Wireless Sensor Networks

by January 24, 2012 12:51 PM

Building Wireless Sensor NetworksI decided to dip my toes in an area where I have no experience: embedded systems development. Basically, I want to create real, physical things that I can point to, hold, hand to a family member, and maybe even sell.

I can't remember exactly why I picked Building Wireless Sensor Networks to get me started on this adventure. I believe I was reading a review of some other book where the individual said something about not particularly getting much out of the book and suggested this one because we'll get the same content plus so much more (working with the radios). I assumed I would get something .NET related so I could stay within my comfort zone, but at some point I pushed Buy and the deed was done.

I'm glad I did, because it has opened up excitement that I haven't felt in a long time. When the book first arrived I devoured it. As soon as I knew the parts I needed, I ordered a slew of components and tools and have since spent hours and hours reading about everything from home automation to hobbyist robotics nuts. All very cool and I couldn't wait to get started.

The Plan

I thought I'd try to document this journey. As anyone who blogs knows, having to write down your thoughts forces clarity like nothing else. Also, I hinted above about creating something I can sell as a product. I want to capture what I learn about that process because the little I've looked into it so far hasn't been very helpful. In fact, I have no freaking idea how I'm going to go from playground to my first sale. Maybe what I figure out will help someone else.

The Book

Building Wireless Sensor Networks is about just that - building networks of "sensors", or devices with sensors connected to them, that communicate with each other wirelessly. The networking part of the equation uses the ZigBee protocol, and the wireless components the author focuses on are XBee radios. The examples that require a microcontroller use the Arduino. In addition to the specific "how to" sections, I personally think the author did an excellent job of explaining just enough theory and the "why" of things to satisfy my curiosity without putting me to sleep with too much information. Even where I needed more, he explained it well enough for me to google intelligently and get all the detail I could possibly want.

What's Next

I'm going to use this post as a table of contents for this journey so I'll keep it updated with links to each related post. The very next step is to configure my first XBee radios (they're in!). Stay tuned...

Configuring My First XBee Radios

Personal Code Library + NuGet

by December 20, 2011 08:05 PM

As I was getting into my next consulting gig, I found myself copying yet again all of those utility extension methods and classes I tend to pull along with me into every project I work on. Enough is enough, I thought! That and it was a great excuse to finally play with NuGet.

You see, I've been avoiding creating a personal library all this time because I didn't like the idea of having an odd dependency that I included in projects. It would have a foreign or personal sounding namespace, versioning and updating it would be a pain, and developers that came along behind me on the project would have this weird black box of random code. I wouldn't want to run into something like that on a project I joined.

Then I figured out that I could create a NuGet package that was content only. Not sure why I hadn't already put that together, but my original thought was that I would have to create a package that delivered a binary which would be referenced by the target project. Easy versioning and updating taken care of, but I'd still be left with the black box of random code. With a content only package, the actual source code from my "personal code library" actually ends up in and lives in the target project.

The final kicker was my noticing source code transformations. By using the $rootnamespace$ token, the NuGet package installer would transform the namespace declarations into whatever the target project was using. No weird or personal namespaces! Pretty much takes care of every problem I had with creating my library.

The Source

The source for my project lives on github in rtennys/Common. I know, real original name.

I set up a basic class library project and unit testing project. Not that I've done a lot of testing mind you, most of the code in the library has been in my possession for a very long time, but I plan to add tests as I modify and grow the core library.

The interesting part to me was automating the deployment into NuGet. Next to the solution file, you'll see my standard deploy.bat and deploy.proj files (if you've worked with me, you probably recognize these!). In here is where I use MSBuild to grab the current build version, copy all the source to a temp folder, replace my namespace with the $rootnamespace$ token, create the NuGet package, and finally upload the package to nuget.org. Very easy and very cool.

With the addition of a hotkey in Visual Studio (see here for details - I do it similar: no context menu, just a hotkey), updating my personal code in a target project is as simple as updating my library, running deploy, and then updating the package at the target. Crazy easy!

The NuGet Package

The package is called RobTennyson.Common. Installing it is as simple as running this in the Package Manager Console:

PM> Install-Package RobTennyson.Common

I don't know that I'd suggest using it since it's my junk pile and filled with my opinion on how things should be done. It's also likely to change a lot and often. But you're welcome to it if you'd like. You're also welcome to snoop around in it and tell me why I'm nuts for doing this or that (like my .Each and .F extension methods!).

Good times!

Tags: , ,

My First Consulting Gig Ended This Week - Was Awesome!

by November 19, 2011 07:32 PM

Like I said here, my first consulting job was a sub-contract with TEKsystems for a company called TD Williamson in Tulsa, OK. Though I’ll still be available if they need anything (questions about the code, bugs, whatever), I completed the last enhancement this week. I feel incredibly lucky that I got this as my first gig after leaving traditional employment behind.

The Customer

First off, I was fortunate with a very cool customer. I could be wrong, but the IT shop I worked with seemed a bit smallish. Whenever I needed something like access or a question answered, the team member who was my point of contact was able to get the answer or get it done insanely fast (sometimes less than an hour!). I needed a good bit of database help in the beginning (back slamming production to development, getting a copy for me to run local and thus disconnected, etc.) and several times I needed new access to other database servers I was asked to integrate with. Their DBAs were awesome! No bottlenecks or bureaucracy or anything to slow down progress as far as I could tell. If it wasn’t a small shop, it was an amazingly well oiled large one.

The Code

This was the surprising part. It's a classic Web Forms application. It uses straight ADO.NET for data access. There wasn’t a single using statement anywhere. If I remember correctly, I found 38 connections that weren’t being closed. Everything is done directly in the code behind. Found a few memory leaks in the Active Directory code. Same redundant email logic repeated all over the place. Magic strings everywhere... Getting the idea yet?

Despite all those negatives, I loved it! It has been a long time since I've been able to belly up to an editor and just engross myself in code for hours and hours. The days flew by like they used to. All of the problems I mentioned above are crazy easy to fix; mind numbingly easy. It's almost like being paid to meditate.

In addition to these simple ways of drastically improving their codebase, I think they were pleased with how fast I was able to get enhancements done. I also fully automated the deployment and added versioning in a way that made it easier to know what is currently in production. All in all, I'd call it a successful gig for both parties and a great start for me.

Tags:

Azure Experience

by November 14, 2011 07:47 PM

This post is in response to a request to know the details of my experience with Windows Azure.

Production Experience

As of today (11/14/2011), I have no experience developing production applications for a company or customer.

Functional Experience

Being the code dork that I am though, I have played...

  • Windows Azure - I've deployed a couple of live sites to azure just to make sure I understood what it meant to code to, deploy to, and live in Windows Azure.
    • My personal site (http://www.robtennyson.us) - at one point I had written a micro CMS that I thought I might use going forward as my personal website. To manage the images linked from my posts, I took advantage of blob storage. All other content I stored in table storage. I've since switched back to BlogEngine.NET. Shared hosting for such a small site is cheaper and I found that backing up my site to be much more straight forward.
    • My business site (http://www.irohservices.com) - when I first started my business I thought I'd be cool and host my online presence in Azure. I started by creating something similar to what I had done previously for my personal site (Azure hosting, blob, and table storage). It didn't take long for me to decide that I wasn't going to put in the time to create a rich experience so I switched to WordPress and hosted it alongside my personal site. In addition to the time constraint, I switched for similar benefits as on my personal site (cost and backing up). Creating my custom theme and playing with PHP has been fun as well.
  • Windows Azure AppFabric - During my time with Microsoft, I created a caching proof of concept taking advantage of Windows Azure AppFabric (not Windows Server AppFabric - though I understand it to be almost identical from the developer's perspective). This turned out to be crazy easy to do. I haven't yet played with the other benefits AppFabric affords (ACS and Service Bus).

Summary

  • Windows Azure Compute
    • Web Role - two public sites 
    • Worker Role - played with - never needed in production
    • VM Role - no experience
  • Windows Azure Storage
    • Table - two public sites
    • Queue - no experience
    • Blob - two public sites
  • SQL Azure
    • SQL Azure Data Sync - no experience
    • SQL Azure Reporting - no experience
  • Content Delivery Network - no experience
  • Azure AppFabric
    • Access Control - no experience
    • Caching - proof of concept
    • Service Bus - no experience
  • Windows Azure Fabric Controller - no experience
  • Azure Market Place - no experience
  • Azure Virtual Network
    • Azure Connect - no experience
    • Azure Traffic Manager - no experience

So there you have it. The most interesting thing about my experience with Azure has been blob and table storage. If I had just gone with SQL Azure, I don't think much at all would have been different from the perspective of the developer. Once the connection string is set, data access is still just data access in code.

Tags: ,

Tulsa DNUG - Agile Code

by October 24, 2011 06:00 PM

My Tulsa DNUG presentation description:

From the Agile Manifesto: Responding to change over following a plan. From the manifesto's 12 principles: Welcome changing requirements, even late in development and Continuous attention to technical excellence and good design enhances agility.

Code that works to enable those three statements is code that I refer to as agile code. We'll talk about writing that kind of code by working through a simple example pulled from the book Agile Principles, Patterns, and Practices in C# by Robert Martin.

Like my last presentation, I burned through this lightning fast. And once again, people started opening up and turned the night into a great meeting. I'm not too surprised since it seems any topic that has anything at all to do with Agile brings out passion in people. It was a fun group and I'm glad they invited me over.

Oh, and what was my favorite quote of the night? "You can't cure stupid". Pure awesome!

See the code I used in the presentation here.

Fort Smith DNUG - SOA For The Developer

by October 10, 2011 06:00 PM

My Fort Smith DNUG presentation description:

Service Oriented Architecture has been a buzz word for a while now and gets talked about all the time. However, I see very few presentations targeting the developer and what he/she should be doing in code as an SOA advocate. In this presentation we surface an old and well known design pattern called the Gateway. When developing applications that talk to other applications (or pull data straight out of their databases!), this pattern can save your bacon at worst and at best will give you a clear and easy to see delineation between your app and external systems.

I actually burned through the presentation rather quickly and for a moment thought the whole thing was going to be a dud. And then people started opening up with comments and questions and I'd say the night turned into a huge success. Awesome group to present in front of. Thanks for the invite!

See the code I used in the presentation here.

My Software Consulting Gets Kicked Off This Week Thanks To TEKsystems

by October 3, 2011 12:35 PM

This week I start my first gig as a software consultant thanks to Megan Coger with TEKsystems. I'll be working with TD Williamson for approximately a month. Couldn't have asked for a better start. They're located in Tulsa, but I'll be working 100% remote and they were fine with my working a slightly shorter day - a six hour day working 9-3. That rocks!!

The interesting thing about this is what it took last week to set this up. You might recall that I started a business called Iroh Services. Originally, I had just created the LLC and was just going to leave it at that which would have made it a disregarded entity in the IRS's eyes and I would have simply been a sole proprietor. In order to work with TEK though, I needed to be a W-2 employee - either of theirs or of my company. So the scramble began! I talked with a lawyer and my accountant and eventually got everything going and all the paperwork done. So now I, Rob Tennyson, am an employee of a company called Iroh Services, which I also happen to own. It turns out both the lawyer and the accountant like it better this way anyway because the delineation between me the person and my company is much more solid now.

As things were being printed, signed, scanned, and emailed back and forth, I remember saying at one point, "I never realized how fun this working-for-myself-thing would be!" :) Truth be told though, it was kind of fun. It feels completely different doing admin crap like that when you know exactly how important it is. This is compared to the admin crap I used to do where I just knew it was a worthless waste of my time.

All in all, I'm really looking forward to getting started. I love zen-like days of pumping out code and I think that's exactly what this contract is going to be.

Two Weeks Down and No Software Ideas Yet

by September 26, 2011 11:20 AM

I've officially been unemployed for two weeks now (today starts the third week). In that time I've created a DBA, created an LLC with the state of Arkansas, gotten an EIN for that LLC, and I've put out the initial website for the company. Nothing sexy and definitely not the final version, but I of course needed to grab the domain name and wanted something there other than just a godaddy parked page. And just for kicks, I put it in Azure even though I don't need the scale and I'm not even using the storage. I did this for two reasons. First I wanted the experience and nothing teaches better than using something for real. I plan on adding content management features and things that while unnecessary for a simple web presence website, will provide richer Azure experience. The second reason is because I read about changes they are about to implement to make it much more affordable for small time websites and businesses. A great move on their part if they want developers to start playing with it and becoming advocates.

What business name did we decide to go with? Iroh Services

Iroh is from our favorite Avatar character, Uncle Iroh. Everyone in the family is a huge fan of the cartoon and we all love the zen-like uncle and his hedonist ways.

Of course the business is really just for accounting and liability safety when I do consulting. My real goal of becoming a micro-ISV has been on my mind and has occupied the vast majority of my time with research and grand pondering. I've had several friends offer their thoughts and software ideas and am still thinking of getting into a large project with my uncle and cousin. Nothing as of yet has really set me on fire though and I'm apparently brain dead when it comes to coming up with my own software project ideas. Still hopeful.

The freedom has completely rocked. I love dropping my daughter off at 8:30 instead of 7:15 and picking her up at 4:30 instead of 5:30-6:00. I'm also home when my oldest gets off the bus around 4:00 which is way cool. Originally I was going to pick up the little one early enough to have both of us home by the time the bus arrives, but she kept getting on to me about missing afternoon activities - especially the case on dance and soccer days. That's cool though - we're still home before the 5:00 traffic hits and our evenings seem so much longer now.

Regardless of coolness though, money will have to start flowing soon. Guess I'll get back to my grand ponderings :)

Leaving Microsoft

by August 22, 2011 05:04 AM

Remember last December when I wrote the post titled New Job about this incredibly awesome opportunity I was really excited about? Here I am less than a year later saying goodbye already. My last day with Microsoft is September 9th.

I truly believe an ADM and the PSfD organization as a whole to be a valuable investment for companies with development staff, but it's just not for me personally. Though it is a highly technical position and I did some code-centric work, I would say it is dominantly managerial and it contains a great deal of support responsibility. I've always claimed that I could never be a manager and I don't think I'm cut out for providing support. Maybe it's my near zero empathy score - don't know. Maybe I've found my level of incompetence! Most importantly though, I really miss just being a developer.

At first I thought about moving around inside the company. I thought I'd look for a development position that would allow me to work remotely since I'm anchored to the area (willingly). After all, Microsoft is an excellent company to work for. Great pay, great benefits, and it's full of extremely smart people who are also fun to be around (for you social types). In the end though, the wife and I decided this would be the perfect time for me to chase dreams. Dreams of working for myself and becoming a Micro ISV.

I'm not entirely sure at this point how I'm going to accomplish this, but I'm going to give it a go. In the beginning I'll be an independent contractor and take jobs as I find them to help financially. Mostly I'm going to be doing a lot of research and investigating a few ideas. Oh, and when I don't have a contract, I'm going to pick up my youngest daughter earlier and hopefully be home when my oldest gets off the bus. Might even make supper for the wife if she can stomach it.

Tags: