Building the sensor hub

The basic ideaBecause I’m working on 4 different things simultaneously, all 4 of them are not progressing as fast as they could. And this new sensor hub is not top priority, so sometimes it takes a while before I can spend some time on it. The last few days I came up with some basic idea; this is what I have in mind for my sensor hub.

The lower side of the enclosure will have all the connectors for power and other wires to the sensors and the upper side is where a small 5V power adapter with USB connector (of which I bought a couple recently, for only 5 euro/piece) and cable will provide the necessary ‘juice’ to the Arduino Fio.

The FTDI breakout on the left is just for uploading sketches (and for power, while it’s still here on my desk).

Inside the enclosure there’s a half-size (400 points) breadboard with double-sided tape that will hold the Fio and the required wiring. Cheap and simple; and since this setup will take care of 4 of my all-in-one sensors, I can live with the fact that it’s not battery powered. This certainly doesn’t mean I’ll never build battery powered sensors anymore…

First sensor finished and working

Power wiresToday I finished soldering a cable to my first new All-in-one sensor with motion, temperature and light. Phew, after soldering those 7 wires my eyes really needed a break, even though I used a magnifying glass. The very first thing I did was getting rid of the headers for the H/L jumper; I reduced the 2headers I needed to 1 mm and added a drop of solder in between; the unused header was cut away completely. This gave me some more free space  for the black wire which connects the GND pin of the PIR to pin 1 (GND) of the DS18B20. After that I connected DS18B20 pin 3 (Vdd) and one leg of the LDR to each other so that I only needed 1 wire for supplying both sensors with power by connecting those to the + pin of the PIR; this is the red wire.

Now all the sensors were connected with each other in a way that when I would apply power to the PIR pins, the rest of the sensors would be powered as well.

Connecting the cable

As you can see a CAT5 cable was used; I only needed a total of 5 wires for this sensor. First I needed a way to glue the cable to the top cover of the enclosure; I saw there was some space between the PIR PCB and the top cover, so I what I did was remove the outer isolation on one half of the cable but left the other half intact. I added a drop of hot glue to it and quickly pushed it between the PCB and top cover, which made the cable isolation work like some sort of pull relief. Soldering the 5 wires was the last thing I did; cause now it was time to check some things first – does it work??

I wrote a small sketch that would read all the sensors once a second and display the results (do I hear a drum roll? ;-) :

10765455 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=643
10766546 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=640
10767638 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=640
10768730 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=645
10769821 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=653
10770913 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=657
10772004 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=663
10773096 Motion:no,  Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=661
10774188 Motion:YES, Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=666
10775279 Motion:YES, Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=668
10776371 Motion:YES, Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=663
10777462 Motion:YES, Addr:28-98-C9-AF-2-0-0-A3 Temp=25.25 grC, LDR=660

It works! Maybe I’ll put some drops of hot glue here and there to make it all slightly firmer and than I can close this sensor.

The sketch is still very basic; it’s just some Serial.prints you see here, no wireless transmission is done yet and there’s an ugly delay(1000) in the loop() for the 1-Wire delay that I have to get rid of.

And I don’t need temperature and light sent to me every second; but waiting one second before motion is detected is way too long of course. Using interrupts for detecting motion is better I guess… soon I’ll know more about that, cause I need to be able to handle 4 PIRs (on 4 different input pins), but I can’t have 4 ISRs (Interrupt Service Routines); but the ‘solution’ will probably suffice. Sounds like a nice subject for another post.

Success and failure

Today I continued with my “RGB LEDs for the gazebo” job; what would those 6 LED spotlights bring, in terms of light? How would it look? Well, here some images:

 

 

 

 

 

 

 

 

 

 

 

 

I wanted to see the result before I would start digging holes, laying cables under the pavement etcetera. Based on what I saw after sunset, the conclusion can only be: we have a Go! It’s exactly what I had in mind; which is a big relief actually, cause those 6 LED spotlights were quite an investment. But the result is wonderful, these LED spotlights light up the gazebo just the way I want.

I did have a big issue with controlling those LEDs though.. All the tests I did in my office with the LEDs on the desk next to me never failed. But today, with the LEDs, DMX decoder, Arduino+Ethernet shield+DMX shield outside it didn’t work anymore!? Everything was set up and ready to go, but I couldn’t even ping my Arduino anymore!

My first thought was that the new CAT5 cable of 20m length was broken, or the RJ45 connectors didn’t make good contact; but this was not the case, the cable was OK. Maybe it was the new Gigabit switch I received 2 days ago which hadn’t been used until now? Nope. What is this??

