I'm working on a project for my final year assignment and I have met a dead end with the RF 433MHz programming.
Basically I have an arduino Nano, fitted with a BMP180 pressure sensor and the transmitter, and another arduino, Mega, fitted with the receiver and SD Card logger.
everything works, I can get it to read the sensor and log it to the SD card, but im trying to get it to transmit the data from one to the other and Log, I have tried so many tutorials and tried to think of a way around it but I'm only a novice so it proves to be a bit difficult. i'd love to get this working to save me some hassle, I can post the codes I have written up for anyone to look at.
Any help would be appreciated!!!
bmp_transmitter_working.ino (843 Bytes)
I have met a dead end with the RF 433MHz programming
Please explain. The transmit code you attached appears to work with the library example VW receive sketch.
I can post the codes I have written up for anyone to look at.
Yes, you will have to do that to get any assistance. Please post your code within the code tags icon which is the scroll and <> on the upper tool bar. Post both the send and receive codes. Explain what problems you are having.
Reciever
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
vw_setup(2000);
vw_set_rx_pin(7);
vw_rx_start();
}
void loop()
{
uint8_t buflen = VW_MAX_MESSAGE_LEN;
uint8_t buf[buflen];
if (vw_get_message(buf, &buflen))
{
buf[buflen] = '\0';
Serial.println((char *)buf);
}
}
transmitter
#include <VirtualWire.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float H = 0;
int tempPin = 0;
float calTemp;
char tString[24];
char hString[24];
char msg[27];
void setup()
{
Serial.begin(9600);
vw_set_tx_pin(12);
vw_setup(2000);
dht.begin();
}
void loop()
{
H = dht.readHumidity();
analogReference(INTERNAL);
temp(analogRead(tempPin)); //Calculating temperature in celcius
analogReference(DEFAULT);
sendData();
delay(100);
}
void temp(int value) {
long temperature = 0;
//Reading the sensor 20 times and calculating the average reading
int aRead = 0;
for (int i = 0; i < 20; i++) {
aRead = aRead+value;
}
aRead = aRead / 20;
//Converting the temperature to celsius
temperature = ((100*1.1*aRead)/1024)*10;
// prints a value of 123 as 12.3
long hele = temperature / 10;
float deci = (temperature % 10)/10.0;
calTemp = hele + deci;
}
int sendData (){
//Converting temperature to a string
dtostrf(calTemp, 5, 1, tString);
//Converting humidity to a string
dtostrf(H, 5, 1,hString);
//Combining to one string
sprintf(msg, "%s, %s,", tString, hString);
Serial.print("message to send: [");
Serial.print(msg);
Serial.println("]");
//Sending the string
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();