A smart home system is only really fun when it can communicate with other components.
Since many systems use radio links for communication, it is only logical to make FHEM radio-enabled as soon as possible.
Most sensors and actuators in the smart home area use W-Lan and Bluetooth as well as frequencies in the 433 or 866 MHz range.
The last two are also gladly used by various radio weather stations, shutter controls, engine controls, etc ..
To make FHEM radio-enabled, there are two ways:
1. You buy yourself a finished USB to wireless adapter which is indeed ready but also expensive.
2. You build yourself a USB-to-wireless adapter and save a lot of money.
Do it yourself is not a problem in this case, because there is again a magnificent open-source project:
The nanoCul.
The nanoCul is a USB-to-wireless adapter that can be soldered and programmed from simple standard components. How the assembly works I have described in this article.
Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section.
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂
Inhalte
- 1 Safety instructions
- 2 Affiliate links / advertising links
- 3 Requirements
- 4 Construction of the nanoCul
- 5 Connect nanoCul to the RaspberryPi
- 6 Install AVR C-Cross Compiler
- 7 Download nanoCul firmware
- 8 Unpack the firmware
- 9 Change to the folder with the firmware
- 10 Set board.h correctly
- 11 Assemble firmware
- 12 Program firmware
- 13 Find out the ID of the nanoCul
- 14 Register nanoCul in FHEM
- 15 Have fun with the project
Safety instructions
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
Affiliate links / advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Requirements
Helpful Articles:
Before you can start installing the nanoCuls, you should have prepared the RaspberryPi so that it can be reached via Putty and FHEM is installed on it.
The following three articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPI – The First Configuration!
RaspberryPi – Control the RaspberryPi via SSH
Required material:
-none-
Required material:
In the following list you will find all the parts you need to implement this article.
Construction of the nanoCul
The nanoCul essentially consists of four important components:
1. The CC1101 radio module: This is available for both 433Mhz and 866Mhz
2. A level converter: Since the CC1101 radio module (3.3V) and the Arduino Nano (5V) work with different logic levels, they have to be adapted respectively.
3. An Arduino Nano: A microcontroller that is relatively easy to program and operate via the USB interface.
4. The board on which everything is soldered together.
5. Optional: A housing so that the whole thing is protected.
Connect nanoCul to the RaspberryPi



Install AVR C-Cross Compiler
In order to adapt the firmware (some kind of the operating system of the nanoCul) to our needs, we have to compile it ourselves. For this we first have to install the AVR C-Cross Compiler.
After you have logged in via Putty on the RasPi this is done with the following command.
sudo apt-get install make gcc-avr avrdude avr-libc
During installation, you may be asked if you agree that the installation will consume additional space. You confirm this demand with a “j”(or “y”) and enter. The installation will then continue.
Download nanoCul firmware
To download now the current firmware for the nanoCul you must first raussuchen the current link. Go to: https://sourceforge.net/p/culfw/code/HEAD/tarball


For example, the full command would look like this for the current version (556):
wget https://sourceforge.net/projects/culfw/
The RasPi then downloads the file and displays the progress in a small animation.
Unpack the firmware
The downloaded firmware is now hidden in a zip archive. To continue working with it we first have to unpack it.
This works (with the current version) with the command:
unzip culfw-code-566-trunk.zip
If the version (in the example the 566) have changed meanwhile you have to adjust the part behind the “unzip” according to your version.
Change to the folder with the firmware
Now you have to switch to the folder just created by unzipping.
The command is:
cd culfw-code-566-trunk/culfw/Devices/nanoCUL
Here again is the part with the “566” to see if the version may have changed.
Set board.h correctly
Before we compile the firmware, we need the parameters
set correctly. This happens in the file “board.h”. This is
in the folder you just switched to.
With the command
sudo nano board.h
you get into the text editor “nano” and can use it to edit the file “board.h”.
Do not be scared: The console view disappears and it all looks a little different.
Here you can set various parameters. For example, the clock frequency of the microcontroller or the radio frequency of the radio module.
If you want to use a radio module with 433Mhz and your microcontroller or the Arduino board corresponds to an Arduino you need not change anything here.
However, if you use a radio module with 866Mhz, you need to change the following part.
Use the arrow keys on your keyboard to navigate to the location “#define HAS_CC1100_433” and write “//” before that.
This comments out this part and tells the compiler that he has the
Firmware should assemble so that they are not for a 433Mhz but
for an 866Mhz wireless adapter.
To save your changes in the board.h file, press CTRL + X, then
“j” (because you want to save the changed file) and then on
Enter. Nano closes then and you are back in the console.
Assemble firmware
This step is easy. The command is:
make
This command causes the firmware you just configured to compile now. This means that the human-readable code is translated into the machine language and can then be programmed into the microcontroller of the nanoCul in the next step.
Program firmware
After the firmware has been compiled, it is now time to program them into the microcontroller of the nanoCul.
You will need to enter the following command:
make program
The microcontroller is programmed and the programmed code is then checked again.
Find out the ID of the nanoCul
To register nanoCul in FHEM, we first need to get his unique ID.
This is important because otherwise conflicts could occur if, for example, two nanoCuls are connected to a RaspberryPi. (for example because you want to run one for 433Mhz and one for 866Mhz).
In order to get the correct ID, there should be nothing connected to the RaspberryPi besides the nanoCul.
The ID of nanoCul is then read with the following command:
ls /dev/serial/by-id
An ID is then output. In my case, it is the “usb-1a86_USB2.0-serial-if00-port0”. Of course, this ID can be different for you. Now we have to remember this ID, because it is needed for the next step
Register nanoCul in FHEM
In order to register the nanoCul in FHEM you have to switch to the web interface of FHEM. There is an input field in the upper area where we can enter the definition of nanoCul.
This definition reads:
define nanoCUL CUL /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0@38400 1234
“NanoCul” stands for the name of your nanoCul in FHEM. You can also choose a different name here.
“CUL” describes the function of the defined device and must not be changed.
“/Dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0”
stands for the interface to nanoCul. Here you have to go now
Make sure you use the ID found in the previous step.
“@38400”
stands for the baud rate (~ speed) with the FHEM with the nanoCul
communicated. This value must be 38400.
“1234” is a code that is actually only needed when the nanoCUL FHT diagrams
should send. Then this must be adjusted accordingly. Either way, this must be specified with.