I took the Arduino back to the office, connected it to my PC for power and to the switch. And it worked again, just like it always did… although I did see the LEDs on the Ethernet Shield behave differently. Well, I won’t go into all the details, but eventually I found out that it was the USB connection that made the difference! Without a USB connection, I had to push the reset button on the Ethernet shield to make the shield work. With USB, the Ethernet shield worked immediately. Go figure..

What has USB got to do with a (dis)functioning Ethernet shield?? A lot, so it seems. What is this, a hidden feature? By design? I must have missed the addendum to the manual that says “This shield will only function with your Arduino USB port connected”… After I knew what was causing this problem, it didn’t take long before I found a solution – phew, this issue could have been a real party pooper! I haven’t tried the workaround yet, but I will. Very soon, as in tomorrow first thing!

Here you see me testing some colors, sitting behind my laptop under the gazebo:

 

Arduino DMX encoder on the test bench

Today I started testing my DMX project. The ingredients:

  • Arduino Duemilanove with Ethernet shield and DMX shield;
  • DMX decoder PX24500;
  • 24V PSU;
  • 6 x Artecta RGB LED;
  • some wires;
  • a sketch running on the Arduino;
  • UTP cable;
  • software tools.

After connecting all the wires, switching on the PSU, starting the Arduino and checking if the Arduino was succesfully connected to my LAN by pinging it, I was ready. I opened the Arduino IDE Serial Monitor so I could see what my sketch was doing and sent a “command” to the Arduino. For that I used wget, a non-interactive network retriever; most people who know Unix-like OS-es will probably know about its existence but it’s less known among the Windows folks. Well, in just a few words it’s a tool with which you can store the results of a HTTP call into a file and do all kinds of other handy stuff .

I started carefully; the first command sent to the Arduino was:

 wget http://192.168.10.177/10,0,0,5,0,0

What this should do is change the R-value from its current value to 10 in 0.5 (5*0.1) seconds. G and B values are set to 0 immediately.

What the  Arduino webserver will receive is the following:

 GET /10,0,0,5,0,0 HTTP 1.1

 ....etc, the rest is all standard HTTP headers

After parsing the request and figuring out what to do, the Arduino starts changing the LED colour by issuing DmxSimple commands according to the values received in the HTTP call.

Ok, the moment of truth is here… will the LEDs start producing light or not? Yeah, they did! Tadaa…

This is not Red (nor is it a pipe)

The moment I saw this working, I felt the need for a more sophisticated way to control the RGB values, so I wrote a small tool in Delphi to help me pick the right color:

ColorWheelToEthernet

With a mouse click I can now select the color; the rest is done automatically: calculating the R-, G- and B-value and performing the HTTP call. And all it took was 10 lines of code (with the help of Indy and a very nice Color Lib made by Marco Binic). This allows me to choose a color much quicker and more precise than by editing numeric values on a command line ;-)

I did find some issues during my first DMX adventure, so I haven’t reached the phase yet where I can start digging holes in the ground; I’m not totally satisfied yet – more on those issues later, when I’ve hopefully fixed them.

 

Stacked stock

Stacked shieldsHere you see an Arduino Duemilanove, an Ethernet shield and a DMX shield. Well to be honest, the top shield is 1 day old; the rest has been on the shelf for more than a year. I wanted to start using some of the stuff I bought in the past but never used, so with the need for a DMX encoder to control 6 RGB LED spotlights, I decided to do it this way.

It was a bit annoying that I had to deal with how the Arduino platform works with shields and that you have to find out whether you can stack more than 1 of them on top of the Arduino and not have pin conflicts between the shields you want to use; this can happen so it’s always good to have a look at the pins all the shields use and see if there are any conflicts. In my opinion, the JeeNode concept is much smarter and easier in this perspective – and documentation is much better too!

Now back on topic again… as I said, this combination of boards is going to be used as an Ethernet enabled DMX encoder with integrated web server. Sounds difficult? It’s not, actually…

The DMX shield (from the Arduino store, made by Tinker.it) uses the DMXSimple library and indeed, it’s very simple. All the hard work is hidden and all you have to do is use 2 or 3 simple functions to get DMX encoding working.

The same goes for the Web server part; the Ethernet library makes it as simple as it possibly can.

So all I had to do was write some code to parse the values I wanted to send to this DMX encoder (R-, G- and B-values and some time values to soften color changes); and now I’m waiting for the LED spotlights to arrive, cause I’m ready for it! Yep, that’s the other side of the story; you can build cool stuff in a matter of minutes, add your own code for some extras and it works!

LED lighting for our gazebo

