Wednesday, 19 November 2014

ArduinoHomeAutomationProject: The SensorNode; PART 2: PROTOTYPE THE HARDWARE


In "The SenorNode; PART 1" we made a brief plan of our node and should be able to proceed by prototyping our hardware.

Let´s have a look at how I did it:

You will need the following parts to setup the Prototype:
  • 1x Arduino nano or Arduino UNO
  • 1x breadboard + wires
  • 1x DHT22 + 4.7k pullup resistor
  • 1x LDR + 10k resistor
  • 2x LED + 2x 220Ohm resistor
  • 2x pushbutton
  • 1x I2C LCD (I´m using a I2C 16x2 LCD) + dupont wires (male - female)
You don´t need the Max485 chip + its 120Ohm resistor yet.

All you have to do is wiring everything to get a working prototype.
If you want to, you can try to make your own sketch for the prototype.
I will present and explain you my (already working) Arduino-sketch in PART 3.
Stay tuned!

Tuesday, 18 November 2014

ArduinoHomeAutomationProject: The SensorNode; PART 1: HARDWARE CONSIDERATIONS


Well, it´s time to get a little more concrete what the sensor node should do.
It should definitely measure the temperature, shouldn´t it?
In my case I also wanted to get some data about humidity and luminous intensity.
Further it should be possible to display the sensor readings and the time (if you want) to the user.

Now we defined what data we want to get from the environment, but we also want to interact with it.
My plan is to switch lights and electric radiators on and off.

The above mentioned things are enough to setup a prototype.


We are going to use Arduino for our project, so we will prefer those sensors where an Arduino compatible library exists. We also should be aware of the sensor tolerance and its accuracy.

  •  a Sensor with a temperature range from 0 - 50°C and an accuracy of +/- 0,5°C will not make much sense for a wheaterstation. 
  • a Sensor with a range from -40 - 90°C and an accuracy of +/- 2°C will not fit our needs.
I found those nice little DHT22 Sensors which have a temperature-range of -40 - 80°C with +/- 0,5°C and a humidity measuring range of 0 - 100% (accuracy +/-2%). You can get them for a few bucks on Aliexpress. We also need some 4.7k pull-up resistors for those sensors. There is a Arduinolibrary available on

For measuring the luminous intensity we can take a LDR and a 10k Resistor for  the voltage divider.
We don´t need a library for that, because the sensor-reading with Arduino will be pretty much like "analogRead(PIN)" + some calculation for the interpretation of the data.

Further we will implement some switches or buttons which we are going to connect with a 10k resistor to the Arduino. These switches can be used to manually switch lights on and off.

Now let´s have a look at how we present the data to the user. Take a display which is already tested with Arduino and be aware that it has enough space to display all the data.
With a 16x2 LCD you possibly run out of space and have to switch the display modes, but you can give it a shot, it is well tested and there are library’s around.
In my opinion a good choice would be an 0,96" I2C OLED. They are small, they are cheap, and you have a really good resolution to display the data.
You can get the library’s here:
Last but not least we should consider which type of transmission we will use. For easier code implementation I recommend something that supports the Serial UART bus of Arduino. 
I´m going to test the whole thing with MAX RS485 chips to build a long range RS485 bus-network (max. about 1000m via 2wire connection). If I can get some RF transceivers like "433Mhz Wireless Serial CC1101 Module" or "RF1100-232-TTL" I´m going to test them.

Monday, 17 November 2014

ArduinoHomeAutomationProject: The Concept - The cognition that something big is approaching


I started to make a concept for an Arduino based home automation a couple of month ago.
In fact the concept isn´t ready yet, there are really much things you have to mind but it´s a start.

You have to mind: What should the whole thing do? How should the user interact with it?
Trust me! KEEP IT AS SIMPLE AS POSSIBLE! It will be a hard nut to crack anyway.


First of all we have to be sure what the sensornodes should do.
  • measuring (temperature, humidity, light intensity, buttons, current...)
  • actuators (switch on lights, radiators, sprinklers, ...)
  • how should those "sensor - readings" be shown to the user (displays, web interface, GUI for mobile devices,...)
  • how should the user interact with the system
  • communication & protocol

Is it possible to do those things with a small microcontroller like Arduino?
The answer is: most of them. We can get the sensor data, switch things on and off, and Arduino has the possibility to use displays (LCD, OLED, ...).


When you think, "that’s more than half the battle" you’re definitely wrong!

It´s a start, a sensor-node, but we need lots of them! Let’s say at minimum a handful for a small flat.

How should they communicate to each other? Arduino has SPI, I2C and Serial UART (RS232) on-board. What am I able to do? How can I extend the range of electronic signals? Do they have enough bandwidth?

It´s on you what you’re going to pick, there is enough useful hardware on the market and you can get an ArduinoLib for most of them. I´m not a great fan of radio communication so I decided to give RS485 a shot. It´s long range (over 1000m) bus-network, which is stable, doesn´t need much electronics and communication should hopefully be as easy as, Serial.print().
In fact there are also radio-transceivers which will work with the UART of the ┬ÁC, but I wasn´t able to test them till yet.


If you’re planning an automation system or a sensor network, you probably want to save the sensor-readings into a database. I think you should, like me, give MySQL a shot. It´s free, it´s reliable, and there is a big community behind it. The planning of the database will be its own story to tell :-P


If you use Arduino plus an Ethernetshield you have the ability to write into a DB. It is possible, but that’s not the way I wanted to do it. I was really afraid of performance issues caused by DB queries.
So I decided to take another popular device, the Raspberry PI. The RasPI should do all the jobs I’m afraid Arduino has a lack of performance. The Raspi itself also has a huge community behind it, it’s a Linux based PC, doesn´t drain much current and it is possible to run a DB Server on it. So there is still one problem left... "How the h... can we get all the data from Arduino to the DB???".
Well, you can break your minds or follow my considerations.
We have:
  • PHP, it has the ability to read from the Serial with a library, I was not able to verify it´s reliability and I´m not a big PHP Coder.
  • PYTHON, I’m not familiar with python
  • JAVA
  • Processing, it´s a sister project to Arduino so the Environment plus the Syntax are familiar to me. (option chosen)

So all we have to do is writing a "bridge-program" which takes the data from the bus, process it and handle it to the DB.
Sounds like a plan, doesn´t it? 


For me that was really one of the hardest decisions in the whole project. I wanted to get the GUI into the WEB and the only chance I´ve seen to get everything together was PHP (that´s hard, I don´t really know PHP nor have I ever written a code in PHP). So I have to learn PHP, "OH MY GOD!".
The fact, that I´m not used to it will definitely slow down the work progress.


If you think that were the main questions and we are ready to go, follow me on my adventure, and let´s proof you´re wrong.


Auer Markus
Karwendelstr. 13
A - 6020 Innsbruck