Arduino Uno R3 radio NRF24L01 and DHT22 telemetry

Hello,
I have idea to use with Arduino Uno R3 radio NRF24L01 and DHT22 module for measuring of temperature and humidity.

I have tried to create dual communication channels, but I have had many problems with it. On the end I have found here in forum simply usíng of NRF24L01 radio module as only for one side to second one transmission as a type of master - slave system without any acknolige message based on SimplyTx and SimplyRx by Robin2 here on forum.

So, there are two schetches for this purpose and I hope they will be interesting for users of this forum.

//Arduino-NRF-DHT-SimpleTx telemetry sender 
//from NRF24L01 + temperature and humidity modul DHT22
//created by PavelOu on the base of Simple one way transmission by Robin2
//from Arduino Forum
// thank you very  much for Dratek.cz for their lectures (in the czech language)
//The following pair of programs sends a simple telemetry message from the TX to the RX 
//on the base of SimpleTx-Ronin2.ino
//
//SimpleTx - the master sender or the transmitter

// libraries for NRF24L01 (in original used as radio)
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   7    // set your pins on the right ones in your schema
#define CSN_PIN  8

const byte slaveAddress[5] = {'R','X','S','0','1'};   //RX Slave 01

RF24 nRF(CE_PIN, CSN_PIN); // Create a nRF

//example of a sended message with numbers 0 to 10  (the teen byte is as char 0)
//char dataToSend[11] = {'0','1','2','3','4','5','6','7','8','9','0'}; 
//final example of the sended message
char dataToSend[11] = {'$','1','2','3',',','5','6','7','*','P','P'}; 
//where is :
//123 is temperature multiplied by 10
//567 is humidity multiplied by 10

//library DHT
#include "DHT.h"
//number of pin coupled with DHT sensore
#define pinDHT 5

//set the right type of DHT sensor
//#define typeDHT11 DHT11     // DHT 11
#define typeDHT22 DHT22   // DHT 22 (AM2302)

// inicialiyation of DHT sensor with pin and type of sensor
DHT myDHT(pinDHT, typeDHT22);

byte dataMode = 0;
char endOfMessage = '*';
byte typedMark = 0;
byte lengthOfMessage = 0;
byte pause = 3;
unsigned int timeOfpause = 1000;

int j = 0;
int i = 0;

//examples for the float outputs from sensors
float analogInputA0 = 23.9;
float temp = 21.7;
float hum = 54.3;

//table for transcoding the float numbers to characters
char nrToCharBuf[] = {'0','1','2','3','4','5','6','7','8','9'};

String sendedText = "";

void setup() 
  {
    Serial.begin(9600);
    Serial.println("SimpleTx Starting send messages !");
    nRF.begin();
    nRF.setDataRate( RF24_250KBPS );
    nRF.setRetries(3,5); // delay, count
    nRF.openWritingPipe(slaveAddress);
    //set communication with module DHT
    myDHT.begin();
    dataMode = 4;
  }

//====================

void loop() 
   {
    if (dataMode == 5 )
      {
        Senddata();
        dataMode = 4;
        timeOfpause = pause * 1000;
        delay(timeOfpause);        
      }
    Setdata();    
}

//====================


void Senddata() 
 {
    bool rslt;
    rslt = nRF.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
    //Serial.print("Data Sent ");
    Serial.println(dataToSend);
    nRF.flush_tx(); 
 }

//================


void Setdata()
 {
  //Servis part of this sketch is in final ino not used 
  if (dataMode == 1)
   {
     Serial.println(" ");
     Serial.println("Sensor TXM01 is ready for NRF communication !");
     Serial.print("End mark of message: ");
     Serial.println(endOfMessage);
                                
     Serial.println("For sending messages type T (as TX) !");
     Serial.println("For set of message delays type P (as pause) !");
     Serial.println("For end of all actions type B (as Break) !");
    dataMode = 2;
   }       // end of dataMode = 1
   
  if (dataMode == 2)
   {     
    if (Serial.available() )
      {
       typedMark = Serial.read();  
       Serial.print("Typed: ");
       Serial.println(typedMark);
       if (typedMark == 66)  // Break
         {
            //ServisOn = true;
            Serial.println("Break and return to basic state  !");
            dataMode = 1;
         }  
        if (typedMark == 84)        // T = transmission
          {
           dataMode = 4;
           Serial.println("TX - Station will send messages !");
          }
        if ( typedMark == 80 )   // P
          {
            String Pstring = Serial.readString();
            Pstring.trim();
            pause = Pstring.toInt();
            if (pause > 10)
             {
              Serial.println("Length of pause is limited to 10 sec !");
              pause = 10;
             }
            Serial.print("Pause between sending of messages : ");
            Serial.print(pause);
            Serial.println(" sec !");
          }        
        Serial.flush(); 
    }
   }
  if (dataMode == 4)
   {    
     //analogInputA0 = analogRead(A0) / 10;
     //analogInputA0 = 87.9;
     /*
     if (analogInputA0 > 100)
      {
       analogInputA0 = 99.9 ;   
      }
     for (j = 0; j<10; j++) 
           {
            dataToSend[j] = 0;
           }
     */      
     dataToSend[0] = '$';
     temp = myDHT.readTemperature();
     // test of temp validity by function isnan
     if (!isnan(temp))
      { 
        int X = temp*10;  // example 231
        int W = X / 100; // 2
        dataToSend[1] = nrToCharBuf[W];
        int V = X - (W*100);   // 31
        int U = V/10;    // 3
        dataToSend[2] = nrToCharBuf[U];
        int Q = V - (U*10);   // 1
        dataToSend[3] = nrToCharBuf[Q];
     }
     else
      {
       dataToSend[1] =  'E'; 
       dataToSend[2] =  'r'; 
       dataToSend[3] =  'r'; 
      }
     dataToSend[4] = ',';
     hum = myDHT.readHumidity();
     if (!isnan(hum))
      {
     int X = hum*10;  // example 56.8
     int W = X / 100; // 5
     dataToSend[5] = nrToCharBuf[W];
     int V = X - (W*100);   // 68
     int U = V/10;    // 6
     dataToSend[6] = nrToCharBuf[U];
     int Q = V - (U*10);   // 8
     dataToSend[7] = nrToCharBuf[Q];
      }
     else
      {
       dataToSend[5] =  'E'; 
       dataToSend[6] =  'r'; 
       dataToSend[7] =  'r';         
      }
     dataToSend[8] = '*';
     //dataToSend[9] = '9';  //this will be simpliest LRC test parity nr one
     //dataToSend[10] = '0';  //this will be simpliest LRC test parity nr twoo of 1 byte
     byte parPom = 0;
     byte pLR = 0;
     for (j = 1; j<8; j++)
      {
       parPom = dataToSend[j];
       pLR = pLR + parPom;
      }
     parPom = pLR + 1;
     pLR = parPom;
     int X = pLR;  // example 041
     int W = X / 100; // 0 not used
     int V = X - (W*100);   // 41 this byte is simpliest LRC parity test
     int U = V/10;    // 4
     dataToSend[9] = nrToCharBuf[U];      
     int Q = V - (U*10);   // 1
     dataToSend[10] = nrToCharBuf[Q];      
     lengthOfMessage = 10;
     dataMode = 5;
  }       // end of dataMode = 4
   
 if (dataMode == 5) 
  {
     i = 0;
     sendedText = "";
     for (j = 0; j<11; j++)
          {
           typedMark = dataToSend[j];  
           sendedText = sendedText + dataToSend[j];
           i = i + 1;
          } 
     lengthOfMessage = i;
     Serial.print("Length of message: ");
     Serial.println(lengthOfMessage);
     Serial.print("Sended data (text): ");
     Serial.println(sendedText);
     delay(1000);            
  }       //end of dataMode = 5
    
}
//====================


