Now that we have FHEM running (click here) it would be nice if we can actually control stuff. For communicating with actors and sensors we need some hardware. There are a lot of home automation protocols to choose from, I myself am among other things interested in the MAX!/EQ-3 hardware to control my heating. The CUL hardware from busware.de is able to do this for me. Their hardware, although pretty good, is actually quite expensive. Since I’m Dutch (we are cheap) I found out you can make a CUL yourself. All we need is 2 cheap items and some time and effort.
A CUL is a piece of hardware based on an ATMEL chip/cpu with a Texas instruments communication chip. ATMEL chips can be found almost anywhere, and is also the core of the excellent Arduino platform. In short, Arduino is an open-source prototyping platform based on easy-to-use hardware and software. For more information visit www.arduino.cc.
What we need
For sake of size we choose an Arduino Nano (clone), I read somewhere on the web that it should also be possible with an Arduino micro, maybe I’ll write a post on that later. Thanks to the Chinese you can buy a Arduino Nano clone for under 2 euro/dollar including worldwide shipping at the moment. My favorite site for these bargains is Aliexpress, you can also check Ebay.
It’s best to buy an Arduino Nano with a FT232 chip USB controller. These Arduino’s will function better if you’d like to use them on Linux/Raspberri Pi/or others someday.
I myself however use a Nano DCCduino, which I bought a couple of years ago, with a CH340 chip USB controller. Just thought I’d test with these while I’m waiting for my newly ordered Nano’s WITH FT232 controller.
A RF1101SE module with antenna
The original CUL uses a Texas Instuments chip called CC1101 for communicating. Our friends in Asia also make affordable modules with this chip on it.
For 2 dollar you can order a RF1101SE module for use with 433 or 868 Mhz. The difference between the displayed modules is the size of the antenna. The longer one is used for 433Mhz and the short for 868Mhz.
The shopping list
- Arduino Nano (clone) preferably with a FT232 USB chip.
- A RF1101SE board with a correct antenna for your needs.
- Some dupont female to female wire breadboard cables, or some other way to connect the Arduino with the RF1101SE module.
- A mini USB cable
Best is to place 10 different colored dupont wires on the RF1101 board. Next connect the RF1101 pins with the corresponding number on the Arduino Nano board as follows:
Pin 1 <-> a 3.3volt pin
Pin 2 <-> not connected
Pin 3 <-> Pin D11
Pin 4 <-> Pin D13
Pin 5 <-> Pin D12
Pin 6 <-> Pin D2
Pin 7 <-> Pin D10
Pin 8 <-> Pin D3
Pin 9 <-> a GND pin
Pin 10 <-> not connected
For the Arduino and C1101 module to act like a CUL, we need to flash the CUL firmware on it, and if needed change the firmware a bit first.
- Download the nanoCUL firware from SourceForge. Click Browse Code and the Download Snapshot.
- Download WinAVR, a suite of executable, open source software development tools for the Atmel AVR series, here.
Compiling the firmware
Extract the culfw archive to a folder of your liking (I used C:\culfw)
Install WinAVR using all options in a folder of your liking by running the installer.
Open a command prompt to check if you can run “make” and “avrdude” of both commands give a response we’re good to go.
If you are using a 868Mhz RF1101 module (the one with the smaller antenna) then we have to change one line of code in the firmware. Open the file c:\CULFW\culfw\Devices\nanoCUL\board.h and change:
#define HAS_CC1100_433 into /* #define HAS_CC1100_433 */
If you’ve changed the board.h file (or not if you’re using a 433 Mhz RF1101 module) it’s time to compile the firmware. Open a command prompt and go to the nanoCUL source folder c:\CULFW\culfw\Devices\nanoCUL\. Run the command “make” and the firmware will be compiled into a .hex file.
If you get an error that is something like “child 17668(0x178) died before initialization with status code 0xC0000142” download this file and unpack it to c:\WinAVR\utils\bin\ and overwrite the msys-1.0.dll file.
Flashing the firmware
Check if the nanoCUL.hex file has the current date and time, this way we can be sure it’s the one we just compiled.
Connect the Arduino to your PC via USB. If you’re using Windows 10, driver installation will probably be no problem.
Open your computers Device Manager and look for a USB2Serial device, most likely under Ports (COM & LPT). Remember the COM port it is on (in my case COM4).
Open a command prompt and go to the nanoCUL source folder c:\CULFW\culfw\Devices\nanoCUL\. Run the following command to flash the firmware.
avrdude.exe -C C:\WinAVR\bin\avrdude.conf -v -v -p atmega328p -c arduino –P COM4 -b 57600 -D -Uflash:w:nanocul.hex:i
When done (without errors) your Arduino and C1101 module will be an official nanoCUL 🙂
Testing the nanoCUL
Now that we have finished the nanoCUL it would be nice to test if it is working. When you don’t have a functioning FHEM installation yet, this can simply be done with a terminal program. I personally use the amazing Putty.
- Start Putty
- Select Connection type Serial
- Serial line is the COM port used by your nanoCUL (Mine is COM4)
- Set speed to 38400 (THIS IS VERY IMPORTANT, OTHER SPEEDS PROBABLY DON’T WORK)
- Click Open
- Type V en press enter
The output will show the version of our nanoCUL.
You now have a working nanoCUL.