GazeboDespite all the Domotica stuff going on every day, I was able to find the time to build a gazebo in our garden this summer. I finished this gazebo in late June. Well, not quite; I still have to take care of the lighting. And somehow, everything I build or do in my spare time just has to have a Domotica touch :-) This time, it’s the lighting. I could have chosen the easy way and just put a big bright light bulb in the middle for when it gets too dark outside, but that’s too ugly, easy and no fun at all.

So I contacted Marco Versluis of Mood LedLight and he offered to come over and have a look at the gazebo and discuss some options for some nice and good lighting. Although I’m not the type of guy who decorates the entire home inside and outside with flashing lights at Christmas time, I do like to have nice lighting in the garden during the time that it’s dark and we’re still downstairs; an example of this is a previous garden lighting project.

This time we chose to do the lighting with 6 RGB LED spotlights.RGB LED spotlight

At each of the 6 poles of the gazebo there will be a RGB LED spotlight which will light the pole and the inside of the roof. That should be sufficient to give good lighting while sitting under the gazebo on warm nights as well as a nice view from the living room when we’re inside.

OK.. I admit it, I just couldn’t resist buying a DMX decoder for those 6 RGB LED spotlights – so I can produce 256 x 256 x 256 colors, who wouldn’t want that in his back yard? ;-) And of course, these LED spotlights need to be controlled from my Domotica system, otherwise it wouldn’t be much fun, right?

I’m not worried about accomplishing this. I found a Arduino DMX shield that should take care of the DMX encoding. And since it’s an Arduino shield and I have some unused Arduinos here, this will be plug & play, hardware-wise. Developing a sketch to control it all from my domotica system shouldn’t be that hard either.

No, the thing that I’m thinking about most of the time is: what color should these LED spotlights produce? Just pick a color I (ehh, we) like? Neh, too easy. And I certainly don’t like some predictable color scenario that repeats itself every x minutes. Yuck!

Come on, my Domotica system has almost 900 device values, why can’t I create some RGB values out of all that constantly changing data and produce a real geeky lighting? (ah, that reminds me: I need a motion sensor for the gazebo and/or a button to override the geek-lighting scheme with something that’s more moderate and acceptable for non-geeks … :-)

So basically, I’m looking for “something” that should produce a smooth changing, unpredictable RGB value based on device values originating from our house… There’s enough to choose from I guess… like using door/window open/closed status as bits for one of the 3 RGB bytes, or on/off statuses,  motion detection, total power usage for the R value, water usage for the B value…  well, I’m still thinking what to choose – suggestions are welcome!

 

Something old and something new

While I’m logging data and waiting for it to become substantial enough to test another project with, I thought it would be nice to kill the time and start building some new sensors: motion, temperature and light.

My goal is to monitor the complete second floor. For the 3 bedrooms I want to monitor motion, temperature and light. The passage will only require motion and light, while measuring the humidity in the bathroom would be nice too.

So, for that I need the following:

  • 5 * motion;
  • 4 * temperature;
  • 5 * light;
  • 1 * humidity.

I already have the motion sensors (PIR), the temperature sensors (1-Wire DS18B20), light sensors (LDR), enough JeeNodes, so all I need is a new humidity sensor.

OK; the amount of sensors I want to use is a bit too much for a single JeeNode I guess. Maybe 2 JeeNodes will suffice? I didn’t do any math on this yet, but I don’t think a single JeeNode can do the job all on its own. 2 JeeNodes maybe, cause the temperature sensors can be on a single 1-Wire bus, so those sensors won’t use up much ports on the JeeNode; and maybe I can use an Analog Plug to measure the LDRs? We’ll see. But for now, I assume I’ll need more than 1 JeeNode. However, I don’t like to spend an XBee module on each of those JeeNodes, cause I want to keep it relatively low cost. Yeah I know, there are cheaper alternatives for XBee..

But wait, I’ve still got an Arduino Fio; I’ve bought it sometime in January, not for a specific purpose but just to have a look at it, and I never found a good use for it yet. This Fio is also based on the ATmega328P and runs at 3.3V and 8 MHz. And it also has an XBee socket and USB connector. And it’s getting old, gathering dust on the shelf…

Now why don’t I use this Fio as a ‘hub’, or ‘central node’? It shouldn’t be too hard to make the (1,2,..) JeeNodes talk to this Arduino Fio over a few wires and use the Fio to transmit all the sensor values to the Zigbee coordinator; now that would be nice! I could power this Fio with a small USB power adapter and run a few wires (for power and serial connection) to the JeeNodes. Maybe I could just as easily use 1 JeeNode per room; this leaves enough ports available for future expansion… well, let’s think this one over for some time!

Arduino Workshop

