Visual Studio + Resharper Intellisense

by March 21, 2012 07:57 AM

I've always turned off the auto-appearance of intellisense in Visual Studio. I feel that it's faster to just finish typing the word than it is to pause slightly and pick the right one from the intellisense dropdown that appears. Whenever I'm typing something really long or when I'm not entirely sure what the method or class name is, then I just hit Ctrl+Space to make the intellisense appear on-demand.

Visual Studio 2010 + Resharper 5.1

In ReSharper's options:

Completion Behavior

Parameter Info

And in Visual Studio's options:

Visual Studio Options

That should do the trick. Enjoy!

Tags: ,

Resistor Decoder

by March 13, 2012 10:37 AM

A friend shared a link to his post about an extremely cool video of Bret Victor's talk at CUSEC 2012 titled Inventing on Principle.

After watching the very inspiring video, I started snooping around Bret's site. Talk about a treasure trove of goodies! When I stumbled across the below, I had to share (as well as put it in a place I would always remember). I thought it was the coolest way to decode resistors I've seen to date.

resistors

Enjoy!

Tags:

ZigBee/XBee Garage Door Opener

by February 23, 2012 04:47 PM

I mentioned in my last post that I have three xbee radios that need to be used (played with!) and that we only have one garage door opener between the two of us - I am not the keeper of said opener. Here I present version one of our new networked garage door opener!

The Old Garage Door Switch

Garage Door Opener

The black box you see with the duck tape is a keyless entry system that was here when we bought the house. I'm the only one who used it (being the one without a remote) so I decided to unplug it and steal the wires that run from the garage door opener. The wires are already run and it's conveniently near a wall outlet so it seemed the right thing to do.

In case you don't know (I didn't at first), the wires that run from your garage door opener (the real one attached to the door) to your standard wall switch works by merely closing the circuit between the two wires temporarily. So your wall switch is just a mechanical switch with two electrical contacts that, when the button is pushed, close the circuit. Releasing the button re-opens the circuit, or breaks the connection between the two wires.

With the knowledge of just how simple it is to activate a garage door opener, all I needed was a way to electronically close the circuit between the two wires. That is exactly what a relay is for.

The XBee Garage Door Switch

2012-02-18_Opener_close-up

What this is, is the remote temperature sensor I had already created plus one additional component (and a few wires).

So the stuff at the bottom of the breadboard is still the power management componentry. It takes the 9 volts coming in from the power supply and regulates it down to exactly 3.3 volts for the xbee. Plus a couple of capacitors to smooth out the current.

Above that is the temperature sensor (tiny black thing) and a few resistors used to get the sensor's reading down to a level the xbee can read. And then there's the xbee itself with the temperature sensor still connected to AD0 (pin 20).

The new piece is the light blue component at the very top. That is a Compact 5VDC/1A SPST Reed Relay. I just connected the two wires from the garage door opener to each side of the relay and then ran a wire from AD1 (pin 19) on the xbee through the relay to ground. To trigger the relay, I just have to turn on AD1. So recalling what I said about the garage door switch, I just turn on the pin, closing the circuit with the relay, and then turn it right back off to re-open the circuit. Just like pushing a button switch :)

Tying Everything Together

2012-02-18_App

I left the temperature sensor on the circuit and I left the xbee configured exactly as-is. This means the console app that I used before still works like a champ. I connected the coordinator xbee to my PC, plugged in the above breadboard, ran the application, and I immediately started getting temperature readings from my garage. All I needed then was to be able to send a command to the remote xbee telling it turn on AD1 and then again to turn it back off.

Digi made this really easy with the xbee API. All I need to do is send it a remote AT command configuring AD1. Specifically, I send a Remote AT Command Request to the address of the remote xbee passing the AT command D1 (configure analog/digital pin 1) with the parameter of 5 to turn on high digital output (3.3 volts). I sleep for half a second and then send the same command again with a parameter of 0 turning the pin back off.

Of course, I needed a way to tell my console application to send those commands. For now I just listen for incoming connections on a named pipe. I created a single ASPX page sitting on my local IIS that, on button click, would open a connection to that named pipe and send it the message "Garage Door". The console app triggers the garage door every time it gets this message.  Sweet!

To get to that from my phone, I opened up HTTP traffic in my firewall to private network traffic and gave my PC a static IP address. So as soon as my phone connects to my wireless router, I can open and close the door with my phone. In fact, anyone who knows the password to my router and knows the IP address of my PC can now open and close the door. Unlimited remotes!!

Awesome, But Not Finished Yet

So now everyone who has access to my router can open and close the garage door. That's cool and all, but I'm not done yet. There are several things I don't like about the situation...

First, I want to be able to tell whether or not the door is currently open. No brainer! Not cool if the opening and closing is automated, but I still have to leave my lazy boy to see whether or not I need to close it at the end of the day.

Next, having a breadboard and exposed components dangling on the wall of my garage isn't cool. It's also not good for the circuit being exposed to dust and whatnot. Mostly it isn't cool though.

More importantly are the implementation details. Currently everything is had coded in a very brittle way. First I assume that any message received at the coordinator is going to be a temperature reading on AD0. Second is the garage door opener. Its address is hard coded to that exact xbee module. The pin is hard coded to AD1. And finally, I'm using named pipes to communicate with a console application from a .net application.

Oh, and I'm not logging the temperature readings, so no cool graphs. Not that there would be many readings coming in yet. Still have to solve the cost problem of creating dozens or remote sensors.

