UNO + NRF24L01 + DHT11 problem

I m not good at java C. There are the code from the internet, it completely matched with the hardware no bugs, errors, library imported. I have test the hardware with the sample code from the arduino library, it’s work on the ping client and server and sensors. However i cannot receive and transfer any data in the serial monitor. PLZ HELP me to combine the DHT11 and NRF24L01 code. Thank you very much!!!

http://arduino-info.wikispaces.com/nRF24L01-Mirf-Examples

Wiring
Nrf24L01 GND ¡V GND, VCC ¡V 3.3V, CS ¡V D8, CSN ¡V D9, SCK ¡V D10, MOSI ¡V D11, MISO ¡V D12, IRQ ¡V D13
DHT11 GND ¡V GND, VCC ¡V 3.3V, Data ¡V A0

Problems:

-Nrf24L01 cannot communication
-Nrf24L01 + DHT11 combine problem

-Is there any missing or config that i need?

Receive:

#include <Mirf.h>
#include <MirfHardwareSPIDriver.h>
#include <MirfSPIDriver.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>

void setup()
{
  Serial.begin(57600);
  
  Mirf.init();
  
  // name the receiving channel - must match tranmitter setting!
  Mirf.setRADDR((byte *)"TX_01");
  
  // just a single byte is transmitted
  Mirf.payload = 1;

  // we use channel 90 as it is outside of WLAN bands 
  // or channels used by wireless surveillance cameras 
  Mirf.channel = 90;
  
  // now config the device.... 
  Mirf.config();  
  
  // Set 1MHz data rate - this increases the range slightly
  Mirf.configRegister(RF_SETUP,0x06);
}

void loop()
{

  byte c; 

  // is there any data pending? 
  if( Mirf.dataReady() )
  {
     // well, get it
     Mirf.getData(&c);

    // ... and write it out to the PC
     Serial.print(c);
  }
}

Sensor:

#include <Mirf.h>
#include <MirfHardwareSpiDriver.h>
#include <MirfSpiDriver.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>

// converts a float into a char 
// and sends it via nRF24L01
void transmit( float v)
{
  byte c; 
  char buf[10];
  
  dtostrf(v,9,3,buf);

  for( int i=0 ; i<8 ; i++ )
  { 
    c = buf[i];
    Mirf.send(&c);
    while( Mirf.isSending() ) ;
  }
}

// sends a string via the nRF24L01
void transmit(const char *string)
{
  byte c; 
  
  for( int i=0 ; string[i]!=0x00 ; i++ )
  { 
    c = string[i];
    Mirf.send(&c);
    while( Mirf.isSending() ) ;
  }
}

// send a CR/LF sequence via the nRF24L01
void transmitlf(void)
{
  byte c;
  
  c = '\r';
  Mirf.send(&c);
    while( Mirf.isSending() ) ;
  
  c = '\n';
  Mirf.send(&c);
    while( Mirf.isSending() ) ;
}

void setup()
{
  
  // init the transceiver
  Mirf.init();
  
  // we transmit only a single byte each time
  Mirf.payload = 1;
  
  // selecting a channel which is not too noisy
  Mirf.channel = 90;
  Mirf.config();
 
  // Set 1MHz data rate
  Mirf.configRegister(RF_SETUP,0x06);
  
  // Set address - this one must match the 
  // address the receiver is using!
  Mirf.setTADDR((byte *)"TX_01");
}

void loop() 
{
  float v01,v02; 
  
  // read in some values
  v01 = analogRead(0);
  v02 = analogRead(1);
  
  // transmit a fixed token
  transmit(" : ");
  
  // transmit the first value
  transmit(v01);
  
  // transmit a separator
  transmit(" : ");
  
  // transmit a second token
  transmit(v02);
  
  // transmit a CR/LF for the PC
  // software to sync to
  transmitlf();
 
  // ... just take your time
  delay(100);
}

DHT11

#define dht_dpin 14 


byte bGlobalErr;//for passing error code back from complex functions.
byte dht_dat[4];//Array to hold the bytes sent from sensor.

void setup(){
  InitDHT();//Do what's necessary to prepare for reading DHT
  Serial.begin(9600);
  delay(300);//Let system settle
  Serial.println("Humidity and temperature\n\n");
  delay(700);//Wait rest of 1000ms recommended delay before
  //accessing sensor
}//end "setup()"

void loop(){
  ReadDHT();//This is the "heart" of the program.
    switch (bGlobalErr){
  case 0:
    Serial.print("Current humdity = ");
    Serial.print(dht_dat[0], DEC);
    Serial.print(".");
    Serial.print(dht_dat[1], DEC);
    Serial.print("%  ");
    Serial.print("temperature = ");
    Serial.print(dht_dat[2], DEC);
    Serial.print(".");
    Serial.print(dht_dat[3], DEC);
    Serial.println("C  ");
    break;
  case 1:
    Serial.println("Error 1: DHT start condition 1 not met.");
    break;
  case 2:
    Serial.println("Error 2: DHT start condition 2 not met.");
    break;
  case 3:
    Serial.println("Error 3: DHT checksum error.");
    break;
  default:
    Serial.println("Error: Unrecognized code encountered.");
    break;
  }//end "switch"
  delay(800);//Don't try to access too frequently... in theory
}// end loop()

