Re: nRF24L01, how to send and receive in the same time :o

Please Help,

What I have here in my code is:

I have TWO RF24L01 connected each one to Arduino MEGA 2560. I want both of them to work in Sending and Receiving data in the same time.
Arduino MEGA 1 sending char “A”. … Arduino MEGA 2 Should receive A.
Arduino MEGA 2 sending char “B”. … Arduino MEGA 1 Should receive B.

This is my simple code.
I was working before on Xbee and it was working fine, but now I want to replace the Xbee with RF24L01.

Please help me … what I have is both Arduinos Just SENDING !!! without any receiving.
Thanks.

The code of ARDUINO 1:

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
RF24 radio(48, 53);
int ackMessg[3] = {0, 0, 0};
char x[] = "A";
char y ;
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
void setup()
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(76);
  radio.enableAckPayload();
  radio.setRetries(2, 5);
}
void loop()
{
  radio.openReadingPipe(1, pipe[1]);
  radio.writeAckPayload(1, ackMessg, sizeof(ackMessg));
  if ( radio.available() )
  {
    radio.read( &y, sizeof(y) );
    Serial.print("The value recieved from 2 is: ");
    Serial.println(y);
    delay (500);
    //ackMessg[1] += 3;
  }
  radio.openWritingPipe(pipe[0]);
  radio.write(&x, sizeof(x));
  Serial.println("x have been sent from 1");
  delay (500);
  if ( radio.isAckPayloadAvailable())
  {
    radio.read(ackMessg, sizeof(ackMessg));
    //ackMessg[1] += 3;
  }
  ackMessg[1] += 3;
}

The code for ARDUINO 2:

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
RF24 radio(48, 53);
int ackMessg[3] = {0, 0, 0};
char y ;
char x[] = "B";
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
void setup()
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(76); // default 76
  radio.enableAckPayload();
  radio.setRetries(2, 5);
   //radio.writeAckPayload(1, ackMessg, sizeof(ackMessg));
  //radio.startListening();
}
void loop()
{
  radio.openReadingPipe(1, pipe[1]);
  radio.writeAckPayload(1, ackMessg, sizeof(ackMessg));
  if ( radio.available() )
  {
    radio.read( &y, sizeof(y) );
    Serial.print("The value recieved from 1 is: ");
    Serial.println(y);
    delay (500);
    //ackMessg[1] += 3;
  }
  radio.openWritingPipe(pipe[0]);
  radio.write(&x, sizeof(x));
  Serial.println("x have been sent from 2");
  delay (500);
  if ( radio.isAckPayloadAvailable())
  {
    radio.read(ackMessg, sizeof(ackMessg));
    //ackMessg[1] += 3;
  }
  ackMessg[1] += 3;
}

Probably the simplest solution is to use the setAckPayload() function in the “slave” device. When the “master” sends data to the slave the ackPayload will be automatically sent back to the master without needing to switch either device between listening and sending.

The attached pair of programs illustrate this. TrackControl.ino is the master. The full version of this is used to control model trains.

…R

TrackControl.ino (2.67 KB)

HandController.ino (1.96 KB)

I have tried to send a frame from 1 to 2 and opposite, it works with me fine but actually I did not understand how that happen !! Can you please have a look to my simple code here and tell me if there is a possibility to make it better.

Arduino 1 sending a frame of x[5] = {1, 2, 3, 4, 5} to Arduino 2.

Arduino 2 sending a frame of byte x[5] = { 11, 12, 13, 14, 15}; to Arduino 1.