//Arduino-NRF-SimpleRx telemetry receiver 
//from NRF24L01 and temperature and humidity sensor DHT22 for example
//created by PavelOu on the base of Simple one way transmitter and receiver
//by Robin2 from Arduino Forum
// thank you very  much for Dratek.cz for their lectures (in the czech language)
//The following pair of programs can send a simple telemetry message from the TX to the RX one.
//
//SimpleRx-Ronin2.ino
// SimpleRx - the slave as the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   7
#define CSN_PIN  8 

const byte thisSlaveAddress[5] = {'R','X','S','0','1'};
String receiverAddress = "RXS01";   // RX Slave 01

RF24 nRF(CE_PIN, CSN_PIN);

char dataReceived[11]; // this need match to dataToSend length in the TX, but it is not very critical
bool newData = false;

String reseivedData = "";
int j = 0;

//===========

void setup() 
{

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    nRF.begin();
    nRF.setDataRate( RF24_250KBPS );
    nRF.openReadingPipe(1, thisSlaveAddress);
    Serial.print("Receiver ");
    Serial.println(receiverAddress);
    Serial.println(" is on air ... ");
    nRF.startListening();
    //delay(3000);
    Serial.println(" and ready to receive new messagees !");
    nRF.flush_rx();
}

//=============

void loop() 
{
    Getdata();
    Showdata();
}

//==============

void Getdata() 
 {
    dataReceived[0] = 0;
    newData = false;
    if ( nRF.available() ) {
        nRF.read( &dataReceived, sizeof(dataReceived) );
        reseivedData = "";
        for (j = 0; dataReceived[j]>0; j++)
          {
            reseivedData = reseivedData + dataReceived[j];
          }
        //Serial.print("Reseived data: ");
        //Serial.println(reseivedData);  
        if (dataReceived[0]>0) 
         {
          newData = true;
         }
        else
         {
          nRF.flush_rx();  
         }
    }
 }

void Showdata() 
   {
    if (newData == true) 
    {
        //Serial.print("Data received ");
        Serial.println(dataReceived);
    }
   newData = false;
}

I moved your topic to an appropriate forum category @pavelou .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi Pert, thank you for your advance .. I am here on forum quite new, my english is not exccelent and I have the problems with right orientation in forum. It is not so simply to find the best category for a new topic, but this one is better, sure.

1 Like

Modules NRF24L01+PA+LNA and Arduino UNO R3 and Arduino NANO

I have started to test modules with IO NRF24L01+PA+LNA and I have found,
after some attempts, that they are consuming more power from source of 3.3 V
as previous modules with IO NRF24L01 only,
which are used simplified PA (Power Amplifier for TX) or LNA (Low Noise Amplifier for RX).

So Arduino NANO and Arduino UNO have power problem to hold modules with IO NRF24L01 alive.

There can be a problem to write codes for them, as by adding next modules or only
by writing next code lines by settin power in modul on PA_HIGH or more,
modul can suddenly dead by it and its communication will be losted. And not only as modul is set as transmitter, but in the case of it is set as receiver !!

This modul NRF24L01+PA+LNA with Arduino Nano as receiver did not work
and with Arduino UNO as receiver has started work after I have set power in modul on PA_MIN only

When you will read in datasheets, you can see , that IO NRF24L01 plus minus has consumed
about 12 mA, but full modules with PA and LNA have consumed much more ,
till 130 mA by TX and 20 mA by Rx and this is more as the sources in these Arduinos give.

Please, see, that power source for modules with IO NRF24L01 plus minus must be adequated.

Hello, I made some next my experiments with modules NRF24L01 and 2401-PA+LNA .

I have added to DHT22 the BMP180 for air pressure measuring.

I have tried and I need solve this basic problems :

  1. the powering of modules NRF24L01-PA+LNA with added capacitors, in my case to 330 uF
    and 68 nF, too.

  2. I have used only contact array and there were some not secure wire contacts,

  3. I dit not know if the memory of Arduino UNO will work with NRF, DHT22 and BMP180
    all together,

  4. I did not know if NRF radio will communicate one TX to second RX and on how long distance.

