About Matthijs Hoekstra

Posts by Matthijs Hoekstra:

Pibow Coupe enclosure for my Raspberry Pi 2

When I ordered my Raspberry Pi 2 I also ordered a little enclosure called the Pibow Coupe. Since the layout of the Pi 2 is the same I assumed every case would fit. Unfortunately that was not the case for this specific enclosure. But with a little help of my Dremel I managed to adjust it a little bit and it now fits perfectly.

When you build the case around your Pi board they little layers are numbered. Number 1 and 2 are at the bottom, than you put your Pi on top of it, than layer 3. This layer needed some adjustments. I removed a little part of the plastic at 3 areas. After that it fitted perfectly.

WP_20150218_005 adjusted

I am happy with the end result


I like this case because it exposes all the GPIO ports so it’s easy to fool around and play with the device when adding sensors and other circuits.

Raspberry Pi 2 arrived

Last month Microsoft announced support for Windows 10 for Raspberry Pi 2. That was a perfect excuse to order one myself as well (I ordered mine at MCM Electronics).

Although it was in backorder it took less than a week to arrive. I also ordered a good power supply and a nice little case. Of course you need a memory card. 8Gb micro SD card should be enough for most situations.


Installing the Raspberry is easy. Download the Noob zip file. Unzip it to the already formatted micros SD, put it in the Raspberry, connect your screen with HDMI, mouse and keyboard through USB and a network cable in the network connector. Plug in the power and you are good to go.

First question is what you want to install. The Noobs install comes with a few choices. Pick the first one.


Wait a little bit.


And you will see a lot of linux stuff appearing on the screen.WP_20150217_005

Final choices. I just clicked Finish.WP_20150217_006

Et voila, a $35 computer is waiting for instructions.WP_20150217_007

Of course I want to put Windows 10 on this device. Yes I do have access to internal bits but I cannot blog about that stuff just yet.

SmartThings: Switch dimmer to 100% and return to original value when contact closes.

This was bothering me for some time. In the hallway we have a wardrobe closet but that part of the hallway is kind of dark. I was already planning to change the dimmers (2 way) for z-wave ones, but I want to have something smart here as well. Whenever I open the closet I want to lights to go to 100% but when I close the closet they should return to the original value (either it off, or dimmed etc).

That happens to be really easy, I found this thread in the SmartThings forum http://community.smartthings.com/t/smart-light-timer-dimmer-modification-is-this-possible/11133/6

You need a little smart app. When a contact opens it turns the dimmers to 100%, remembers the original value first and subscribes to the close event of the contact, when the contact closes again the original value is restored.

Sounds what I need is possible, so ordered the contact sensor from Amazon (click click Smile)

My SmartThings setup for my home (the logic)

In the recent blog posts I described how I setup the different sensors and connected my Nest thermostat. But the real automation or getting things convenient is by tying everything together. I have been struggling to get everything to work. One time 1 part was working but it didn’t go to another state automatically and suddenly the lights went out when I didn’t want it to happen etc.

What helped me was drawing the following diagram and after that go through the app to define/configure all the different states (in the end, SmartThings is nothing else than a state machine)


The states, Home, Night and Away are already defined in ST. If you go to the activities (those are in bold at the lines) you can configure them 1 by 1. For example you go to ‘I’m Back’. I have configured to turn on some lights and change the mode to ‘home’. At additional settings you can configure ‘automatically perform ‘I’m Back!’ when.. I have configured ‘Someone arrives’ (connected to Sandra’s and my presence sensor) and ‘Things start happening’ which is the motion sensor, so when I come home through the front door or garage and the presence sensor isn’t detected yet the lights turn on anyway.

The 1 thing left to do is connect all this to sunset/sunrise. If I return home during the day I don’t want the lights to turn on. So I want to add another state which is ‘Home sunrise’ or something like that which is a different state than home. That state doesn’t need the lights to come on. Creating a chart with that state added and the different transitions will help me configure the SmartThings hub the way I want.

Get the device name of your Windows Phone

I am updating my rubber duck app and I want to store the amount of ‘squeeck’s per device in roaming settings. So you can see the total but also how much you squeezed the duck on every device.

I am storing this as key value pair and the key is the device name.

So how do you get the device name? You can’t. There is (as far as I know) no API to get the device name.

So when searching around I found this trick which I am documenting for myself here in this post.

Windows.Networking.Proximity.PeerFinder.DisplayName will give you the name a user gave his device.

Not sure how robust it is yet. It seemed to work on my phone, but when I check the name in internet sharing in my emulators they say something like ‘Microsoft Virtual_6262’ but the API returns ‘Windows Phone’ so apparently these 2 aren’t the same. That’s ok since you can change the broadcast name for internet sharing in the UI and renaming your phone needs to be done when it’s connected to your PC.

Hmm, no neutral wire for my z-wave on/off switch, now what?

I tried to add another z-wave switch to my SmartThings network. I bought a on/off switch at Lowes (all the ‘works with Iris’ stuff you can use in your z-wave network), this is just a GE 1-way on/off z-wave switch, to connect to my outdoor lights so I can switch them on/off automatically with sunset/sunrise.