Code for Arduino 1:

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
RF24 radio(53, 53);
byte ackMessg[5] = {0};
byte x[5] = {1, 2, 3, 4, 5};
boolean state = true;
void setup()
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(76); // default 76
  radio.enableAckPayload();
  radio.openReadingPipe(1, pipe[0]);
  radio.setRetries(2, 5);
}
void loop()
{
  radio.writeAckPayload(1, ackMessg, sizeof(ackMessg));
  radio.openWritingPipe(pipe[0]);
  if (state == true)
  {
    radio.stopListening();
    radio.write(x, sizeof(x));
    for (int i = 0; i < sizeof(x); i++)
    {
      Serial.print("x[");
      Serial.print(i, DEC);
      Serial.print("]=");
      Serial.println(x[i]);
      delay (100);
      radio.startListening();
      state = false;
    }
    delay (500);
  }

  else
  {
    if ( radio.isAckPayloadAvailable())
    {
      radio.read(ackMessg, sizeof(ackMessg));
      for (int i = 0; i < sizeof(ackMessg); i++)
      {
        Serial.print("ackMessg[");
        Serial.print(i, DEC);
        Serial.print("]=");
        Serial.println(ackMessg[i]);
        delay (100);
      }
    }
    state = true;
  }
}

Code for Arduino 2:

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
RF24 radio(53, 53);
byte ackMessg[5] = {0};
byte x[5] = { 11, 12, 13, 14, 15};
boolean state = true;
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
void setup()
{
  Serial.begin(9600);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(76);
  radio.enableAckPayload();
  radio.setRetries(2, 5);
}
void loop()
{
  radio.openWritingPipe(pipe[0]);
  if (state == true)
  {
    radio.stopListening();
    radio.write(x, sizeof(x));
    for (int i = 0; i < sizeof(x); i++)
    {
      Serial.print("x[");
      Serial.print(i, DEC);
      Serial.print("]=");
      Serial.println(x[i]);
      delay (100);
      radio.startListening();
      state = false;
    }
    delay (500);
  }

  else
  {
    if ( radio.isAckPayloadAvailable())
    {
      radio.read(ackMessg, sizeof(ackMessg));
      for (int i = 0; i < sizeof(ackMessg); i++)
      {
        Serial.print("ackMessg[");
        Serial.print(i, DEC);
        Serial.print("]=");
        Serial.println(ackMessg[i]);
        delay (100);
      }
    }
    state = true;
  }
}

Please Upload and try my code if you can tell me exactly what happen inside and many thanks for you.

The Results for Arduino 1 are :
x[0]=1
x[1]=2
x[2]=3
x[3]=4
x[4]=5
ackMessg[0]=11
ackMessg[1]=12
ackMessg[2]=13
ackMessg[3]=14
ackMessg[4]=15

The Results for Arduino 2 are :
x[0]=11
x[1]=12
x[2]=13
x[3]=14
x[4]=15
ackMessg[0]=1
ackMessg[1]=2
ackMessg[2]=3
ackMessg[3]=4
ackMessg[4]=5

Short answer is "I don't know".

I don't understand why you are using writeAckPayload() and at the same time you are using radio.write() in both programs. Also, you are not putting the data that is in the array x into the payload. (Don't use single character names for variables).

If you look at my examples you will see that only one program (the master) uses radio.write().

I may try and find time tomorrow to simplify my examples.

...R

Thank you.

Okay please after you simplify your example, try to post them here.

Many thanks.
Regards,

Alas, I will not get time until the 19th.

...R

Okay... no problem .. Please .. I just want a simple example that each RF can send & receive in the same time.

Regards,

Sorry - I got distracted by a new toy yesterday :slight_smile:

Here is the simplified pair of programs. They have just been working on my Uno and Mega.

Note the comment in the code about the need for a small change to the write() function in the library file RF24.cpp

As before the code in TrackControl is the master and the HandController is the slave.

…R

TrackControl.ino (1.9 KB)

HandController.ino (1.69 KB)

Hi,

I want both of them to work in Sending and Receiving data in the same time.

I just want a simple example that each RF can send & receive in the same time.

You want TX A and TX B to send at the same time and RX A and RX B to receive at the same time, that is FULL DUPLEX.

The nRF24L01 cannot do that, one TX A to RX A, THEN TX B to RX B, but not at the same time.

To do that you need specialized units that have either different TX band frequencies or if on the same band then RF isolation devices called diplexers, even separate TX and RX aerials.

Tom.... :slight_smile:

