noob help for nrf24l01

This is my 1st post, so forgive if a violate any standards.

Hello here on the forum i have a bit of a problem with my code.

i have two arduino mega, setup as one mega as a receiver and a second one mega as a sender, i have had everything working, but suddenly, when i expanded my code, the transmission stopped working, i have now. commented out alot of code, and cooked it down to the code below, and know it just some times recieves trasmission from the sender, but it seems only just at startup of the sender.

And i can't figure out why.

if someone could explain it very precisely what, it is i am doing wrong, i would really appreciate it.

PS. Sorry for my bad english, english is not my first language.

time-and-temp-and-nrf24Sender-2-mega-virkerm_ske.ino (12.2 KB)

mega_nrf24-soft-ethernet-receiver_test.ino (17.6 KB)

+1 , added to make fav.

Hope you can get solution.

Hello, could you please make your code in the appropriate form (use this and put your code there) so that other people can see your code easily !

Sorry but i tried to post the code, but th forum said it was to big and would not let me post it.

i have figured out that if i comment out my temp measurement it can transmit hmmm

//loop start  
/*
  myData.temp = temp(DHTPIN);
  DHTPIN = 3;
  myData.humid = humid(DHTPIN);
  
  DHTPIN = 2;
  myData.humidOut = humid(DHTPIN);
  DHTPIN = 3;
  myData.tempOut = temp(DHTPIN);
  
  DHTPIN = 2;

  */
//Loop end

double temp(int DHTPIN)
{
  DHT dht(DHTPIN, DHTTYPE);
  dht.begin();
    // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  delay(50);
return t;
  }

  double humid(int DHTPIN)
{
  DHT dht(DHTPIN, DHTTYPE);
  dht.begin();
    // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();

  // Check if any reads failed and exit early (to try again).
  if (isnan(h)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  delay(50);
return h;
  }

wackot:
when i expanded my code, the transmission stopped working, i have now. commented out alot of code, and cooked it down to the code below, and know it just some times recieves trasmission from the sender, but it seems only just at startup of the sender.

And i can't figure out why.

I have not looked at your code beyond noticing that you are using the ManiacBug RF24 library. When I tried that I found that it does not like long intervals between messages and maybe when you extended your code it increased the interval a little too much.

I suggest you use the newer TMRh20 version of the RF24 library which solves some problems from the earlier ManiacBug version. Unfortunately TMRh20 did not think to change the name for his version so it is easy to get them confused. If in doubt I suggest you delete the library completely and then download and install the TMRh20 version. There are one or two changes in the library that may require a small amendment to your code.

...R
Simple nRF24L01+ Tutorial

Thanks for helping Robin2

but the reason i use the ManiacBug RF24 library is because i use a modifiet version of it, that lets me use soft spi so that i also can use my ethernet card.

but that info can help me problem solve or figure another way to do it :smiley:

Hi Robin2

i have just gone a step deeper ind the tmrh20 and i seemt they now have made it possible to self define miso, mosi and clk. and when i now use that library i seems to run pretty smooth. thanks for the help and hint. :smiley: