A smart home system is only really fun when it can communicate with other components.
Since many systems use radio connections for communication, it is only logical to make FHEM radio-capable as soon as possible.
In addition to WLAN and Bluetooth, most sensors and actuators in the smart home sector use frequencies in the 433 or 866 MHz range.
The last two are also used by various radio weather stations, shutter controls, motor controls, etc..
There are two ways to make FHEM radio-capable:
1. you buy a ready-made USB to wireless adapter which is ready-built but also expensive.
2. build your own USB to wireless adapter and save a lot of money.
Do-it-yourself is no problem in this case, because there is again a splendid open-source project for this:
The nanoCul is a USB-to-radio adapter that can be soldered and programmed from simple standard components. How the assembly works I have described in this article.
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
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 make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Before you can start with the installation of the nanoCul you should prepare the RaspberryPi so that it is accessible via Putty and FHEM is installed on it.
The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPI - The First Configuration!
Your own smart home - installation and introduction to FHEM
RaspberryPi – Control the RaspberryPi via SSH
In the following list you will find all the parts you need to implement this article.
Structure of the nanoCul
The nanoCul essentially consists of four important components:
1. the CC1101 radio module: This is available for 433Mhz as well as for 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 adjusted respectively.
3. an Arduino Nano: a microcontroller that is relatively easy to program and operate via the USB interface.
4. the circuit board on which everything is soldered together.
5. optional: a housing so that the whole thing is also protected.
Connect nanoCul to the RaspberryPi
Install AVR C-Cross Compiler
To adapt the firmware(quasi the operating system of the nanoCul) to our needs, we have to compile it ourselves. First we have to install the AVR C-Cross Compiler.
After you have logged in via Putty logged in on the RasPi you can do this with the following command.
sudo apt-get install make gcc-avr avrdude avr-libc
During the installation you may be asked if you agree that the installation will use additional disk space. Confirm this request with a "j" and Enter. The installation will then continue.
nanoCul- Download Firmware
To download the latest firmware for the nanoCul you have to find the current link first. To do this go to: https://sourceforge.net/p/culfw/code/HEAD/tarball
For example, the full command would look like this for the current version(556):
The RasPi then downloads the file and shows the progress in a small animation.
The downloaded firmware is now still hidden in a zip archive. In order to continue working with it, we have to unzip it first.
This can be done (with the current version) with the command:
If the version (in the example 566) has changed in the meantime you have to adjust the part behind the "unzip" according to your version.
Change to the folder with the firmware
Now you have to change to the folder you just created by unpacking.
The command to do this is:
Set board.h correctly
Before we compile the firmware, we need to set the parameters to it
correctly. This is done in the file "board.h". This is located
in the folder you just changed to.
With the command
sudo nano board.h
you get to the text editor "nano" and can use it to edit the file
Don't be alarmed: The console view disappears and everything looks a little different.
Various parameters can now be set here. 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 don't need to change anything here.
If you use a radio module with 866Mhz you have to change the following part.
Navigate with the arrow keys of your keyboard to the place "#define HAS_CC1100_433" and write "//" in front of it.
This comments out this part and tells the compiler to use the
Firmware should be assembled in such a way that it is not suitable for a 433Mhz but a
is to be configured for an 866Mhz radio adapter.
To save your changes in the board.h file press CTRL+X, then press
“j” (weil ihr die geänderte Datei speichern wollt) und anschließend auf
Enter. Nano will close and you will be back in the console.
Assemble (have assembled) firmware
This step is easy. The command to do this is:
This command causes the firmware you just configured to be compiled now. This means that the code that is readable for us humans is translated into machine language and can then be programmed into the microcontroller of the nanoCul in the next step.
After the firmware has been compiled, it is now time to program it into the microcontroller of the nanoCul.
To do this, you need to enter the following command:
The microcontroller is programmed and the programmed code is checked again afterwards.
Find out the ID of the nanoCul
In order to register the nanoCul in FHEM, we first have to find out its unique ID.
This is important because otherwise there could be conflicts if for example two nanoCuls are connected to one RaspberryPi. (e.g. because you want to operate one for 433Mhz and one for 866Mhz).
To get the correct ID nothing should be connected to the RaspberryPi besides the nanoCul.
The ID of the nanoCul can be found out with the following command:
Thereupon an ID is output. In my case it is the "usb-1a86_USB2.0-Serial-if00-port0". Of course this ID can be different for you. We have to remember this ID now, because it is needed for the next step.
Register nanoCul in FHEM
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 the nanoCul.
This definition reads:
define nanoCUL CUL /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0@38400 1234
Here "nanoCul" stands for the name of your nanoCul in FHEM. So you can also choose another name here.
"CUL" describes the function of the defined device and must not be changed.
stands for the interface to the nanoCul. You must now click here
make sure that you use the ID determined in the previous step.
stands for the baud rate(~speed) with which FHEM is connected to the nanoCul
communicated. This value must correspond to 38400.
"1234" is a code that is actually only needed when the nanoCUL FHT diagrams
should send. Then this must be adapted accordingly. Either way, this must also be specified.
If everything works remember to save your FHEM configuration by clicking on "Save Config" in the left bar.
So you should now have a nanoCul connected to your RaspberryPi and logged into FHEM.
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