When I connected it to the 2 black wires which were used to the existing switch the lights didn’t come on. Although the led on the switch itself lighted up.

After some searching and reading the manual a little better I found out I needed to connect the neutral wire. Fortunately there is a neutral wire in this wall mount. I checked my study and that doesn’t have one. The weird thing is the z-wave dimmer works without the neutral wire.

So after wiring up the neutral wire the outdoor lights started working.


So I found some information on the SmartThings forum to explain what was going on.

No neutrals is a bad thing, unfortunately. You can use once of the switch types that don’t need a neutral, but they do have limitations.

First question: If these are three-way switches, there should be at least three wires. In the first box there should be a hot line (from the breaker/fuse box) and two wires (called traveler wires) going to the next box. At the second box there should also be three wires. The two traveler wires from the first box, and then one load wire leading to the light.

If this is what you have then you can look at Levitron which appears to have both switches and aux switches that do NO require neutrals. See this page: In particular, look at the setup in part 4B. This is what your setup should look like.

Second question: Why only Incandescent bulbs? The important thing to remember is that old “dumb” switches are simple mechanical devices. By flipping the switch you are mechanically connecting or disconnecting a circuit. The switch is nothing more than a path for power to move through.

However, a z-wave “smart” switch is an electronic device in and of itself. Yes it opens and closes the electrical circuit for your lights, but it also has a small radio built in as well as various other electronic components that control dimming, current state, etc. Because this is an electrical device it requires power all the time. This is whymost switches of this type need a neutral. The power used to “run the switch” comes from the hot, then goes out the neutral.

But some switches obviously don’t require a neutral… how do they operate then? They operate by allowing a small trickle of energy to move through the circuit. Enough to operate the switch, but not enough to make an incandescent bulb light up. These switches take advantage of the fact that incandescent’s need a (relatively speaking) high level of power before responding with light.

CFLs, on the other hand, take less juice and this constant trickle is enough to occasionally make them flicker or blink. Having a constant small level of juice probably isn’t very helpful to the ballast and other parts of the CFL either, potentially shortening their life considerably.

Similarly LEDs require a lot less juice too. Meaning that small trickle might be enough to make them come on at a dim level even when the switch is “off.” Theoretically if you have enough of a load of LED lights you might be able to get by without this switch lighting up your LEDs. For example, in one room of my house I have 4 LED lights each taking like 16 or so watts. That just might be enough to prevent them from lighting up (I don’t know for sure as I’ve got a switch with a neutral… just same it might be enough).

Okay… so this explanation ended up going long. Sorry ’bout that. Also, I hopefully I didn’t sound like I was talking down to you. Not sure how much you know or don’t know so thought I’d start with the basics.

In other words. if you don’t have a neutral wire, on/off could work with specific switches and regular light bulbs.

Installing my 240V Electric Vehicle charger and extra 40A breaker

A couple of months ago I bought a Nissan LEAF. It comes with a trickle charger you can connect to your 110V outlet but it takes a bit of time to completely charge your car (over 12 hours). I leased the car with a fast charger pack which makes it possible to charge the car in a couple of hours if you have a 240V charger.


I decided I wanted to install this myself. I bought a Bosch EL-51253 Power Max 30 Amp charging station with 18’ cord. I also bought a NEMA 14-50R outlet I wanted to put in the wall. And I bought a Electric WX9X35 4-wire Range cord to connect to the charger so I could plug it in the wall.

Connecting the range cord to the charger is easy. Open it up on the back and connect 3 wires (you only need 3, the white wire isn’t used because only 3 wires go from the breaker to the NEMA outlet).


The 240v connection wasn’t that hard. Most of the time I used to figure out what the exact rules are here in the US. It’s a bit different compared to the Netherlands (Yes I read the NEN1010 in NL when I was in school). I did a lot of research online to figure out what is allowed or not. I requested a permit (this is different per area, even Redmond and Bothell are different, some areas you go to the power company, some you go to the city. For Bothell I needed to go to the city and pay around $60) and after everything was hooked up, somebody from the city came by and approved the installation. (You don’t want to fight with your insurance when your house burns down because you made a mistake Winking smile)

First I needed an extra breaker in the outlet panel. This house is a new build so the panel is new. I could just add an extra 40A breaker. Here in the US they use 110V outlets although 240V comes into the house. The breaker for your dryer is also 240V.

After I switched of the main breaker I added the new breaker. (btw, although the main breaker is switched off there is still current on the main thick feeder line at the top of your breaker box!). Just make sure you use a breaker which fits on the panels connectors.


Adding the breaker in the panel is easy, just click it in.


That was the easy part


I was lucky I wanted the outlet really close to the breaker panel. I bought some materials at Home Depot and started working. I used this wire which allows 55A and in the wall usage. First I needed to cut out the hole in the wall.


Opened up one of the holes in the panel to feed the wire


Make sure you put in this plastic ring before you feed the wire (you need this if you want to get the permit approved afterwards)


Strip the wire and feed it to your breaker and attach the ground to the ground block


