Arduino RF VirtualWire.h

I want to send temperature over RF communication.
Transmitter code:

#include <VirtualWire.h>
int temp;
char buf[3];
int i;
int flag=0;
void setup(){
  vw_set_tx_pin(2);
  vw_setup(2000);
  Serial.begin(9600);
}

void loop(){
 
  temp=Thermister(analogRead(0));
  for(i=2;i>=0;i--){
      buf[i]= temp % 10;
          temp /= 10;
        }
    vw_send((uint8_t *)buf, strlen(buf));
        
  }

int Thermister(int RawADC) {
	int Temp;
	Temp = log(((10240000/RawADC) - 10000));
	Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
	Temp = Temp - 273.15;            
	return Temp;
}

Receiver code:

#include <VirtualWire.h>
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
char buf1[3];
int i;

void setup() {
  attachInterrupt(0,receive_RF,CHANGE);
  Serial.begin(9600);
  vw_set_rx_pin(2);  
  vw_setup(2000);
  vw_rx_start(); 
}

void loop() {
 
    
  }
  
void receive_RF()
{

  if(vw_get_message(buf, &buflen)) 
  {
    for(i = 0; i < buflen; ++i)
    {
      Serial.print((char) buf[i]);
      
    }
   Serial.println("");
  }
 }

I want to view the temperature on the receiver.Any help?

Fix the names in the receive code.

char buf1[3];
vs
Serial.print((char) buf*);*

Not 100% sure but I don't think you can use attachInterrupt(0,receive_RF,CHANGE), you may just need to use the regular receiving code that comes with the virtualwire library. Start with the receiving example, then modify it to fit your needs.

You're thinking timers are disabled in the ISR, and virtualwire needs timer1 to function?
Or, you can't do an ISR inside of an ISR?

"The code consists of an ISR interrupt handler. Most of the work is done in the interrupt
handler for both transmit and receive, but some is done from the user level. Expensive
functions like CRC computations are always done in the user level.

Caution: VirtualWire takes over Arduino Timer1, and this will affect the PWM capabilities
of the digital pins 9 and 10."

You're thinking timers are disabled in the ISR, and virtualwire needs timer1 to function?

Yea, just wasn't sure if it would still work. (Brain fart)

I kwon CrossRoads, i test port 10 and 9 with this library and dont work like PWM output.

iam very close to resolve my problem.

I have to convert the interger thermister value to char array.
I try this;

void loop(){
  
  int temp=Thermisther(analogRead(0));
  for(i=2;i>=0;i--){
      buf[i]= temp % 10;
          temp /= 10;
        }
  vw_send((uint8_t *)buf, strlen(buf));
 
}

I know is something wrong but i dont know who to writte the code correct.

You need to use sprintf(). It will convert your data to a String.

Can you write an example?

if i do this:

 int temp1=Thermistor(analogRead(0));
  for(i=2;i>=0;i--){
      buf[i]= temp1 % 10;
          temp1 /= 10;
        }
  vw_send((uint8_t *)buf, strlen(buf));
 
}

Dont work.And this:

 int temp1=112;
  for(i=2;i>=0;i--){
      buf[i]= temp1 % 10;
          temp1 /= 10;
        }
  vw_send((uint8_t *)buf, strlen(buf));
 
}

Works if a put the integer=112.What is wrong?

Well what does thermistor return, an int or a float? You should make it a float then cast the return as an int.

Do a serial print of temp.

Can you write an example?

Here is a snippet.

void loop() 
{
 SendOut(55, 80, 30); // I made the numbers up
}

void SendOut(int X, int Y, int Z)
{
  if(!((Z >ZparPos || Z < ZparNeg) && X > XparPos))Z=10;
  if(!(Y > YparPos || Y < YparNeg)) Y=10;
  sprintf(Array, "%d,%d,%d,%d ",X,Y,Z,getButton(tx,ty)); //getButton() is a function that I'm calling to get the forth value

  vw_send((uint8_t*)Array, strlen(Array));
  vw_wait_tx();
}

Output on other side:
55,80,30,2repeat…

Thank you!