As the test of air to air communication is always difficult for tests, I have to think some times
about an end of my next attempts. When I have changed some instruction in my sketch
or if I have moved my desing of radio, the communications usually ended.

Over this problems, I have finished two sketches tied to my previous ones.

  1. I used for my SimleTX two commands for NRF PowerUp and PowerDown and with these commands was the NRF24L01-PA+LNA worked with added capacitors with Arduino Uno,
    but only on the minimal settled power in TX and RX,

  2. I have loaded the dynamic memory of Arduino Uno with all instruction of NRF, DHT22 and BMP180 for the basic telemetric transmission,

  3. My tested distance of TX to RX communication with my constructions was small , usually in one room, exclusive between room doors, but never into a house wall.

  4. The smaller module NRF24L01 without PA in lowest power for TX and RX can confirm
    that the communication between SimpleTX an SimpleRx was succesfull.
    Another type of confirmation I did not try and I let it for my followers.

  5. My result - it is better to use for similar experiments only the smaller modules of NRF24L01 as the types with PA+LNA, which need to use better construction and power as my contruction was used.

//Arduino-NRF-DHTP-SimpleTx-po-23 telemetry sender of temperature, humidity and air press
//with NRF24L01 or NRF24L01+PA+LNA
//with powerDown and powerUp  for lowering of power consumption
//PC USB or mobile OTG powered application
//with DHT22 for temperature and humidity and BMP180 air pressure for example
//with temperature polarity
//with LRC control
//run mode => dataMode = 3 in setup !!
//it is possible to go to servis mode by typing mark B (Break) with Enter
//created by PavelOu on the base of Simple one way transmission by Robin2
//from Arduino Forum
//thank you very  much for Dratek.cz for their lectures (in the czech language)
//This program send a simple telemetry message from the TX to the RX 
//on the base of SimpleTx-Robin2.ino
//to SimpleRx receiver
//
//SimpleTx - the master sender or the transmitter

// libraries for NRF24L01 (in origial used as radio)
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


//#define CE_PIN   7    // set your pins on the right ones in your schema
//#define CSN_PIN  8
#define CE_PIN   9    // set your pins on the right ones in your schema
#define CSN_PIN  10

const byte slaveAddress[5] = {'R','X','S','0','1'};   //RX Slave 01

RF24 nRF(CE_PIN, CSN_PIN); // Open nRF

//example of a sended message with numbers 0 to 10  (the teen byte is as char 0)
//final example of the sended message
//char dataToSend[20] = {'$','+','1','2','3',',','5','6','7',',','0','9','9','9','9','9','*','P','P','P','#'}; 
//where is :
//+(-)123 is temperature wirh polarity multiplied by 10
//567 is humiditi multiplied by 10
//100178 is presure multiplied to 100
//when BMP180 module is defect, the result is 555 Pa (5.55 mbar)
//PPP is one parity byte (000 to 255) LRC type
//char dataToSend[20];
//example
//char dataToSend[] = {'$','+','1','2','3',',','5','6','7',',','1','0','0','1','9','9','*','P','P','P','#'}; 
char dataToSend[21];
bool dataOn = false;  // true => data was transmitted
     
//library DHT
#include "DHT.h"
//number of pin coupled with DHT sensor
#define pinDHT 5

//set the right type of DHT sensor
//#define typeDHT11 DHT11     // DHT 11
#define typeDHT22 DHT22   // DHT 22 (AM2302)

// inicialisation of DHT sensor with pin and type of sensor
DHT myDHT(pinDHT, typeDHT22);

// Sensor of barometrick presure BMP180
#include <Wire.h>
#include <Adafruit_BMP085.h>
//this librarie use  pins A4 as SDA and A5 = SCL
//inicialisation of  sensor BMP180 on the modul HW-415 from library BMP085
Adafruit_BMP085 HW415;

byte dataMode = 0;
char endOfMessage = '#';
char endMarkOfData = '*';
char startOfMessage = '$';
byte typedMark = 0;
byte lengthOfMessage = 0;
byte pause = 4; // in seconds
unsigned int timeOfpause = 1000;

int j = 0;
int i = 0;

//examples for the float outputs from sensors
//float analogInputA0 = 23.9; //here not used
float temp = 21.7;
float hum = 54.3;
float pres = 1023.87;


// empiric constant for correction by measurig of atmospheric presure in Pascals
int corectPres = 320; // Pa - it is equal 3,2 mbar (1 mbar = 100 Pa )

//table for transcoding the float numbers to characters
char nrToCharBuf[] = {'0','1','2','3','4','5','6','7','8','9'};

String sendedText = "";

void setup() 
  {
    Serial.begin(9600);
    delay(1000); //delay for serial lines
    Serial.flush();
    Serial.println(" ");
    Serial.println("SimpleTx is starting send messages !");
    delay(5000); // delay for rise of voltage 3.3 V for nRF in capacitors cca 250 uF or more
    nRF.begin();
    nRF.setDataRate( RF24_250KBPS );
    //nRF.setRetries(3,5); // delay, count
    // setting of nRF power
    nRF.setPALevel(RF24_PA_MIN); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX) tested
    //nRF.setPALevel(RF24_PA_LOW); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX) 
    //nRF.setPALevel(RF24_PA_HIGH); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX)
    //nRF.setPALevel(RF24_PA_MAX); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX)
    nRF.openWritingPipe(slaveAddress);
    nRF.powerDown();
    dataOn = true;
    sendedText = "";
    i = 0;            
    //Serial.print("dataToSend declared :"); // for tests only
    //Serial.println(dataToSend);
    //Test of sended data format
    //Serial.print("dataToSend filled with spaces (a) : ");
    //Serial.println("*");
    //Serial.print("dataToSend filled with spaces (b): ");
    //Serial.print(sendedText);
    //Serial.println("*");
    //Serial.print("dataToSend filled with spaces (c): ");
    //Serial.print(dataToSend);
    //Serial.println("*");
    
    //set communication with modul DHT
    myDHT.begin();
    // start of communication with sensor BMP180
    HW415.begin(); // name of module with BMP180
    //dataMode = 1; //servis version
    dataMode = 3; //run version
    if (dataMode == 3)
     {
      Serial.println("Arduino-NRF-DHTP-SimpleTx-po-23 for PC USB or mobile USB OTG");
      Serial.print("Run mode - pause = ");
      Serial.print(pause);
      Serial.println(" [sec], Break - Type B");
     }
  }