I'm definitely excited about what I have so far. And excited about the fact that I can open and close the door from my truck of course. But I have a lot of work (can I even call it that?) ahead of me.

Tags: , ,

ZigBee Simple Sensor Network Part 2 - Never Mind

by February 18, 2012 10:06 AM

In my last post I left off with saying that I planned to continue in the book with the second piece of the Simple Sensor Network project - switching the remote sensors to end devices and using batteries instead of the 9v plugs. I also thought I'd create my own PCB instead of using the breadboards. Didn't happen...

I really dig the idea of having one of these temperature sensors in literally every room in the house. Maybe one out front and one out back as well. I can picture having rich graphs showing me the temperature rise and fall from all around my house. Ideally all of the internal sensors would rise and fall in sync as the central air kicks on and off. If one of the rooms fell lower in the winter or rose higher in the summer in between heating/cooling cycles, that would tell me that particular room isn't insulated as well as the rest. Or it would tell me someone left a window cracked, or a varmint decided to make their own entry. All good information to have and at the very least I'd have those cool graphs to show off to oldsters who visit :)

The problem with the XBee-based sensor though, is the cost. The radio itself is roughly $20 and then there are the rest of the components. So we're talking close to 30 bucks per sensor. Not cool if I want to buy more than a dozen (every room - not just bedrooms, outside, attic, etc.). If I plan to implement this idea of a zigbee network of temperature sensors, I need to find a much cheaper solution for end devices.

So I'm done with the book Building Wireless Sensor Networks. Even though I don't think I'll continue using xbee radios everywhere, I am so glad I got the book. It has introduced me to all sorts of fun and coolness that I've never played with before. And I can see using those radios in spots (like the controller or more extravagant devices that use more of the module's functionality), so I'm sure it will be a great reference in the future. It's an excellent addition to my library.

What's Next

I am left with the three xbee radios I've already purchased. I was thinking about what I might do with them as I was leaving to take the kids to school the other morning. As I pulled out of the garage and lamented once again that I still haven't gotten a second remote for the door (the wife has our one remote in her car of course), the idea of creating my own formed. I've read of others doing it with arduinos and netduinos so there's plenty out there on the subject. My next post will show how I accomplished it with a couple of my left over xbee radios. Good times!

Tags: , ,

ZigBee Simple Sensor Network

by January 30, 2012 10:40 AM

This is the project I mentioned in Configuring My First XBee Radios where I'm going to setup the sensor network from chapter 5 in Building Wireless Sensor Networks. I'm going to end up with two remote temperature sensors that are mesh-networked together to stream their data to a base station radio connected to my PC.

Preparing the radios

Coordinator

This is a simple matter of connecting to the xbee with X-CTU and switching its mode from AT to API (along with ATAP = 2). I also went ahead and zeroed out ATDH and ATDL since the coordinator will be receiving data only.

Routers

These stay in AT mode, but need the following settings:

  • ATID - set to the same PAN ID as the coordinator
  • ATDH - 0 (forces the radio to use 16-bit addressing)
  • ATDL - 0 (destination is the coordinator for both routers)
  • ATJV - 1 (rejoin network on restart)
  • ATD0 - 2 (puts pin 0 in analog mode)
  • ATIR - 3E8 (sample rate of 1,000 milliseconds - polls for the temperature once a second)

Something that might be worth noting here. When I first unplugged the coordinator and plugged in the first router, my computer's USB completely stopped working. Yep, I lost both my mouse and keyboard and no amount of unplugging and plugging them in helped. I tried every USB port on my computer. I eventually had to do a hard restart (and luckily only lost a little progress on this post - I save often). I did notice I had left X-CTU running when I did the switch. This time I closed X-CTU in between configuring the two routers and everything worked fine. Don't know for sure if that was the problem since I don't care to reproduce it, but wanted to put it out there just in case you run into the same thing.

Preparing the sensor boards

Sensor Board

This was an experience for me. It seems like I have a vague memory of having soldered before, but we might as well say I've never done it. I'm proud to say I finished with only one burn (right index finger). The solder jobs themselves look horrible.

Working with all the parts was interesting as well (transistors, resistors, etc.). Very neat and I'd say rather satisfying when the end product is a physical thing instead of software. Good times!

This is a picture of the first one I put together (the second looks identical). The little black thing poking up right below (in the picture) the XBee is the actual temperature sensor. The mess of stuff near the bottom is the voltage regulator (from 9-volt to 3.3-volt) and the capacitors (to get rid of noise in the power supply). Prototyping on those breadboards is super easy.

Capturing the sensor data

The book actually supplies a program ready to use that will allow you to visually see on your computer all the data being sent from your remote sensors. It's a Processing program that uses some Java libraries to communicate with the XBee radio over the COM port. I could have used that I suppose...

Sensor Network App

Being the developer that I am though, I wrote my own in .net. I put the code out on github in a project called XBee (real stretch for a project name, I know). You can see the library I wrote along with the project specific to this example at https://github.com/rtennys/XBee. The format of the messages sent from the XBee radios in API mode are very easy to work with. It was a fun little exercise for sure.

What's Next

I think I'm going to do two things next. I'm going to kind of stick with the book moving on to creating temperature sensors that are configured as end devices instead of routers. This allows them to be much more conservative on the energy they consume thus allowing me to use a battery power supply instead of having to plug them in. In addition to what the book shows though, I'm going to create my own PCB instead of using the breadboard.

Tags: , ,