Go Down

Topic: Sending a number instead of a Byte using RF communication. (Read 872 times) previous topic - next topic


May 10, 2013, 06:09 pm Last Edit: May 10, 2013, 06:15 pm by mixania Reason: 1
Whats up Arduino forum? Recently I have managed to create a data transmitter out of an Attiny85 and a RF Link Transmiter - 4800bps (434MHz) from SparkFun. The receiver is an Arduino Uno and a RF Link Receiver - 4800bps (434MHz) connected to a computer for Serial Monitoring.  $)

Since there are very few libraries that support Attiny85, I had to create my own transmitter and receiver code. They are extremely minimalistic, but they work pretty well! Basically the transmitter code consists of a function called byteSend() . What it does is chop up a letter that is typed into it, into bits and send the bits through the transmitter one at a time. For now, I can only send one byte at a time, so in order to create a sentence I have to create many byteSend() functions.The Receiver does the opposite of the transmitter, it collects the the bits and packs them into a byte in order to send them over the Serial Monitor. :smiley-sweat:

Despite the fact that transmitting letters works with my code, I eventually want to transmit temperature readings from the analog pin on the Attiny85. For this I have to convert the analog reading which is an Int, into a byte, so I can send it via the Transmitter. I tried to send one digit ints through the link but I believe they consist of two bytes so that's probably the reason why It didn't work. Here is how I did it. :|

Code: [Select]
int d = 7;

Is there a way to convert the int into a byte that the function will be able to send? :smiley-roll:
Thanks guys. :smiley-surprise:

Here is the transmitter code:
Code: [Select]

// Data pin that connects to the transimter's DATA IN pin
int dataPin = 2;
void setup(){
   // Set up the Data pin as an Output
   pinMode(dataPin, OUTPUT);

void loop(){
   // Send some bytes continuesly

// Function that will simplify the process of sending a letter
void byteSend (byte inputByte){
    int i;
    // Loop that will make the reciever wake up and adjust its amplification
    for(i=0; i<20; i++){
      digitalWrite(dataPin, HIGH);
      digitalWrite(dataPin, LOW);
   // A 3ms delay in order to synch the transimtter and get ready for data transmition
   digitalWrite(dataPin, HIGH);
   digitalWrite(dataPin, LOW);
   // A loop that goes throught all the bits in a byte and transimts accordingly
   for(i=0; i<8; i++){
   if (bitRead(inputByte,i)==1) {
     digitalWrite(dataPin, HIGH);
   if (bitRead(inputByte,i)==0) {
     digitalWrite(dataPin, LOW);


Is there a way to convert the int into a byte that the function will be able to send?

highByte() and lowByte() will get the two bytes that make up the int.

But, why? Is it really hotter than 255 degrees where you are? Normally, the temperature, on some scale, will fit in a byte.
The art of getting good answers lies in asking good questions.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131