TomGeorge:
You want TX A and TX B to send at the same time and RX A and RX B to receive at the same time, that is FULL DUPLEX.
The nRF24L01 cannot do that,

If you look at my example code, it can get pretty close to doing that. It would be hard to see the join.

…R

I NEEED help

I have 2 nrf24l01+ with 1 UNO (TR) GA2560(R)

if I have Vin only in UNO the riciver has not print me nothing in Serial

if both is in COM usb I have communication why ???

lino92:
I NEEED help

I have 2 nrf24l01+ with 1 UNO (TR) GA2560(R)

if I have Vin only in UNO the riciver has not print me nothing in Serial

if both is in COM usb I have communication why ???

You need to explain what you are trying to do very much more clearly. To be honest I don't understand any of what what you have said. For example why would you have 2 nRF24s and only one Uno? What is the other nRF24 connected to?

Have a look at this Simple nRF24L01+ Tutorial

...R

@lino92 has asked the same question, but with a little more information here.

I suggest people do not reply to his question in this Thread.
As this Thread has continued I have suggested to the Moderator to delete the Post in the other Thread.

...R

hello I need help I have 2 nrf24l01+

1 uno (TR) and mega 2560 (RC)

when the uno is not in COM USB the MEGA has not print nothing in Serial (the uno is in power VOUT 9 vot )

when is in Com the Arduino mega has writte on Serial ?

#include <SPI.h>
#include <Wire.h>
#include <OneWire.h>
#include <RF24Network.h>
#include <RF24.h> 
OneWire ds(8);    //ds στην ψηφιακή θύρα 8
#include "DHT.h" // DHT11 ή 22 αισθητήριο υγρασίας 
#define DHTPIN 3 // στο pin 7 πηγαίνει το σήμα του αισθητήριου υγρασίας
#define DHTTYPE DHT22 // ο τύπος του αισθητήριου υγρασίας που χρησιμοποιούμε 
#define LED_light 5 // στο pin 5 πηγαίνει το σήμα του αισθητήριου φωτεινότητας LDR
DHT dht(DHTPIN, DHTTYPE);
#define CE_PIN 9  // το CE είναι στην θύρα 9
#define CSN_PIN 10  // το CSN είναι στην θύρα 10
RF24 radio (CE_PIN ,CSN_PIN) ; // Ασύρματη επικοινωνία που επισυνάπτεται σε ποιες θύρες
RF24Network network (radio) ;  // Το δίκτυο που χρησιμοποίει  η ασύρματη επικοινωνία
const uint16_t this_node = 1;
const uint16_t other_node = 0;
const unsigned long interval = 2000;  //μ second
unsigned long last_sent;      //  το τελευταίο πακέτο δεδομένων
unsigned long packets_sent;     // ποσά πακέτα έχουν αποσταλθεί 
int A;
int a=1024;
int d ;
int y=1024;
int x=A0;
int x2=A1;      //ακέραια μεταβλητή που την δέχεται από την αναλογική 1
int light_pin =A5;    //ακέραια μεταβλητή που την δέχεται από την αναλογική 5
float Humidity;     //δεκαδική μεταβλητή  σχετικής υγρασίας 
float T;
int nRainIn =A2;
int nRainDigitalIn =6;
int nRainVal;
boolean bIsRaining = false; //δυαδική μεταβλητή
String strRaining;      //χαρακτήρας
int Soil=0;
int Soilb=0;

struct payload_t  // η δομή payload δηλώνουμε ποιες μεταβλητές θα στέλνει μέσο της ασύρματης επικοινωνίας
{
  unsigned long ms; 
  int A;
  float Temp;
  int light_lvl;
  float Humidity;
  int Soil;
  int Soilb;
  int nRainVal;
  boolean bIsRaining;
  unsigned long counter;
};




void setup() {
Serial.begin(57600);
analogReference(5);
Serial.println("Trasnfer data GReenHouse Arduinio RF24Network PSev/");
dht.begin(); 
Wire.begin();
pinMode(LED_light, OUTPUT);    // δήλωση μεταβλητής σαν έξοδος
pinMode(nRainDigitalIn, INPUT);     // δήλωση μεταβλητής σαν είσοδος 
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  }


