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 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. 🙂
- 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
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/
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. 🙂
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
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):
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:
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:
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.
This step is easy. The command is:
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.
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:
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:
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.
stands for the interface to nanoCul. Here you have to go now
Make sure you use the ID found in the previous step.
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. 🙂