نقل قول نوشته اصلی توسط d3lphi نمایش پست ها
من از یک Arduino Pro Mini که به یک سنسور دما و رطوبت DHT 22 متصل است استفاده کردم. طرف دیگه یک آردینو Uno بود که مقادیر رو دریافت می کنه و روی یک Liquid Crystal نمایش میده. با همه ماژول های NRF که 8 پایه هستند تست کردم و با همشون به خوبی کار میکنه.

کد ارسال:
کد:
/* YourDuinoStarter Example: nRF24L01 Transmit Joystick values
 - WHAT IT DOES: Reads Analog values on A0, A1 and transmits
   them over a nRF24L01 Radio Link to another transceiver.
 - SEE the comments after "//" on each line below
 - CONNECTIONS: nRF24L01 Modules See:
 http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 9
   4 - CSN to Arduino pin 10
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED
   - 
   Analog Joystick or two 10K potentiometers:
   GND to Arduino GND
   VCC to Arduino +5V
   X Pot to Arduino A0
   Y Pot to Arduino A1
   
 - V1.00 11/26/13
   Based on examples at http://www.bajdi.com/
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include "DHT.h"
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10
//#define JOYSTICK_X A0
//#define JOYSTICK_Y A1
#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int data[3];  // 2 element array holding Joystick readings

DHT dht(DHTPIN, DHTTYPE);
void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  dht.begin();
   
  
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  //joystick[0] = analogRead(JOYSTICK_X);
  //joystick[1] = analogRead(JOYSTICK_Y);

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  data[0] = 1;
  data[1] = 100;//h;
  data[2] = 200;//t;
  
  radio.write( data, sizeof(data) );
  //delay(1000);
}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//NONE
//*********( THE END )***********
کد دریافت
کد:
/* YourDuinoStarter Example: nRF24L01 Receive Joystick values

 - WHAT IT DOES: Receives data from another transceiver with
   2 Analog values from a Joystick or 2 Potentiometers
   Displays received values on Serial Monitor
 - SEE the comments after "//" on each line below
 - CONNECTIONS: nRF24L01 Modules See:
 http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
   1 - GND
   2 - VCC 3.3V !!! NOT 5V
   3 - CE to Arduino pin 9
   4 - CSN to Arduino pin 10
   5 - SCK to Arduino pin 13
   6 - MOSI to Arduino pin 11
   7 - MISO to Arduino pin 12
   8 - UNUSED
   
 - V1.00 11/26/13
   Based on examples at http://www.bajdi.com/
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display


/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN   9
#define CSN_PIN 10

// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe


/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int data[3];  // 2 element array holding Joystick readings

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();;
  
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  if ( radio.available() )
  {
    // Read the data payload until we've received everything
    bool done = false;
    while (!done)
    {
      // Fetch the data payload
      done = radio.read( data, sizeof(data) );
      //Serial.print("H = ");
      //Serial.print(data[1]);
      //Serial.print(" T = ");      
      //Serial.println(data[2]);
      lcd.clear();

      lcd.setCursor(0,0);
      lcd.print("Channel: ");
      lcd.print(data[0]);
      
      lcd.setCursor(0,1);
      
      lcd.print("H: ");
      lcd.print(data[1]);
      lcd.print(" T: ");
      lcd.print(data[2]);

      delay(500);
    }
  }
  else
  {    
      //Serial.println("No radio available");
      lcd.clear();
      lcd.print("No radio available");
      delay(500);
  }

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/

//NONE
//*********( THE END )***********
دلفی جان با چندتا dht تست کردی؟ واضح بهت بگم دیتا لاگر بیسیم دیگه..من الان یه دستگاه دارم که چندتا dht با چندین متر سیم رو میخونه..میتونم با این ماژول یه شبکه ستاره ای درست کنم؟از دست این صد متر سیم راحت شم!