Wireless communication

Hello guys… I am new to your forum…

I have a question…

I have done a wireless communication between two arduinos with Virtual wire…!

I can send any char i want… now i want to measure temp and send the TEmp to the other arduino and see in on the Lcd…

The Virtualwire sends only Char?? i have to convert the Integer ( temp) in char in order to send it? or what??

Here is my code till now…

Transmitter code

#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
Serial.begin(4800); // Debugging only
Serial.println(“setup”);

// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
}

void loop()
{
const char *msg = “hello”;

digitalWrite(13, true); // Flash a light to show transmitting
vw_send(uint8_t *)msg;
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
delay(200);
}

Reciever Code

#include <VirtualWire.h>
#include <LiquidCrystal.h>

#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{

Serial.begin(4800);
Serial.println(“setup”);

vw_setup(2000);
vw_set_rx_pin(7);
vw_rx_start();
}

void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;

if (vw_get_message(buf, &buflen)) // Non-blocking

{
int i;

digitalWrite(9, true);

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13;
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH);
lcd.begin(16,2);

for (i = 0; i < buflen; i++)
{

lcd.setCursor(0,0);
lcd.print(“Temp:”);
lcd.setCursor(i,1);
lcd.print(buf*);*

_ Serial.print(buf*);_
_
Serial.print("");_
_
}_
_
Serial.println("");_
_
digitalWrite(9, false);*_

* }*

}
[/color]
Soz for my english and for my bad skill in programming :slight_smile: :slight_smile:

The Virtualwire sends only Char?? i have to convert the Integer ( temp) in char in order to send it? or what??

The VirtualWire class sends bytes, not chars. If temp is an integer, it is two bytes long.

    vw_send(uint8_t *)msg;

This won't even compile.

    vw_send((uint8_t *)temp, 2);

will send the two byte integer, temp, across.

PaulS:

The Virtualwire sends only Char?? i have to convert the Integer ( temp) in char in order to send it? or what??

The VirtualWire class sends bytes, not chars. If temp is an integer, it is two bytes long.

    vw_send(uint8_t *)msg;

This won't even compile.

    vw_send((uint8_t *)temp, 2);

will send the two byte integer, temp, across.

Yeap you are right.. i erased some comments and i erased and some code..

vw_send((uint8_t *)msg, strlen(msg)); here is what i had...

Ok i undestood i wish i do it.. :) :)

THank you!

what do you think is the simpliest code to use with the Ds18B20 temp sensor??

Thank you!