RFlink is an amazing tool. It allows you to import data from RF devices into your home automation ecosystem. I purchased two different units from a seller on eBay (now retired), both targeting the 433 MHz range. RF Link also supports 315, 868, and 915 MHz, as well as 2.4 GHz with the required receivers. Further, RFLink is supported by a number of platforms, such as Domoticz, Jeedom, Pimatic, Domotiga, OpenHAB, and HoMIDoM.
If your home automation system isn’t on the list, don’t let that stop you – you can write your own app to read the data directly from your computer’s serial port! Project Viduus is where I’ll introduce RFLink into my smart home app. I have a number of devices that transmit wireless data on 432 MHz and would love to make use of it for automation and informational purposes and it isn’t hard at all.
Now for my standard disclaimer – I’m not an expert developer. I have very little experience in writing desktop apps, having spent most of my career in QA and working on web code. My purpose is not to show you best practices or how to perform a given function with the fewest lines possible. I just want to show you simple ways of accomplishing your goals!
Before starting, I plugged in my RFLink gateway and tested it using Domoticz. After verifying it works, I noted the COM port it used and positioned my antenna as high in the room as possible to enhance reception.
For this specific app, I created a new Windows Form application and added a Textbox and a Timer. The timer defaults to 100 ms, which is fine for this app – the more sensors you have, the faster you want to check the serial port. Also – while you see a set of panels containing text boxes on the right side of the form, I deliberately disabled them for this entry – they’re for part II! The code itself is very straightforward.
Imports System.IO.Ports (for working with the serial port), declared ReceivedData as String.
In the “Load” sub, I make sure the timer is turned off and then initialize the com port. Please note, because of the unpredictability of RF devices, I padded the ReadTimeout setting considerably.
The sub for the Start button opens the port and enables the timer. Note the Try/Catch – if you have another app accessing the port, it’s going to throw an exception. The sub for the Stop button closes the port and disables the timer. The Clear bhutton clears the text from the data log text box. The timer sub calls the ReceiveSerialData function and appeands the returned string to the data log text box. The ReceiveSerialData function just reads the data from the port and returns it.
This is really simple stuff. Part 2 will be more challenging, as we will need to split the string into an array, format the data where needed, and evaluate it for further actions. This will actually be my first time doing this sort of code in VB, so it will be a learning experience for me, too!
SmarterHome.club is the website for our Facebook community, The Smarter Home Club – which is an umbrella for all kinds of smart home technologies – home automation, security, custom electronics, weather stations, alternative energy, you name it. DIY focused.
If you’re interested in joining the Smarter Home Club’s Facebook group, please follow this link: