FYP: Arduino data transfer over 433MHz RF

So Tuesday went... interestingly. Getting the transmitter transmitting data other than the binary ones and zeros went kinda well. It wasn't quite as hard as I expected, but still took a little while to get sorted.

The goal was to set up the transmitter sending a numerical ID and a value between 0 and 170. The 0-170 value was so that the receiver could forward this onto the servo, which would then the volume knob. This was generated by a potentiometer reading being mapped from 0-1023 to 0-170. Then this number was converted into a string, and prefixed with a number of '0's to ensure the string length was 3 characters. So essentially '139' would remain unchanged, '72' would be prefixed with a '0' to make the string '072', and '8' would be prefixed with two '0's to make '008'. This three character string would be then prefixed by the one character ID. Broadcasting something like 1139, 1072 or 1008.

Getting this transmitting was no problem. The VirtualWire library had a couple examples of this, so it worked pretty well. However receiving was an issue. The transmission was coming in fine, but as HEX. Now at this point I had no understanding of how ASCII worked, so I needed to figure out a way to convert the HEX into its glyph equivalent.

As an example: 1139 was coming in as 31 31 33 39.

The Instructable in the previous post had a bit of code that turned an LED on and off. This managed to read the inbound as the character, so I tried to print out the first character from the inbound, i.e. 1.


That printed, but it printed 49. This confused me to no end because of the aforementioned lack of understanding all this character-level stuff. So I found that Serial.write() printed the character I wanted. So I wrote a for loop that did a Serial.write() of the each character in the inbound. However I found trying to get the whole value in a nice manipulable variable was iffy at best as whenever I tried to do anything with it it would use the 49 value. Simon later explained to that the was a DEC, and I just had to subtract 48 from the numerical values I received. So understanding this I wrote a loop that converted the inbound into a string, character by character, subtracting 48 from each individual DEC. Then I finally had a value I could manipulate.

If the character was a 1 it would send the remaining 3 characters as an integer to the servo. So this didn't really work because apparently the Servo library and the VirtualWire library use the same timers on the Arduino, meaning the libraries cannot work together. I couldn't find any decent alternative libraries for the servo that let me use angles as input instead of pulses. I found that the Arduino MEGA had multiple timers, so I ended up modifying the Servo library to make both work on the MEGA.

In end end it all seemed to work fine, albeit a little jittery. The potentimeter successfully controlled the servo and thus volume over RF.


  1. Hi there, actually Im doing my project and using the Servo and Virtual wire libraries, and end up error like this.
    Servo\Servo.cpp.o: In function `__vector_17':
    C:\Program Files (x86)\Arduino\libraries\Servo/Servo.cpp:104: multiple definition of `__vector_17'
    Phils_VirtualWire\VirtualWire.cpp.o:C:\Program Files

    And this virtualwire written by phils is working great before I added the servo. May I have your modified servo library please?
    If can do you mind send me through p14004300@student.newinti.edu.my please.. Thanks in advance.. and sorry for any inconvenience.


Post a Comment

Popular posts from this blog

Logitech G502 Proteus Core Teardown & Scroll Wheel Replacement

Turning a laptop screen into an external monitor.

Letter basket: Productive procrastination