//================


void loop()
 {
  //Servis part of this program is in run mode not used 
  if (dataMode == 1)
   {
     Serial.println("Arduino-NRF-DHTP-SimpleTx-po-23");
     Serial.println("Transmitter TXM01 with NRF24L01 is ready for communication !");
     Serial.print("End mark of message: ");
     Serial.println(endOfMessage);                                
     Serial.println("For sending messages type T (as TX) !");
     Serial.print("Pause is set to : ");
     Serial.print(pause);
     Serial.println(" [sec]");
     Serial.println("For set of another delay type P (as pause) with x = new delay!");
     Serial.println("For end of all actions type B (as Break) !");
     delay(1000);
     dataOn = true;
     dataMode = 2;
     nRF.powerDown();
   }       // end of dataMode = 1
   
  if (dataMode == 2)
   {     
    if (Serial.available() )
      {
       typedMark = Serial.read();  
       Serial.println(" ");
       //Serial.print("Typed: ");
       //Serial.println(typedMark);
       if (typedMark == 84)        // T = transmission
          {
           dataMode = 3;
           dataOn = true;
           Serial.println("TX - Station will send messages !");
          }
        if ( typedMark == 80 )   // P
          {
            String Pstring = Serial.readString();
            Pstring.trim();
            pause = Pstring.toInt();
            if (pause > 10)
             {
              Serial.println("Length of pause is limited to 10 sec !");
              pause = 10;
             }
            Serial.print("Pause between sending of messages : ");
            Serial.print(pause);
            Serial.println(" sec !");
            dataMode = 1;
          }        
        Serial.flush(); 
        delay(1000);
    }
   }  // end of dataMode = 2
   
  if (dataMode == 3)
   {     
    if (Serial.available() )
      {
       typedMark = Serial.read();  
       Serial.println(" ");
       //Serial.print("Typed: ");
       //Serial.println(typedMark);
       if (typedMark == 66)  // Break
         {
            //ServisOn = true;
            Serial.println("Break and return to basic state  !");
            dataMode = 1;
         }  
        Serial.flush(); 
        delay(1000);
      }
     else
      {
       dataMode = 4;
      }
   }
   
if (dataMode == 4)
   {    
     //analogInput is not used here - this is example only
     //analogInputA0 = analogRead(A0) / 10;
     //analogInputA0 = 87.9;
     /*
     if (analogInputA0 > 100)
      {
       analogInputA0 = 99.9 ;   
      }
     */      
     for (j = 0; j<21; j++) 
           {
            dataToSend[j] = 0;
           }
     nRF.powerUp(); // restart of nRF power
     dataToSend[0] = startOfMessage;
     pres = (HW415.readPressure() + corectPres)/100.00; // measured in Pa - 100 = result in mbar
     delay(500);
     //Serial.print("Pres = "); // for tests only
     //Serial.println(pres);
     temp = myDHT.readTemperature();
     // test of temp validity by function isnan
     if (!isnan(temp))
      { 
        if (temp < 0 )
         {
          dataToSend[1] = '-';
         }
        else
         {
          dataToSend[1] = '+';          
         }
        if (temp > 100)
         {
          temp = 99.9;
          dataToSend[1] = 'o';        // as over  
         }
        int X = temp*10;  // example 231
        int W = X / 100; // 2
        dataToSend[2] = nrToCharBuf[W];
        int V = X - (W*100);   // 31
        int U = V/10;    // 3
        dataToSend[3] = nrToCharBuf[U];
        int Q = V - (U*10);   // 1
        dataToSend[4] = nrToCharBuf[Q];
     }
     else
      {
       dataToSend[1] = 'E';          
       dataToSend[2] = 'E'; 
       dataToSend[3] = 'r'; 
       dataToSend[4] = 'r'; 
      }
     dataToSend[5] = ',';
     hum = myDHT.readHumidity();
     if (!isnan(hum))
      {
     int X = hum*10;  // example 56.8
     int W = X / 100; // 5
     dataToSend[6] = nrToCharBuf[W];
     int V = X - (W*100);   // 68
     int U = V/10;    // 6
     dataToSend[7] = nrToCharBuf[U];
     int Q = V - (U*10);   // 8
     dataToSend[8] = nrToCharBuf[Q];
      }
     else
      {
       dataToSend[6] =  'E'; 
       dataToSend[7] =  'r'; 
       dataToSend[8] =  'r';         
      }
     dataToSend[9] = ',';
     //Serial.println(pres);
     //pres = 1024.89; // test of press range 
     if (pres >= 1000.00)
      {
        dataToSend[10] = '1';
        pres = pres - 1000.00;
      }
     else
      {
        dataToSend[10] = '0'; 
      }
     //Serial.print("Byte 10 = "); // 1 or 0
     //Serial.println(dataToSend[10]);
     unsigned int X = pres / 100; //exaple 567.89 / 100 = 5
     //Serial.print("Byte 11 = "); // 5
     //Serial.println(X);
     dataToSend[11] = nrToCharBuf[X];
     float W = pres - (X * 100); //  67.89
     X = W /10;                   // 6
     //Serial.print("Byte 12 = "); // 6
     //Serial.println(X);
     dataToSend[12] = nrToCharBuf[X];
     W =  W - (X*10);   // 7.89
     unsigned int U = W * 100;    // 789
     unsigned int V = U / 100;                 // 7
     //Serial.print("Byte 13 = "); // 7
     //Serial.println(V);
     dataToSend[13] = nrToCharBuf[V];
     int Q = U - (V*100);   // 89
     V = Q / 10;             // 8
     //Serial.print("Byte 14 = "); // 8
     //Serial.println(V);
     dataToSend[14] = nrToCharBuf[V];
     U = Q - (V*10); // 9
     //Serial.print("Byte 15 = "); // 9
     //Serial.println(U);
     dataToSend[15] = nrToCharBuf[U];
     dataToSend[16] = endMarkOfData;    // end mark of data
     //dataToSend[17] = '2';  //this is for LRC test char nr one of 1 byte  000 to 255
     //dataToSend[18] = '5';  
     //dataToSend[19] = '5';  
     byte parPom = 0;
     byte pLR = 0;
     for (j = 1; j<16; j++)
      {
       parPom = dataToSend[j];
       pLR = pLR + parPom;
      }
     parPom = pLR + 1;
     pLR = parPom;
     X = pLR;  // example 234
     Q = X / 100; // 2 
     dataToSend[17] = nrToCharBuf[Q];
     V = X - (Q*100); // 
     U = V/10;    // 3
     dataToSend[18] = nrToCharBuf[U];      
     Q = V - (U*10);   // 4
     dataToSend[19] = nrToCharBuf[Q];      
     dataToSend[20] = endOfMessage;      // end mark of message
     dataToSend[21] = ' ';
     lengthOfMessage = 22;      // 0 to 20 = 21
     i = 0;
     sendedText = "";
     for (j = 0; j<22; j++)
          {
           //typedMark = dataToSend[j];  
           sendedText = sendedText + dataToSend[j];
           i = i + 1;
          } 
     lengthOfMessage = i;
     if (dataOn == false)
      {
       //Serial.print("Prepared data (text): "); //for tests only
       //Serial.print(sendedText);
       Serial.print(dataToSend);
       Serial.println(" ?");
       //Serial.print("Length of message: ");
       //Serial.println(lengthOfMessage);
      }
     //dataOn = false; 
     dataMode = 5;
  }       // end of dataMode = 4
   
 if (dataMode == 5) 
  {
     //nRF.stopListening();
     nRF.flush_tx(); 
     dataOn = false;
     //nRF.powerUp(); // from previous tests - here not used
     //delay(1000);            
     dataOn = nRF.write( &dataToSend, sizeof(dataToSend) );
     // Always use sizeof() as it gives the size as the number of bytes.
     delay(100);            
     nRF.powerDown();
     if (dataOn == true)
      {
        //Serial.println(" ");
        //Serial.print("Data ");
        Serial.print(dataToSend);
        Serial.println(" *");
       //Serial.println(" were sent ");
      }
     nRF.flush_tx(); 
     timeOfpause = pause * 1000;
     delay(timeOfpause);             
     dataMode = 3;  
  }       //end of dataMode = 5    
}
//====================
//Arduino-NRF24L01-SimpleRx-po-10 telemetry receiver
//Tested with Arduinu NANO clone and NRF24L01+PA+LNA - at first no function
//Tested with Arduino UNO R£ clone - function only with PA-MIN  !!! 
//external VCC 3.3 V is not necessary
//RX with NRF24L01 can read the temperature, humidity and pressure 
//with sensors DHT22 and BMP180 for example
//created by PavelOu on the base of Simple one way transmissmitter and receiver
//by Robin2 from Arduino Forum
//thank you very  much for Dratek.cz for their lectures (in the czech language)
//This RX in pair with program for TX can read a simple telemetry message from a TX to the RX one.
//change of CE_PIN to 7 or 9 and CE_PIN  to 8 or 10 as you are using them in zour schema
//
//SimpleRx-Ronin2.ino
// SimpleRx - the slave as the receiver


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//#define CE_PIN   7
//#define CSN_PIN  8