If everything works, remember to save your FHEM configuration by clicking on “Save Config” in the left bar.
You should now have a nanoCul connected to your RaspberryPi and registered in FHEM.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂
Hi,
sorry – I am not able to download the correct file.
I tried to create the board.h file on the raspberry by just copy the code from the website, but when I try to start the “make” process, the output is “nothing to be done for ‘board.h’.
So can you please update your nice how-to by the new link to the updated file?
Thank you very much!
Hi Frank,
could you please tell me which file you can not download? 🙂
The culfw firmware seems to be downloadable.
Best regards
Fabian
Hi Fabian,
if I click on your link (https://sourceforge.net/p/culfw/code/HEAD/tarball) the following error appears:
“Commit [r568]
We’re having trouble finding that snapshot. Would you like to resubmit?”
Unfortunately I cannot add a screenshot to this comment…
Thank you!
Hi Frank,
I tried this again and it looks that the link is working for me. Maybe you can try a different browser (for me it works in Google Chrome)? As soon as I open this link it starts the download of the fila located at: https://sourceforge.net/code-snapshots/svn/c/cu/culfw/code/culfw-code-r568-trunk.zip
This is the firmware file you are looking for. So in case it is still not working you can use this link. 🙂
Best regards
Fabian
Hi Fabian,
great, now it works 🙂
Thank you very much for your support!
Best Regards
Frank
Hi Frank,
glad to hear that it works now. 🙂
You’re welcome.
Best regards
Fabian
Hallo Fabian,
zunächst vielen Dank für diese grandiose Anleitung, mit der auch ich als völlig ahnungsloser Anfänger zurecht komme.
Leider laufe ich beim Befehl “make” auf einen Fehler:
ecki@raspberrypi:~/Downloads/culfw-code-r569-trunk/culfw/Devices/nanoCUL $ make
Compiling C: ../../clib/somfy_rts.c
../../clib/somfy_rts.c: In function ‘send_somfy_rts_frame’:
../../clib/somfy_rts.c:200:85: error: stray ‘#’ in program
my_delay_us(30415 + (((frame[6] >> 7) & 1) ? 0 : somfy_rts_interval_half)); # 129341
^
../../clib/somfy_rts.c:200:87: warning: statement with no effect [-Wunused-value]
my_delay_us(30415 + (((frame[6] >> 7) & 1) ? 0 : somfy_rts_interval_half)); # 129341
^
../../clib/somfy_rts.c:202:1: error: expected ‘;’ before ‘}’ token
}
^
make: *** [makefile:328: ../../clib/somfy_rts.o] Fehler 1
Hast Du mir vielleicht einen Tip?
Danke
Ecki
Hi Ecki,
das sieht mir nach einem Fehler in den Programmbestandteilen der Firmware aus. Die Datei somfy_rts.c hat in Zeile 202 wohl ein RProblem weshalb das Paket nicht gebaut werden kann. Damit müsstest du dich leider an die Entwickler der Firmware wenden. 🙂
Beste Grüße
Fabian
Hallo Fabian,
zunächst vielen Dank für diese grandiose Anleitung, mit der auch ich als völlig ahnungsloser Anfänger zurecht komme.
Leider laufe ich beim Befehl „make“ auf einen Fehler:
ecki@raspberrypi:~/Downloads/culfw-code-r569-trunk/culfw/Devices/nanoCUL $ make
Compiling C: ../../clib/somfy_rts.c
../../clib/somfy_rts.c: In function ‘send_somfy_rts_frame’:
../../clib/somfy_rts.c:200:85: error: stray ‘#’ in program
my_delay_us(30415 + (((frame[6] >> 7) & 1) ? 0 : somfy_rts_interval_half)); # 129341
^
../../clib/somfy_rts.c:200:87: warning: statement with no effect [-Wunused-value]
my_delay_us(30415 + (((frame[6] >> 7) & 1) ? 0 : somfy_rts_interval_half)); # 129341
^
../../clib/somfy_rts.c:202:1: error: expected ‘;’ before ‘}’ token
}
^
make: *** [makefile:328: ../../clib/somfy_rts.o] Fehler 1
Hast Du mir vielleicht einen Tip?
Danke
Ecki