Go Down

Topic: Sensing, Transmit and Receive data by using nRF24L01 (Read 609 times) previous topic - next topic

DecepticonDog13

Hi there!
I am a newbie in Arduino, and I kinda have a problem.
Recently, I have started a project that uses Arduino Uno and its sensors to measure temperature and humidity, and transmit the data from an arduino to another. The problem I encounter now is that I cannot receive the data from the uno.

Here is the code for transmission uno:

Code: [Select]


#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
#include <dht.h>

dht DHT;            // sensing unit
#define DHT11_PIN 8

RF24 radio(9,10);   // transmit unit
const byte address[6] = "00001";

void setup() {
  // first, setup communication
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
}

void loop() {
  // humidNtemp execution:
    delay(1000);
    radio.stopListening();
    int SensorValue = DHT.read11(DHT11_PIN);
    radio.write(&SensorValue, sizeof(SensorValue));



And here is the code for receive uno:

Code: [Select]


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

 RF24 radio(9,10);
 const byte address[6] = "00001";

 void setup() {
  // setup screen:
   Serial.begin(9600);
   radio.begin();
   radio.openReadingPipe(0, address);
   radio.setPALevel(RF24_PA_MIN);
}

 void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
  radio.startListening();
  if (radio.available()) {
    while (radio.available()) {
      int SensorV = 0;
      radio.read(&SensorV, sizeof(SensorV));
      Serial.print("Temperature = ");
      Serial.println(SensorV);
      Serial.print("Humidity = ");
      Serial.println(SensorV);
      delay(1000);
    }
  }



I'm pretty sure that the program has mistakes, here and there. I am not sure where and how to encounter it. I have use quite a number of reference and codes to make it work, but I don't know. So, if anyone who read this post, can you please help me? I appreciate your kindness. Thank you.


AWOL

Please don't waste time looking for this post's twin - I deleted it.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

DecepticonDog13


AWOL

Why? What's wrong? Did I make any mistakes?
You posted the same question in different parts of the forum. (That answers all three of your questions)
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

DecepticonDog13

#4
Jul 03, 2018, 11:01 am Last Edit: Jul 03, 2018, 11:06 am by DecepticonDog13
Anyhow, I tried to approach to the community as humble as I can, because I really new in this thing. I thought that if I post more than one, people would have the chance to see it.

AWOL

I thought that if I post more than one, people would have the chance to see it.
...the practical flip-side of which, is that more people will waste their time.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

DecepticonDog13

Owhh. Alright. Sorry in advance.
Anyhow, can you help me with this thingy?

cattledog


Go Up