#define CE_PIN   9
#define CSN_PIN  10

const byte thisSlaveAddress[5] = {'R', 'X', 'S', '0', '1'};
String receiverAddress = "RXS01";   // RX Slave 01

RF24 nRF(CE_PIN, CSN_PIN);

char dataReceived[24]; // this need minimal match to dataToSend length from the TX, 
                       // but longer till 32 one is not very critical
bool newData = false;

String receivedData = "";
int j = 0;

//===========

void setup()
{
  Serial.begin(9600);
  //pinMode(LED_BUILTIN, OUTPUT);
  //digitalWrite(LED_BUILTIN,HIGH);  // turn the LED on (High is the high voltage level)
  delay(1000); //delay for serial lines
  Serial.println(" ");
  Serial.println("SimpleRx with NRF24L01 is starting");
  delay(5000); //delay rise up of for 3.3 V on capacitors
  Serial.println("Arduino-NRF24L01-SimpleRx-po-10");
  nRF.begin();
  nRF.setDataRate( RF24_250KBPS );
  nRF.setPALevel(RF24_PA_MIN); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX) !!!
  nRF.openReadingPipe(1, thisSlaveAddress);
  Serial.print("Receiver ");
  Serial.print(receiverAddress);
  Serial.print(" is on air ... ");
  nRF.startListening();
  delay(1000);
  Serial.println("and ready to receive new messages !");
  nRF.flush_rx();
  //digitalWrite(LED_BUILTIN,LOW);  // turn the LED off (HIGH is high and LOW is the low voltage level)
}

//=============

void loop()
{
  Getdata();
  Showdata();
}

//==============