Feed the wire to the outlet (only 2 wires and 1 ground)


Connect the NEMA connector, I connected the ground and the 2 L wires.


Et voila, done


I am happy with the result Smile


Update: Although my charger doesn’t use it, I would recommend adding the extra wire from the breaker to the NEMA plug and just connect it (neutral wire goes into the neutral bar). So for future use the NEMA connector is wired completely and would save some frustration of you use it in the future but forgot 1 wire was missing 🙂

Added 2 SmartSense presence sensors to my SmartThings network

There are still a couple of things I would like to automate in my house. For one when everybody leaves the home the home should switch to ‘away’ mode. The other one which would be nice is if I get home with the car the garage door opens automatically or closes when you leave the house.

First thing I tried was setting up the Windows Phone from me and Sandra to use as a presence sensor. You can do this through the SmartThings app. But after some experimenting this isn’t a reliable way to detect if you are at home or not. Not sure what the exact problem is but I don’t think this is a Windows Phone 8.1 app using geo-fences. One of my friends uses his iPhone and that is pretty accurate.

So I bought to SmartSense presence sensors on Amazon (they ship in days, when I order at the SmartThings website it takes much longer for the same price!?)


First experiment was putting these things in the glove compartment of the cars. I added the 2 devices to the network (just follow the instructions it’s easy)

When driving away from the house it takes around 5 minutes before it detects I left the house. (little over 1 mile away). That’s not good enough to close the garage door automatically since it will be open without me being there for some time. It looks like it polls only so many minutes (when I check the log). Not sure if that’s true or not.

Detecting when I am home is a bit spotty too. When I drive to my house it detects me or Sandra is home when we park the car in the garage. So it’s not good enough to open the garage door automatically. You can set an amount of minutes you are not present before an action triggers. This is a good setting because you sometimes get a false message about one of the sensors not being present.

I found out the sensor is usable for setting the house to ‘away’ automatically. I connected the sensors to our keys (which we bring with us all the time). So when Sandra leaves the house on her bike or walks Lisa to school it also works. It’s not bound to just the cars.

I programmed the ‘away’ mode in the app to automatically go to away when everybody leaves the house. I also changed the ‘I’m back!’ to automatically when ‘somebody arrives’, together with the motion sensor this works really well.

The scenario for the garage door might work together with your iPhone or Android phone. My friend had a problem with this the garage door also opened automatically when he returned from walking the dog. If you combine this with 2 sensors in both cars you could program the ST hub to automatically open the garage door when arriving (with your phone) and your car is not present. That would be accurate enough to make it really convenient. I hope ST updates the Windows Phone app some day to make this scenario workable. At that time I will buy a automatic garage door opener and sensor to detect if the door is open or closed.

Adding the Ecolink Z-Wave PIR Motion Detector, Pet Immune (PIRZWAVE2-ECO) to my SmartThings network

Last week I ordered this motion detector for my home. I want to use it to automatically switch some lights etc in my SmartThings network.


Connecting the motion detector to the network is easy. Just follow the instructions. I use this for 2 different scenarios. 1st scenario is when I go downstairs in the morning, the sensor detects me coming down the stairs and tells the house ‘Goodmorning!’, that turns the lights on, turns the Nest to 69, if it isn’t already and turns on the Sonos on my favorite radio channel. The 2nd scenario is when the house is in ‘away’ mode. I want the motion detector to tell the house ‘I’m back!’ this makes the lights turn on and put the Nest in ‘home or present’ mode. I will write another post how I programmed these 2 scenarios in SmartThings.

So does the motion detector work? Yes it does, there are some caveats to be honest. When it detects motion it stays in this mode for at least 4 minutes. When it doesn’t detect motion it ‘turns off’ for at least a minute before it detects motion again. I did not figure out how I could change these timings, I guess it’s done to save battery. For my scenarios that’s ok but if you would like to use it to automatically switch on and off the bathroom lights for example I wouldn’t use this sensor. The price is pretty good. $28 for this sensor isn’t that expensive I think.

The sensor comes with a wallplate and some double sided tape. I positioned it in a spot where it can detect us coming down the stairs, enter the frontdoor or enter the kitchen through the pantry. So these 3 areas and my 2 scenarios cover everything I currently want.

Setting the Nest to away and home in combination with SmartThings

I wanted to make it even easier for myself when I leave and enter the house. What we do now when we leave the house we set the Nest to away and when we return we set it to Home. That’s something we can automate with SmartThings.

I found this script on github: https://github.com/pstuart/smartthings/blob/master/set%20tstat%20to%20not%20away.groovy

So when I set my home to goodbye the Nest goes in ‘away’ mode and when ‘I am back’ the nest goes in to ‘home’ mode. That’s all.

I don’t need to connect the motion sensor since that’s already hooked up to the different modes in SmartThings, I only need the nest to respond to those mode changes. So I might change the script a little in the future to adjust it to just this scenario.

So go the web IDE  and create a new smartApp. Select From code and paste the code, save, and publish to me.

Go to your phone and use the app to add the custom app, hit the + swipe to My Apps and select the Thermostat Away mode app.