But OneWire.h library no working together . Or must I use RCSwitch.h library?
Thanks.
RX
#include <VirtualWire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
int i;
void setup(){
Serial.begin(9600);
vw_setup(2000);
vw_rx_start();
vw_set_rx_pin(11);
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if( vw_get_message(buf, &buflen) )
for (i = 0; i < buflen; i++)
Serial.write(buf[i]);
}
TX
#include <VirtualWire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
char msg[6];
void setup() {
sensors.begin();
vw_setup(2000);
vw_set_tx_pin(3);
}
void loop() {
sensors.requestTemperatures();
float temperature = sensors.getTempCByIndex(0);
dtostrf(temperature, 6, 2, msg);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
delay(200);
}