void Getdata()
{
  dataReceived[0] = 0;
  newData = false;
  if ( nRF.available() ) {
    nRF.read( &dataReceived, sizeof(dataReceived) );
    if (dataReceived[0] > 0)
    {
      newData = true;
      //Serial.println(" ");  //for tests only
      //Serial.print("Readed data: ");
      //Serial.println(receivedData);
      //digitalWrite(LED_BUILTIN,HIGH);  // turn the LED on (High is the high voltage level)
    } 
    else
    {
      //Serial.print("?");  //for tests
      nRF.flush_rx();
      delay(10);
      //delay(1000); //for tests
    }
  }
}

void Showdata()
{
  if (newData == true)
  {
    receivedData = "";
    //Serial.print("Readed data: "); // for tests
    Serial.println(dataReceived);
    for (j = 0; dataReceived[j] > 0; j++)
    {
      receivedData = receivedData + dataReceived[j];
      dataReceived[j] = 0;
    }
    //Serial.print("Received data: "); // for tests
    //Serial.println(receivedData);
    //digitalWrite(LED_BUILTIN,LOW);  // turn the LED off (HIGH is high and LOW is the low voltage level)
  }
  newData = false;
}

An example of printout from Arduino IDE Monitor

22:58:39.014 -> SimpleTx is starting send messages !

22:58:44.027 -> Arduino-NRF-DHTP-SimpleTx-po-23 for PC USB or mobile USB OTG

22:58:44.080 -> Run mode - pause = 4 [sec], Break - Type B

22:58:44.983 -> $+160,398,099558*003## *

22:58:49.897 -> $+166,389,099558*009## *

22:58:54.810 -> $+166,388,099546*005## *

22:58:59.726 -> $+166,387,099558*007## *

22:59:04.639 -> $+166,387,099552*001## *

22:59:09.600 -> $+166,387,099555*004## *

22:59:14.515 -> $+166,387,099553*002## *

22:59:19.428 -> $+167,387,099554*004## *

22:59:23.438 ->

22:59:23.438 -> Break and return to basic state !

22:59:24.441 -> Arduino-NRF-DHTP-SimpleTx-po-23

22:59:24.494 -> Transmitter TXM01 with NRF24L01 is ready for communication !

22:59:24.541 -> End mark of message: #

22:59:24.541 -> For sending messages type T (as TX) !

22:59:24.595 -> Pause is set to : 4 [sec]

22:59:24.642 -> For set of another delay type P (as pause) with x = new delay!

22:59:24.695 -> For end of all actions type B (as Break) !

22:59:25.644 ->

Hello again, I have improoved my ,,design'' of coupled Arduino+NRF+DHT+BMP modules
with adapter HW-200 for NRF24L01 and this one plus PA+LNA module simple via Canon C9M and C9F connectores, so I can simple change this types occasionaly.

This adapter serves as power converter from 5.0 V to 3.3 V for both NRF types and this power is with capacitors more harder for NRFs as Arduino Uno etc. with its 3.3 V .

So I have used this adapter and I pull up the power for NRFs from PA MIN to PA LOW at first and this led immediatelly to increasing of range of possible communication, from the wall of my house for example.

So as there was cold outer, so I could made the test of measuring of temperature under zero .

Of course, my first attempt was bad for tranzit this cold temperature and I need to improve the transform process for this temperature from float to string.

I have now wrote here the reneved code Arduino-NRF-DHTP-SimpleTx-po-26.ino
with this repaired measuring of temperature under zero till 100 grad of Celsius.


//Arduino-NRF-DHTP-SimpleTx-po-26 telemetry sender of temperature, humidity and air press
//finished for the temperature under zero
//and nRF.setPALevel(RF24_PA_LOW);
//-SimpleTx-po-25 - test of measuring and taranslate of negative temperature
//Test of adapter for NRF24L01
//with NRF24L01 or NRF24L01+PA+LNA
//with powerDown and powerUp  for lowering of power consumption
//PC USB or mobile OTG powered application
//with DHT22 for temperature and humidity and BMP180 air pressure for example
//with temperature polarity
//with LRC control
//run mode => dataMode = 3 in setup !!
//it is possible to go to servis mode by typing mark B (Break) with Enter
//created by PavelOu on the base of Simple one way transmission by Robin2
//from Arduino Forum
//thank you very  much for Dratek.cz for their lectures (in the czech language)
//This program send a simple telemetry message from the TX to the RX 
//on the base of SimpleTx-Robin2.ino
//to SimpleRx receiver
//
//SimpleTx - the master sender or the transmitter

// libraries for NRF24L01 (in origial used as radio)
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


//#define CE_PIN   7    // set your pins on the right ones in your schema
//#define CSN_PIN  8
#define CE_PIN   9    // set your pins on the right ones in your schema
#define CSN_PIN  10

const byte slaveAddress[5] = {'R','X','S','0','1'};   //RX Slave 01

RF24 nRF(CE_PIN, CSN_PIN); // Open nRF

//example of a sended message with numbers 0 to 10  (the teen byte is as char 0)
//final example of the sended message
//char dataToSend[20] = {'$','+','1','2','3',',','5','6','7',',','0','9','9','9','9','9','*','P','P','P','#'}; 
//where is :
//+(-)123 is temperature wirh polarity multiplied by 10
//567 is humiditi multiplied by 10
//100178 is presure multiplied to 100
//when BMP180 module is defect, the result is 555 Pa (5.55 mbar)
//PPP is one parity byte (000 to 255) LRC type
//char dataToSend[20];
//example
//char dataToSend[] = {'$','+','1','2','3',',','5','6','7',',','1','0','0','1','9','9','*','P','P','P','#'}; 
char dataToSend[21];
bool dataOn = false;  // true => data was transmitted
     
//library DHT
#include "DHT.h"
//number of pin coupled with DHT sensor
#define pinDHT 5

//set the right type of DHT sensor
//#define typeDHT11 DHT11     // DHT 11
#define typeDHT22 DHT22   // DHT 22 (AM2302)

// inicialisation of DHT sensor with pin and type of sensor
DHT myDHT(pinDHT, typeDHT22);

