i have also been working on this code for the transmiter what im tying to do is have the reviver send a code to the transmitter then it reads it then sends the value to the reciver then the reviver displays the value then sends out the next code and so on till it gets all 4 values then it delays then dose it all again.
So what i want is the reciver to send this
send this For Temp Val
wait for incoming val
then display incoming Val
send this For Humidity Val
wait for incoming val
then display incoming Val
send this For Soil Val
wait for incoming val
then display incoming Val
send this For Volt Val
wait for incoming val
then display incoming Val
then delay for 5mins then start again
This works great if i send them out the coms using my xbee coms board
Can anyone help me with this
This is the transmitter code.
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
char inData[24];
byte index;
boolean started = false;
boolean ended = false;
int Sensor1 = A0;
int analogInput = A1;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.02; // !! resistance of R1 !!
float R2 = 7399.40; // !! resistance of R2 !!
// variable to store the value
int value = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while(Serial.available() > 0)
{
char aChar = Serial.read();
if(aChar == '<')
{
started = true;
index = 0;
inData[index] = ' ';
}
else if(aChar == '>')
{
ended = true;
}
else if(started)
{
inData[index] = aChar;
index++;
inData[index] = ' ';
}
}
if(started && ended)
{
// Use the value
if(inData[0] == 'R')
{
inData[0] = ' ';
float t = dht.readTemperature();
Serial.print("<T");
Serial.print(t);
Serial.print(">");
}
else if(inData[0] == 'B')
{
inData[0] = ' ';
float h = dht.readHumidity();
Serial.print("<H");
Serial.print(h);
Serial.print(">");
}
else if(inData[0] == 'C')
{
inData[0] = ' ';
int Sensor1 = analogRead(A0);
Serial.print("<M");
Serial.print(Sensor1);
Serial.print(">");
}
else if(inData[0] == 'D')
{
inData[0] = ' ';
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
Serial.print("<V");
Serial.print(vin);
Serial.print(">");
}
started = false;
ended = false;
index = 0;
inData[index] = ' ';
}
}