void loop() {
 byte i=0;
 byte present = 0;
 byte type_s;
  byte data[12];
  byte addr[8];
  float Temp;
network.update();     //ανανέωση δικτύου επικοινωνίας RF

if ( !ds.search(addr)) {
//    Serial.println("No more addresses.");
    // Serial.println();
    ds.reset_search();
  //  delay(250);
    return;
  }
  
 
  Serial.print("ROM =");    // ROM READ ONLY DATA
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  
  //delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  
  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad
//  Serial.print("  Data = ");
//  Serial.print(present, HEX);
//  Serial.print(" ");
  for ( i = 0; i < 8; i++) {           // we need 9 bytes
    data[i] = ds.read();
//    Serial.print(data[i], HEX);
//    Serial.print(" ");
  }
 // Serial.print(" CRC=");
  //Serial.print(OneWire::crc8(data, 8), HEX);
  //Serial.println();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }

Temp = (float)raw / 16.0; 
//με αυτή την διαίρεση  είναι η θερμοκρασία σε celsius στα αισθητήρια DS18b20
  Serial.print("  Temperature = ");
  Serial.print(Temp);
  Serial.print(" Celsius, ");
  Serial.println();

Humidity = dht.readHumidity();
T = dht.readTemperature();
Serial.print("Humidity: ");
Serial.print(Humidity);
Serial.println(" %");
int light_lvl=analogRead(light_pin);
Serial.print("Brightness:");
Serial.println(light_lvl);
int x = analogRead(A0);//take a sample
int x2 = analogRead(A1);//take a sample
Soil=y - x; // είναι 1024- x (το αποτέλεσμα του αισθητήρα) για να είναι κατά αύξουσα σειρά η υγρασία εδάφους 
Soilb = y - x2;
Serial.print("Soil=");Serial.println(Soil); 
Serial.print("Soil_Sec =");Serial.println(Soilb);
  nRainVal = analogRead(nRainIn);
  bIsRaining = !(digitalRead(nRainDigitalIn));
  
  if(bIsRaining){
    strRaining = "Yes";
  }
  else{
    strRaining = "No";
  }
  Serial.print("Raining: ");
  Serial.print(strRaining);  
  Serial.print("\t Moisture Level:");
  Serial.println(nRainVal);
d= ((a-light_lvl)/4); // με αυτή την πράξη ο όταν υπάρχει έλλειψη φωτός να υπάρχει φωτίζετε κατάλληλα
Serial.println(d);    // d είναι η έλλειψη φωτός 255 καθόλου φως 
if (d>80 )
{
analogWrite (LED_light,d);  //ρυθμίζει την φωτεινότητα τον led μέσω του Δίκτη d Serial.println ("LED ON");
}
else
{
  analogWrite(LED_light,0);
  Serial.println("LED OFF");
}
  if (addr[0] == 0x28 && addr[1] == 0xFF && addr[2] == 0x35 && addr[3] == 0x08 && addr[4] == 0x63 && addr[5] == 0x04 && addr[6]==0x00 &&addr[7] == 0x78 )
{
  A=1;
  Serial.println();
  Serial.println(A);
}

else if (addr[0] == 0x28 && addr[1] == 0x8E && addr[2] == 0x21 && addr[3] == 0x05 && addr[4] == 0x07 && addr[5] == 0x00 && addr[6]==0x00 &&addr[7] == 0x29 )
{
  A=2;
  Serial.println();
  Serial.println(A);
}

else if (addr[0] == 0x28 && addr[1] == 0xFF && addr[2] == 0xF8 && addr[3] == 0x08 && addr[4] == 0x65 && addr[5] == 0x04 && addr[6]==0x00 &&addr[7] == 0x67 )
{
  A=3;
  Serial.println();
  Serial.println(A);
}
else if (addr[0] == 0x28 && addr[1] == 0xFF && addr[2] == 0xB7 && addr[3] == 0x0C && addr[4] == 0x65 && addr[5] == 0x04 && addr[6]==0x00 &&addr[7] == 0xEF )
{
  A=4;
  Serial.println();
  Serial.println(A);
}
else if (addr[0] == 0x28 && addr[1] == 0xFF && addr[2] == 0xAD && addr[3] == 0x08 && addr[4] == 0x65 && addr[5] == 0x04 && addr[6]==0x00 &&addr[7] == 0x20 )
{
  A=5;
  Serial.println();
  Serial.println(A);
}
delay(10000);

  unsigned long now = millis();
  if  (now - last_sent >= interval)
  {
    last_sent = now;
    Serial.print("Sending...");
 payload_t payload = { millis(),A,Temp, light_lvl, Humidity, Soil, Soilb, nRainVal, bIsRaining, packets_sent++ };   //δηλώσει των μεταβλητών και με την σειρά που  είναι
    RF24NetworkHeader header(/*to node*/ other_node);
    bool ok = network.write(header, &payload, sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
      delay(200);
  }
}
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "DHT.h" // DHT11 ή 22 αισθητήριο υγρασίας 
#define DHTPIN 7 // στο pin 7 πηγαίνει το σήμα του αισθητήριου υγρασίας (μπορεί να αλλαχθεί)
#define DHTTYPE DHT22   //ο τύπος του αισθητήριου  
DHT dht (DHTPIN,DHTTYPE);
#define CE_PIN 40 // το CE είναι στην θύρα 40
#define CSN_PIN 42  // το CSN είναι στην θύρα 42
RF24 radio (CE_PIN ,CSN_PIN) ;
RF24Network network(radio);
const uint16_t this_node = 0;
float H;
float T;
int heater=4 ;    //σε ποια έξοδο για την χρωμονικελίνη 
int dhuminty=5; //σε ποια έξοδο είναι ο ανεμιστήρας για την πτώση της σχετικής υγρασίας 
int fan=6;    //σε ποια έξοδο είναι ο ανεμιστήρας για την  είσοδο του αέρα  
int water=3;    //σε ποια έξοδο είναι η αντλία νερού 
boolean Rain;
struct payload_t
// η δομή payload δηλώνουμε πoιες μεταβλητές θα στέλνει μέσο ασύρματης επικοινωνίας
{
  unsigned long ms;
  int A;
  float Temp;
  int light_lvl;
  float Humidity;
  int Soil; 
  int Soilb;
  int nRainVal;
  boolean bIsRaining;
  unsigned long counter;
};

void setup(void)     // οι ρυθμιζόμενες εντολές θα τρέξουν μόνο μια φόρα στην έναρξη του προγράμματος
{
  Serial.begin(57600);
  Serial.println("Reciver data GReenHouse Arduinio RF24Network PSev/");
    radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  dht.begin();
  SPI.begin();
pinMode(heater, OUTPUT);    // δήλωση μεταβλητής σαν έξοδος
pinMode(dhuminty, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(water, OUTPUT);
}


void loop()
{
H = dht.readHumidity();  // καταχωρεί την τιμή της σχετικής υγρασίας από το αισθητήριο
T = dht.readTemperature();// καταχωρεί την τιμή της θερμοκρασίας από το αισθητήριο
    float celsius;    //δήλωση μεταβλητών για τις συνθήκες
    float Humidity;
    int Soil;
    int Soilb;
 network.update();
  // Is there anything ready for us?
  while ( network.available() )
  {
    RF24NetworkHeader header;
    payload_t payload;
    network.read(header,&payload,sizeof(payload));  
// εκτύπωση στην σειριακή τα δεδομένα που λήφθηκαν από τον UNO μέσο ασύρματης επικοινωνίας
    Serial.print("Received packet #");
    Serial.print(payload.counter);
    Serial.print(",");
    Serial.print("Sensor_DS:");
    Serial.print(payload.A);
    Serial.print(",");
    Serial.print("TEMP:");
    Serial.print(payload.Temp);
    Serial.print("*C");
    Serial.print(",");
    Serial.print("Brightness:");
    Serial.print(payload.light_lvl);
    Serial.print(" /1024");
    Serial.print(",");
    Serial.print("Humidity:");
    Serial.print(payload.Humidity);
    Serial.print("%,");
    Serial.print("Soil:");
    Serial.print(payload.Soil);
    Serial.print(",");
    Serial.print("Soilb:");
    Serial.print(payload.Soilb);
    Serial.print(",");
    Serial.print("nRainVal:");
    Serial.print(payload.nRainVal);
    Serial.print(",");
    Serial.print("Rain:");
    Rain = (payload.bIsRaining);
    if (Rain == 1)
    Serial.print ("YES");
    else 
    Serial.print ("NO");
    Serial.print("   ------ ");
    Serial.print(payload.counter);
    Serial.print(" at ");
    Serial.println(payload.ms);
    Serial.print("Temperature_environment:");
    Serial.print(T);
    Serial.print("*C");
    Serial.print(",");
    Serial.print("Humidity_environment:");
    Serial.print(H);
    Serial.print("%");
Serial.println(",");
celsius = payload.Temp; //payload. temp = celsius για να μπορούν να γίνουν οι συνθήκες 
Humidity =payload.Humidity; // payload. Humidity = Humidity για να μπορούν να γίνουν οι συνθήκες
Soil=payload.Soil;  //payload.Soil= Soil για να μπορούν να γίνουν οι συνθήκες
Serial.println (celsius); //εκτύπωση της θερμοκρασίας που διάβασε από τον αισθητήρα μέσα στο θερμοκήπιο
Serial.println();
if (celsius >=20 && celsius <=29)
{
  digitalWrite(heater,HIGH);  // επειδή το relay είναι λογικής TTL θα είναι κλειστό
  digitalWrite(fan, LOW);
  Serial.println("Satisfactory temperature");
       if (Humidity >=50 && Humidity<=80)
    {
      Serial.println("Good level of relative humidity");
      digitalWrite(dhuminty, LOW);
      digitalWrite(water,HIGH); // επειδή είναι σε TTL relay θα είναι κλειστή
    }
      else if(Humidity <50)
    {
  if (Soil >24 && Soil<=654 || Soilb >24 && Soilb <=654)
// δηλαδή εάν είναι συνδεμένος ο αισθητήρας εδάφους και δεν έχει γεμίσει με νερό το χώμα
      { 
        Serial.println("watering");
        digitalWrite(water, LOW);
      }
      else if (Soil >= 666 || Soilb >=666 )
      {
        Serial.println("Soil in water");
        digitalWrite(water, HIGH);
      }
      else
      {
        Serial.println("Soil in water OR DISCONNECTED Sensor ");
        digitalWrite(water, HIGH); //κλειστή η αντλία νερού
      }
    digitalWrite(dhuminty, HIGH); // κλειστός ο ανεμιστήρας
    }

     if (Humidity >80 || Rain == 1)
    {   
   Serial.println("HIGH level relative humidity");
  Serial.println ("MODE: Wind recycling");
      digitalWrite(dhuminty, LOW); // δουλεύει ο ανεμιστήρας για να την ελάττωση της σχετική υγρασία 
      digitalWrite(water, HIGH);
    }
else if (celsius >=34)
{
      digitalWrite(heater,HIGH); // επειδή το relay είναι λογικής TTL θα είναι κλειστό
      digitalWrite(fan, HIGH);
      Serial.println("MODE Cool greenHouse");
       if (Humidity >=50 && Humidity<=80)
    {
      digitalWrite(dhuminty, LOW);
      Serial.println("Good level of relative humidity");
      digitalWrite(water, HIGH); 
      digitalWrite(dhuminty, HIGH);
     } 
    else if (Humidity<50)
    { 
      digitalWrite(dhuminty, HIGH); // ανεμιστήρας κλειστός 
if (Soil >24 && Soil<=654 || Soilb >24 && Soilb <=654) 
      {
        Serial.println("watering");
        digitalWrite(water, LOW);
      }
      else if (Soil >= 666 || Soilb >=666 )
      {
        Serial.println("Soil in water");
        digitalWrite(water, HIGH);
      }
      else
      {
        Serial.println("Soil in water OR DISCONNECTED Sensor ");
        digitalWrite(water, HIGH);
       }
    }
  if (Humidity >80 || Rain == 1)
    { 
      Serial.println("HIGH  level of relative humidity");
      Serial.println ("MODE: Wind recycling");
      digitalWrite(dhuminty, LOW);
      digitalWrite(water, HIGH);
    }
}
else if (celsius <=16)
{
      digitalWrite(heater ,LOW);  // επειδή το relay είναι λογικής TTL θα είναι ανοιχτό 
      analogWrite(fan,220);
      Serial.println("MODE Heat  greenHouse");
        if (Humidity >=50 && Humidity<=80)
    {
      digitalWrite(dhuminty, LOW);
      Serial.println("Good level of relative humidity");
      digitalWrite(water, HIGH);
      digitalWrite(dhuminty, HIGH);
     } 
    else if (Humidity<50)
    { 
      digitalWrite(dhuminty, HIGH);// ανεμιστήρας για την υγρασία κλειστός
if (Soil >24 && Soil<=654 || Soilb >24 && Soilb <=654)
      {
        Serial.println("watering");
        digitalWrite(water, LOW);
      }
     else if (Soil >= 666 || Soilb >=666 )
      {
        Serial.println("Soil in water");
        digitalWrite(water, HIGH);
      }
      else
      {
        Serial.println("water soil OR DISCONNECTED Sensor ");
        digitalWrite(water, HIGH);
      }
    }
       if (Humidity >80 || Rain == 1)
    {   
      Serial.println("HIGH level relative humidity");
      Serial.println ("MODE: Wind recycling");
      digitalWrite(dhuminty, LOW); // δουλεύει ο ανεμιστήρας για την ελάττωση της σχετική υγρασία 
      digitalWrite(water, HIGH);
    }
}
else 
{
    digitalWrite(heater, HIGH); // επειδή το relay είναι λογικής TTL θα είναι κλειστό
    digitalWrite(fan, LOW);
      if (Humidity >=50 && Humidity<=80)
    {
      digitalWrite(dhuminty, LOW);
      digitalWrite(water, HIGH);
      digitalWrite(dhuminty, HIGH);
     } 
    else if (Humidity<50)
    { 
      digitalWrite(dhuminty, HIGH); // ανεμιστήρας για την υγρασία είναι κλειστός
if (Soil >24 && Soil<=654 || Soilb >24 && Soilb <=654)
      {
        Serial.println("watering");
        digitalWrite(water, LOW);
      }
      else if (Soil >= 666 || Soilb >=666 )
      {
        Serial.println("Soil in water");
        digitalWrite(water, HIGH);
      }
      else
      {
        Serial.println("Soil in water OR DISCONNECTED Sensor ");
        digitalWrite(water, HIGH);
      }
    }
     if (Humidity >80 || Rain == 1)
    {   
      Serial.println("HIGH level relative humidity");
      Serial.println ("MODE: Wind recycling");
      digitalWrite(dhuminty, LOW); // δουλεύει ο ανεμιστήρας για ελάττωση της σχετική υγρασία 
      digitalWrite(water, HIGH);
    }
}
Serial.println();
} 
}
}

I don't know what is wrong is not the hard ware because the programm work correct and

lino92:
I don't know what is wrong is not the hard ware because the programm work correct and

If the program is working correctly why have you got a problem?

Have you studied the link I gave you in Reply #11 ?

...R

I SAY .. if the uno TR is out of COM the programme has not send me data (is the Arduino in 9VOlt vcc) and this happen in 2 Arduino and in examples

What about the second question in Reply #16?

Debugging wireless problems can be very difficult. Start with the simplest possible program that sends data wirelessly - something simple like "hello world". Don't add any other stuff until that is working properly. Then you can add other pieces one at a time testing everything as you go.

...R

why if both Arduino is in computer te program work ???