// Sensor of barometrick presure BMP180
#include <Wire.h>
#include <Adafruit_BMP085.h>
//this librarie use  pins A4 as SDA and A5 = SCL
//inicialisation of  sensor BMP180 on the modul HW-415 from library BMP085
Adafruit_BMP085 HW415;

byte dataMode = 0;
char endOfMessage = '#';
char endMarkOfData = '*';
char startOfMessage = '$';
byte typedMark = 0;
byte lengthOfMessage = 0;
byte pause = 4; // in seconds
unsigned int timeOfpause = 1000;

int j = 0;
int i = 0;

//examples for the float outputs from sensors
//float analogInputA0 = 23.9; //here not used
float temp = 21.7;
float hum = 54.3;
float pres = 1023.87;


// empiric constant for correction by measurig of atmospheric presure in Pascals
int corectPres = 320; // Pa - it is equal 3,2 mbar (1 mbar = 100 Pa )

//table for transcoding the float numbers to characters
char nrToCharBuf[] = {'0','1','2','3','4','5','6','7','8','9'};

String sendedText = "";

void setup() 
  {
    Serial.begin(9600);
    delay(1000); //delay for serial lines
    Serial.flush();
    Serial.println(" ");
    Serial.println("SimpleTx is starting send messages !");
    delay(1000); // delay for rise of voltage 5.0 V for nRF in capacitors cca 250 uF or more
    nRF.begin();
    nRF.setDataRate( RF24_250KBPS );
    //nRF.setRetries(3,5); // delay, count
    // setting of nRF power
    //nRF.setPALevel(RF24_PA_MIN); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX) tested
    nRF.setPALevel(RF24_PA_LOW); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX) 
    //nRF.setPALevel(RF24_PA_HIGH); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX)
    //nRF.setPALevel(RF24_PA_MAX); //(RF24_PA_MIN|RF24_PA_LOW|RF24_PA_HIGH|RF24_PA_MAX)
    nRF.openWritingPipe(slaveAddress);
    nRF.powerDown();
    dataOn = true;
    sendedText = "";
    i = 0;            
    //Serial.print("dataToSend declared :"); // for tests only
    //Serial.println(dataToSend);
    //Test of sended data format
    //Serial.print("dataToSend filled with spaces (a) : ");
    //Serial.println("*");
    //Serial.print("dataToSend filled with spaces (b): ");
    //Serial.print(sendedText);
    //Serial.println("*");
    //Serial.print("dataToSend filled with spaces (c): ");
    //Serial.print(dataToSend);
    //Serial.println("*");
    
    //set communication with modul DHT
    myDHT.begin();
    // start of communication with sensor BMP180
    HW415.begin(); // name of module with BMP180
    //dataMode = 1; //servis version
    dataMode = 3; //run version
    if (dataMode == 3)
     {
      Serial.println("Arduino-NRF-DHTP-SimpleTx-po-26 for PC USB or mobile USB OTG");
      Serial.print("Run mode - pause = ");
      Serial.print(pause);
      Serial.println(" [sec], Break - Type B");
     }
  }

//================