/*Below here: Only "black box" elements which can just be plugged unchanged
 unchanged into programs. Provide InitDHT() and ReadDHT(), and a function
 one of them uses.*/

void InitDHT(){
       if (dht_dpin-14 != dht_PIN){Serial.println("ERROR- dht_dpin must be 14 more than dht_PIN");};//end InitDHT
  pinMode(dht_dpin,OUTPUT);// replaces DDRC... as long as dht_dpin=14->19
  digitalWrite(dht_dpin,HIGH);//Replaces PORTC |= if dht_pin=14->19
}//end InitDHT

void ReadDHT(){
   bGlobalErr=0;
  byte dht_in;
  byte i;
  // Send "start read and report" command to sensor....
  // First: pull-down i/o pin for 18ms
  digitalWrite(dht_dpin,LOW);//Was: PORTC &= ~_BV(dht_PIN);
  delay(18);
  delay(5);//TKB, frm Quine at Arduino forum
    digitalWrite(dht_dpin,HIGH);//Was: PORTC |= _BV(dht_PIN);
  delayMicroseconds(40);//DHT22 datasheet says host should
    pinMode(dht_dpin,INPUT);//Was: DDRC &= ~_BV(dht_PIN);
  delayMicroseconds(40);

  dht_in=digitalRead(dht_dpin);//Was: dht_in = PINC & _BV(dht_PIN);

  if(dht_in){
    bGlobalErr=1; //Was: Serial.println("dht11 start condition 1 not met");
    return;
  }//end "if..."
  delayMicroseconds(80);

  dht_in=digitalRead(dht_dpin);//Was: dht_in = PINC & _BV(dht_PIN);

  if(!dht_in){
    bGlobalErr=2;//Was: Serial.println("dht11 start condition 2 not met");
    return;
  }//end "if..."

   delayMicroseconds(80);
  for (i=0; i<5; i++)
    dht_dat[i] = read_dht_dat();

    pinMode(dht_dpin,OUTPUT);//Was: DDRC |= _BV(dht_PIN);

    digitalWrite(dht_dpin,HIGH);//Was: PORTC |= _BV(dht_PIN);

    byte dht_check_sum =
    dht_dat[0]+dht_dat[1]+dht_dat[2]+dht_dat[3];
  /*Condition in following "if" says "if fifth byte from sensor
   not the same as the sum of the first four..."*/
  if(dht_dat[4]!= dht_check_sum)
  {
    bGlobalErr=3;
  }
};
byte read_dht_dat(){

  byte i = 0;
  byte result=0;
  for(i=0; i< 8; i++){
       while(digitalRead(dht_dpin)==LOW);//Was: while(!(PINC & _BV(dht_PIN)));
      delayMicroseconds(30);//AFTER pin is high, wait further period, to be

    if (digitalRead(dht_dpin)==HIGH)//Was: if(PINC & _BV(dht_PIN))
      result |=(1<<(7-i));// "add" (not just addition) the 1
      while (digitalRead(dht_dpin)==HIGH);//Was: while((PINC & _BV(dht_PIN)));
  }//end of "for.."
  return result;
}//end of "read_dht_dat()"

I m not good at java C.

Nobody is. Java and C (and C++ and Fortran and C# and Pascal and Cobol and many others) are different programming languages.

The problem is nothing show at serial monitor by the Receive code,

Code:

#include <Mirf.h>
#include <MirfHardwareSPIDriver.h>
#include <MirfSPIDriver.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>

void setup()
{
  Serial.begin(57600);
  
  Mirf.init();
  
  // name the receiving channel - must match tranmitter setting!
  Mirf.setRADDR((byte *)"TX_01");
  
  // just a single byte is transmitted
  Mirf.payload = 1;

  // we use channel 90 as it is outside of WLAN bands 
  // or channels used by wireless surveillance cameras 
  Mirf.channel = 90;
  
  // now config the device.... 
  Mirf.config();  
  
  // Set 1MHz data rate - this increases the range slightly
  Mirf.configRegister(RF_SETUP,0x06);
}

void loop()
{

  byte c; 

  // is there any data pending? 
  if( Mirf.dataReady() )
  {
     // well, get it
     Mirf.getData(&c);

    // ... and write it out to the PC
     Serial.print(c);
  }
}

]

PaulS: Nobody is.

I have to correct you there; I'm highly proficient at writing Java C. Unfortunately, compilers usually object strenuously when asked to compile it.

I have to correct you there; I'm highly proficient at writing Java C. Unfortunately, compilers usually object strenuously when asked to compile it.

OK. You got me there.

Seems like incorrect connection. Hardware SPI: * Radio MO -> Arduino pin 11 (MOSI) * Radio MI -> Arduino pin 12 (MISO) * Radio SCK-> Arduino pin 13 (SCK) ..forget IRQ-pin CE and CSN selectable to any pin 2..10, 14..19 (pin14=analogPin0) (leave pin 0 and 1 for selial comm) // defalt values are // Mirf.csnPin = 7; // Mirf.cePin = 8;