Project Viduus Part II – Changing Direction on RFLink

In my last entry (HERE), I put together a quick little VB app to read 432 MHz RF data captured through an RFLink Gateway. I called it Viduus, after the minor deity from Roman mythology that divided the body from the soul. This time, I’m hoping to make sense of the name as I split the strings returned by RFLink.

The first step in working was to enable the panels with groups of text boxes for each of the sensors I expected to work with. Next, I removed the Try Catch statement from the Button State code – the command to open the serial port was never an issue and wrapping the call to the Timer in it was not best practice. I also removed all of the empty lines.

All of the Timer code is wrapped in a try catch. I declare my variables and then hit the RFLink Gateway for data. The first significant difference is that I declared an array of String to hold the values returned by the split function. I next apply the split function, the delimiter is a semicolon. Split automatically returns an array of string data after parsing the original string. here’s an example of the original data:

The first Node (20 in each of the examples above) is either 10 for the host to the RFLInk Gateway, while 20 means from the Gateway to the host. The second Node is a packet counter (hex values, representing decimal values from 0 to 255). The next node is the Device name. The fourth node is the device ID, with additional nodes for different sensors, providing data for temperature (hex), humidity (percent), windspeed (hex, converts to kph value), wind direction (integer, 0-15, representing 22.5 degree steps), rain amount (in hex, for rainfall in mm), and battery status (OK or Low).

I then loop through the array to get the goodies. There are three sensors I’m interested in capturing data from – my Xiron Pool Thermometer, an Ambient Weather Thermo-Hygrometer in our laundry room, and, my top priority, an Acurite 5-in-1 Weather Station sensor. SO! The first thing to remember is that this is a zero based array, so to get the third node, we ask for array element 2. I do a Select Case switch on aryTextFile(2) and define a case for each of the three sensors. The Xiron and Ambient Weather (displayed here as F007_TH” are easy and display the same fields – temp, humidity, and battery status. I also added a “last updated” field, which I populate using the Now() function.

The Acurite sensor is a little more interesting because it returns two different packets of data. One packet sends Temp, Humidity, Windspeed, and battery. The other packet sends Windspeed, Wind direction, Rain amount, and battery. I suspect that when it rains, it also sends a rain rate, though I haven’t verified this when it was actually raining yet. So, unlike the other two sensors, the Acurite sensor fills the text boxes from two different packets, meaning a couple of text boxes will not populate each time. I set the value of “checkString” to the 4th element of the array and then use Strings.Left to evaluate the first character (Wind or Temp, so W or T). An interesting note – using the Left function returns an error. I didn’t care to spend a lot of time debugging, there’s more than one way to skin a cat.

Speaking of debugging – you can see multiple lines commented out, where I displayed messages in txtLog. I would have stopped using these anyway, but it turns out that my understanding of arrays in VB is flawed. I expected the update to textLog to occur once with each iteration of the For Loop. Instead, it appended text for each element in the array that I add to one of the other text boxes – meaning 4 times for the Xiron or Ambient sensors or 5 times for an Acurite packet. I thought it was strange that it didn’t do so when I used the Now() function and it didn’t do this for elements in the array that I skipped.

Also, I’ve got an Else statement that catches any unknown Acurite sensor packets, as well as a Case Else that catches anything that I don’t have a case for. Finally, I also commented out the lines to append any errant data that might magically get past the case statement and also that dumps any exception data, neither of which provided any useful information in practice. Not a very complicated bit of code, for sure. Here’s how it looks with the debug code active:

I usually throw out a disclaimer that I’m not an expert developer and that is important with this particular bit of code. As I said, I didn’t expect the results I got while iterating through the array elements. It doesn’t matter here, since I am just displaying text. However, a significant goal for the project is to store the sensor data in a SQL database and I don’t want to repeat rows 4 or 5 times.

In order to help clarify things, I’ve reached out to a couple of experienced VB programmers, but those guys are generally swamped at their day job and don’t want to deal with the same crap at home. While I’ve waited for some guidance, I came to the conclusion that VB is great for my X10 data, I don’t need to use it for RFLink. There are no VB examples in the wild but there are tons of Python, so I am going to stop this series here for now. I’ll write a final version of the X10 reader, which saves data to SQL and can send it to my home automation system via MQTT. I then will shift to Python to not only implement the behavior I want and expect for RFLink, but also to take the time to learn a new language that I’ve never touched before!

Thanks for coming along with me on the path so far. 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:

The Smarter Home Club on Facebook

One Reply to “Project Viduus Part II – Changing Direction on RFLink”

Comments are closed.