void loop()
 {
  //Servis part of this program is in run mode not used 
  if (dataMode == 1)
   {
     Serial.println("Arduino-NRF-DHTP-SimpleTx-po-26");
     Serial.println("Transmitter TXM01 with NRF24L01 is ready for communication !");
     Serial.print("End mark of message: ");
     Serial.println(endOfMessage);                                
     Serial.println("For sending messages type T (as TX) !");
     Serial.print("Pause is set to : ");
     Serial.print(pause);
     Serial.println(" [sec]");
     Serial.println("For set of another delay type P (as pause) with x = new delay!");
     Serial.println("For end of all actions type B (as Break) !");
     delay(1000);
     dataOn = true;
     dataMode = 2;
     nRF.powerDown();
   }       // end of dataMode = 1
   
  if (dataMode == 2)
   {     
    if (Serial.available() )
      {
       typedMark = Serial.read();  
       Serial.println(" ");
       //Serial.print("Typed: ");
       //Serial.println(typedMark);
       if (typedMark == 84)        // T = transmission
          {
           dataMode = 3;
           dataOn = true;
           Serial.println("TX - Station will send messages !");
          }
        if ( typedMark == 80 )   // P
          {
            String Pstring = Serial.readString();
            Pstring.trim();
            pause = Pstring.toInt();
            if (pause > 10)
             {
              Serial.println("Length of pause is limited to 10 sec !");
              pause = 10;
             }
            Serial.print("Pause between sending of messages : ");
            Serial.print(pause);
            Serial.println(" sec !");
            dataMode = 1;
          }        
        Serial.flush(); 
        delay(1000);
    }
   }  // end of dataMode = 2
   
  if (dataMode == 3)
   {     
    if (Serial.available() )
      {
       typedMark = Serial.read();  
       Serial.println(" ");
       //Serial.print("Typed: ");
       //Serial.println(typedMark);
       if (typedMark == 66)  // Break
         {
            //ServisOn = true;
            Serial.println("Break and return to basic state  !");
            dataMode = 1;
         }  
        Serial.flush(); 
        delay(1000);
      }
     else
      {
       dataMode = 4;
      }
   }
   
if (dataMode == 4)
   {    
     //analogInput is not used here - this is example only
     //analogInputA0 = analogRead(A0) / 10;
     //analogInputA0 = 87.9;
     /*
     if (analogInputA0 > 100)
      {
       analogInputA0 = 99.9 ;   
      }
     */      
     for (j = 0; j<21; j++) 
           {
            dataToSend[j] = 0;
           }
     nRF.powerUp(); // restart of nRF power
     dataToSend[0] = startOfMessage;
     pres = (HW415.readPressure() + corectPres)/100.00; // measured in Pa - 100 = result in mbar
     delay(500);
     //Serial.print("Pres = "); // for tests only
     //Serial.println(pres);
     temp = myDHT.readTemperature();
     if (isnan(temp))
          { 
          dataToSend[1] = 'E';          
          dataToSend[2] = 'E'; 
          dataToSend[3] = 'r'; 
          dataToSend[4] = 'r';
          goto IsnanTemp;
         }
     if (temp == 0)
         {
          dataToSend[1] = '+';          
          dataToSend[2] = '0';
          dataToSend[3] = '0';
          dataToSend[4] = '0'; 
          goto IsnanTemp;
         }
     //Serial.print("temp measured : ");
     //Serial.println(temp);
     // test of temp validity by function isnan
     //temp = -1.3 ;  // test of negativa temperature 
     //Serial.print("temp tested : ");
     //Serial.println(temp);
     float tempminusone = -1.00;
     if (temp < 0 )
         {
          dataToSend[1] = '-';
          temp = (temp*tempminusone);
          //Serial.print("temp reversed : ");
          //Serial.println(temp);
         }
        else
         {
          dataToSend[1] = '+';          
         }
     if (temp > 100)
         {
          temp = 99.9;
          dataToSend[1] = 'o';        // as over  
         }
     int X = temp*10;  // example 231
     int W = X / 100; // 2
     dataToSend[2] = nrToCharBuf[W];
     int V = X - (W*100);   // 31
     int U = V/10;    // 3
     dataToSend[3] = nrToCharBuf[U];
     int Q = V - (U*10);   // 1
     dataToSend[4] = nrToCharBuf[Q];
   IsnanTemp:  
     dataToSend[5] = ',';
     hum = myDHT.readHumidity();
     if (!isnan(hum))
      {
        X = hum*10;  // example 56.8
        W = X / 100; // 5
        dataToSend[6] = nrToCharBuf[W];
        V = X - (W*100);   // 68
        U = V/10;    // 6
        dataToSend[7] = nrToCharBuf[U];
        Q = V - (U*10);   // 8
        dataToSend[8] = nrToCharBuf[Q];
      }
     else
      {
       dataToSend[6] =  'E'; 
       dataToSend[7] =  'r'; 
       dataToSend[8] =  'r';         
      }
     dataToSend[9] = ',';
     //Serial.println(pres);
     //pres = 1024.89; // test of press range 
     if (pres >= 1000.00)
      {
        dataToSend[10] = '1';
        pres = pres - 1000.00;
      }
     else
      {
        dataToSend[10] = '0'; 
      }
     //Serial.print("Byte 10 = "); // 1 or 0
     //Serial.println(dataToSend[10]);
     X = pres / 100; //exaple (987.69 / 100 = 9
     //Serial.print("Byte 11 = "); // 9
     //Serial.println(X);
     dataToSend[11] = nrToCharBuf[X];
     float WR = pres - (X * 100); //  87.69
     X = WR /10;                   // 8
     //Serial.print("Byte 12 = "); // 8
     //Serial.println(X);
     dataToSend[12] = nrToCharBuf[X];
     WR =  WR - (X*10);   // 7.69
     U = WR * 100;    // 769
     V = U / 100;                 // 7
     //Serial.print("Byte 13 = "); // 7
     //Serial.println(V);
     dataToSend[13] = nrToCharBuf[V];
     Q = U - (V*100);   // 69
     V = Q / 10;             // 6
     //Serial.print("Byte 14 = "); // 6
     //Serial.println(V);
     dataToSend[14] = nrToCharBuf[V];
     U = Q - (V*10); // 9
     //Serial.print("Byte 15 = "); // 9
     //Serial.println(U);
     dataToSend[15] = nrToCharBuf[U];
     dataToSend[16] = endMarkOfData;    // end mark of data
     //dataToSend[17] = '2';  //this is for LRC test char nr one of 1 byte  000 to 255
     //dataToSend[18] = '5';  
     //dataToSend[19] = '5';  
     byte parPom = 0;
     byte pLR = 0;
     for (j = 1; j<16; j++)
      {
       parPom = dataToSend[j];
       pLR = pLR + parPom;
      }
     parPom = pLR + 1;
     pLR = parPom;
     X = pLR;  // example 234
     Q = X / 100; // 2 
     dataToSend[17] = nrToCharBuf[Q];
     V = X - (Q*100); // 
     U = V/10;    // 3
     dataToSend[18] = nrToCharBuf[U];      
     Q = V - (U*10);   // 4
     dataToSend[19] = nrToCharBuf[Q];      
     dataToSend[20] = endOfMessage;      // end mark of message
     dataToSend[21] = ' ';
     lengthOfMessage = 22;      // 0 to 20 = 21
     i = 0;
     sendedText = "";
     for (j = 0; j<22; j++)
          {
           //typedMark = dataToSend[j];  
           sendedText = sendedText + dataToSend[j];
           i = i + 1;
          } 
     lengthOfMessage = i;
     if (dataOn == false)
      {
       //Serial.print("Prepared data (text): "); //for tests only
       //Serial.print(sendedText);
       Serial.print(dataToSend);
       Serial.println(" ?");
       //Serial.print("Length of message: ");
       //Serial.println(lengthOfMessage);
      }
     //dataOn = false; 
     dataMode = 5;
  }       // end of dataMode = 4
   
 if (dataMode == 5) 
  {
     //nRF.stopListening();
     nRF.flush_tx(); 
     dataOn = false;
     //nRF.powerUp(); // from previous tests - here not used
     //delay(1000);            
     dataOn = nRF.write( &dataToSend, sizeof(dataToSend) );
     // Always use sizeof() as it gives the size as the number of bytes.
     delay(100);            
     nRF.powerDown();
     if (dataOn == true)
      {
        //Serial.println(" ");
        //Serial.print("Data ");
        Serial.print(dataToSend);
        Serial.println(" *");
       //Serial.println(" were sent ");
      }
     nRF.flush_tx(); 
     timeOfpause = pause * 1000;
     delay(timeOfpause);             
     dataMode = 3;  
  }       //end of dataMode = 5    
}
//====================