Yesterday the Arduino Workshop that Lennart and I organized, took place in Velsen. Quite a day it was… Leaving home @ 06:45, picking up 2 hitchhikers and arriving at 09:40.

Arduino on a breadboardThe workshop started with a presentation by Lennart, followed by handing over the kits and handouts to the participants. And then it didn’t take long before the tables were crowded with soldering irons, laptops, breadboards, ATMega’s, jumper wires and so on. For some this was the first time they ever had a soldering iron in their hands, others brought their own soldering iron with them; the level of experience was very broad. But, by helping each other, most people managed to create a breadboard Arduino with a blinking LED, and went home with a soldered Bridge Board, Room Board and JeeNode :-)

During the day Jean Claude Wippler also demonstrated his reflow setup and I wanted to demonstrate the HomeSeer Integration of the JeeNodes. However, at the moment suprème, something went terribly wrong: my JeeNode, which had worked flawlessly the whole day and made Homeseer speaking “Motion” all the time, suddenly refused to work.. What a bummer! And nothing helped; rebooting the laptop, changing COM ports, nothing! Aargghh!!

Arduino Workshop

It was 20:30 when I came back home. Enough for today… well, that’s what I thought during the 1st hour… but I just couldn’t cope with the fact that my demonstration didn’t go as planned. I just had to see it working again! So I took the JeeLink and JeeNode with me to my hobby room, booted my PC, hooked them up and started HomeSeer. Guess what… it worked, as if it had never stopped! I don’t recall inviting Mr. Murphy to our workshop, but apparently he did pay us a visit in the afternoon…

The description of how to get the HomeSeer integration working is all in the handout, so I’m sure all the participants that want to get this working will have no problem doing that at home.

Despite the fact that I was not able to demonstrate the Homeseer part, I’m looking back on a successful day on which I hope the participants have learned a lot – enough to catch the Arduino fever! :-)

Preparing for the Arduino workshop

The Arduino workshop I mentioned before, is actually going to happen! :-) This will be a busy day, for both the organizing party as well as the attendees! A short list of the things we will be doing during that day:

  • Building an Arduino on a breadboard
  • Soldering a JeeNode
  • The Arduino IDE and testing the JeeNode
  • Experimenting with sensors and actors
  • Building a Room board
  • HomeSeer integration.

Enough to fill a complete day I’d say!

For the HomeSeer integration we’ll be using a slightly modified version of JeeNode for HomeSeer. This script based solution will help the attendees to integrate the hardware they created into HomeSeer in a very simple way. And since all the source code is provided, everyone can extend and/or modify it so that it will fit their personal needs the way they want.

Although I’m not a HomeSeer user, I do have a HomeSeer license that was paid for by a fundraiser that took place earlier this year. So I can play with HomeSeer whenever I like without any dirty tricks while I’m working on the Plugins I created or when I’m doing stuff like this.

I soldered a new JeeNode v4, a Room Board, uploaded the JeeNode sketch and connected it to the AA Power Board:

JeeNode with Room Board

JeeNode with Room Board

The JeeLink sketch was uploaded to the, eh, JeeLink, and I added an extra line to the HomeSeer startup script to get the JeeNode script running. After some initial configuration like setting the JeeLink COM port and some RF related settings, I was good to go:

HomeSeer Status

HomeSeer Status

OK, it’s all working; I can see the Room Board sensors in HomeSeer. Now it’s time to upgrade the JeeNode sketch to make it more power usage aware, cause I assume that will be important for those who attend this workshop. Back at home, they’ll probably start creating their own battery powered sensors, so a good starting point is essential. And that’s what I’m working on right now.

Adding Light and Temperature

Since i removed a bunch of MS13 sensors recently, i am missing some input on what is going on at several places in our home. So while i was making a list of things i need in the near future, i realized i should extend the motion sensors a bit more, or otherwise i would lose the dark/light sensor the MS13 provided. And why not add temperature as well; cause that would mean i could do without the Oregon sensors also. I mean, why use 2 sensor devices (one only for temperature and another one for motion and light) when you can combine it all into one? Let’s have a look at temperature…

I still have 10 DS1820 1-Wire sensors somewhere from the days when i started with Domotica, but i never used them; maybe now i finally found a purpose for them? Let’s connect a few to an Arduino and see if  i can get a temperature reading:

Arduino with 3 x DS1820

Arduino with 3 x DS1820

And of course, there’s a library to use 1-Wire devices with an Arduino.. so before i knew it, i was polling the temperature of 3 DS1820s :-)

Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC

Add an additional LDR and I’m done; ready to replace a large part of all my sensors: all remaining MS13s and most of my Oregon Scientific Temperature & Humidity sensors with my own :-)