Teensy with 4 or 5 wireless temperature sensors

Status
Not open for further replies.
No Data sent in serial ?
Also if you have no delay in the loop this will run continously ... I would add either a long delay or let the transmissions happend at certain second (based on currentMillis).

Look at the TX and RX example on https://forum.arduino.cc/index.php?topic=421081
They use currentMillis as a trigger to send data ever X milliseconds.
 
hmmm I trie dthe TX exmaple as suggested.

Still got TX failed msg in Serial.

But accidently disconnected teh SCK pin from board (aka D13 on Nano) & it suddenly changed to Acknowledge Recieved
 
Off the top of my head, you are sending a float into println() and getting "NaN".

Try using Serial.printf("Sent temperature: %f\n", SENT_temperature). That way, you can eliminate "is println() correctly figuring out what I'm asking?" from what could be happening. I vaguely remember that there are cases where you have to use printf() with a format string because println() will not figure it out.

The float value probably is "not a number" (which is a supported value for floats), which would indicate that the library either didn't receive anything - or did, but couldn't make sense of it (timing issue, running at the wrong speed, some configuration isn't right, etc.)
 
OK

I got really frustrated with all this and took it right back to basics.

Now my board literally just has the NRF24L01+ connected.
And I loaded the GETTINGSTART project that comes with NRL24 library - just to see if I could get one of these things to talk to itself.

BTW - I had to change the include part from:

Code:
#include "RF24.h"
as it wouldnt compile.

I also changed teh data being sent to a String.

Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 0;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7, 8);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 1;

void setup() {
  Serial.begin(9600);
  Serial.println(F("RF24/examples/GettingStarted"));
  Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
  
  radio.begin();

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  radio.setDataRate(RF24_2MBPS);
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
/****************** Ping Out Role T ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.

    Serial.println(F("----------------------------------------------"));
    Serial.println(F("Now sending Data"));

    unsigned long start_time = micros();   
    String Astart_time = "HELP"; // Take the time, and send it.  This will block until complete
     if (!radio.write( &Astart_time, sizeof(Astart_time) ))
     {
       Serial.println(F("Write failed"));
     }
     else
     {
      Serial.println(F("**** Write SUCCEEDED ****"));
     }
        
    radio.startListening();                                    // Now, continue listening
    
    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
    
    while ( ! radio.available() ) // While nothing is received
    {                             
      if (micros() - started_waiting_at > 200000 )    // If waited longer than 200ms, indicate timeout and exit while loop
      {            
          timeout = true;
          break;
      }      
    }
        
    if ( timeout )
    {                                             // Describe the results
        Serial.println(F("Failed, response timed out."));
    }else
    {
        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
        String Agot_time;
        radio.read( &Agot_time, sizeof(got_time) );
        unsigned long end_time = micros();
        
        // Spew it
        Serial.print(F("Tx: "));
        Serial.println(Astart_time);
        Serial.print(F("Rx: "));
        Serial.println(Agot_time);
        Serial.print(F("Round-trip delay "));
        Serial.print(end_time-start_time);
        Serial.println(F(" micros"));
        Serial.println("");
    }

    // Try again 1s later
    delay(1000);
  }
/****************** Pong Back Role R ***************************/
  if ( role == 0 )
  {
    unsigned long got_time;
    
    if( radio.available()){                                                   // Variable for the received timestamp
      while (radio.available()) 
      {                                                             // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
      }
     
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      Serial.print(F("Sent response "));
      Serial.println(got_time);  
   }
 }
/****************** Change Roles via Serial Commands ***************************/
  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == 0 ){      
      Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
      role = 1;                  // Become the primary transmitter (ping out)
    
   }else
    if ( c == 'R' && role == 1 ){
      Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));      
       role = 0;                // Become the primary receiver (pong back)
       radio.startListening();
    }
  }
} // Loop

Still can't get it working.
I set the code to run in TRANSMIT mode.

and here's what i get on the Serial:

PHP:
Now sending Data
Write failed
Tx: HELP
Rx: 
Round-trip delay 95681 micros

ie nothing Rx'd.

Then I physically picked the project up by teh wires & noticed the serial chnaged to :

PHP:
Now sending Data
**** Write SUCCEEDED ****
Tx: HELP
Rx: 
Round-trip delay 14847 micros

ie the Write now succeeds but still nothing is recieved.

By trial & error I found I can replicate this by literally just lightly touching the SPI wires OR putting my fingers around the whole wire bundle WITHOUT touching then.

No idea whats going on here - any one ideas pls.

BTW get the same thing with a Teensy 3.2, 3.6 and a clone Nano.
 
DOH!!!
Now dont I just feel stupid (again).
Maybe thsi RF stuff is just a step too far for me.

I did think it was strange.
But I thought the switching was being done in the code - to send as a Tx then switch to recieve as a Rx.
All teh other examples I seen explicity called out seperate code for teh Tx & Rx.

Will hook up a 2nd one again & give it another try - thanks.

BTW any idea on the behaviour I mentioned with wrapping my fingers arund the cables?
 
Yes you can switch roles in the code but ... you need to go back in time first to be able to receive the data you just had sent ;)

Your fingers and cables could be that there is a lot of static around or so. How long are your cables ? I never used cables on these and mounted them on a perfboard very close to the MCU.
 
When I work on things that are new to me I tend to remember a quote from a danish mathematician:

The road to wisdom? — Well, it's plain
and simple to express:
Err
and err
and err again
but less
and less
and less.
 
thanks.

I'm using short cables as still working at breadboard stage.
wires are 100mm max.

Got 2 modules running now.
But still can get data to be recieved
 
Have you tried this advice "It is recommended to plce a 10µF capacitor across VCC and GND"
And furthermore, your measured all the connections ? No broken wires/disconnected breadboard points ?
 
What is the significance of this?
Code:
// Set the PA Level low to prevent power supply related issues since this is a
// getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
radio.setPALevel(RF24_PA_LOW);
 
What is the significance of this?
Code:
// Set the PA Level low to prevent power supply related issues since this is a
// getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
radio.setPALevel(RF24_PA_LOW);

The lines above the code state the logic behind it. When you are testing devices you dont need to use the maximum power, doing so reduces the power needed to send data and thus also reduces (possible) issues due to an unstable power-supply. The other advice (to mount a 10uF close to the nRF24L01 over VCC/GND) is probably related to these type of issues.

In my setup (as stated before using TI MSP430 chips) I have never had to do this, but using other MCUs things might work different.
 
And you also tried the suggestion I made in message #38 ?

I did yes - no luck either.

I'm currently trying solder Nano & Radio unit onto a small perf board.

WIll report back what that yeilds.

Thanks for your continued support & help.
 
What was the output of the testconnection.ino ?


This what im now getting with a single project on a perf board:

13:31:38.454 -> CheckConnection Starting
13:31:38.454 ->
13:31:38.454 -> FIRST WITH THE DEFAULT ADDRESSES after power on
13:31:38.554 -> Note that RF24 does NOT reset when Arduino resets - only when power is removed
13:31:38.601 -> If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
13:31:38.702 -> communicating with the nRF24
13:31:38.755 ->
13:31:38.755 -> SPI Speedz = 10 Mhz
13:31:38.755 -> STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
13:31:38.855 -> RX_ADDR_P0-1 = 0xe7e7e7e7e7 0x4141417852
13:31:38.855 -> RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
13:31:38.902 -> TX_ADDR = 0xe7e7e7e7e7
13:31:38.956 -> RX_PW_P0-6 = 0x00 0x20 0x00 0x00 0x00 0x00
13:31:38.956 -> EN_AA = 0x3f
13:31:39.003 -> EN_RXADDR = 0x02
13:31:39.003 -> RF_CH = 0x4c
13:31:39.056 -> RF_SETUP = 0x07
13:31:39.056 -> CONFIG = 0x0e
13:31:39.056 -> DYNPD/FEATURE = 0x00 0x00
13:31:39.103 -> Data Rate = 1MBPS
13:31:39.103 -> Model = nRF24L01+
13:31:39.156 -> CRC Length = 16 bits
13:31:39.156 -> PA Power = PA_MAX
13:31:39.156 ->
13:31:39.203 ->
13:31:39.203 -> AND NOW WITH ADDRESS AAAxR 0x41 41 41 78 52 ON P1
13:31:39.257 -> and 250KBPS data rate
13:31:39.257 ->
13:31:39.257 -> SPI Speedz = 10 Mhz
13:31:39.304 -> STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
13:31:39.357 -> RX_ADDR_P0-1 = 0xe7e7e7e7e7 0x4141417852
13:31:39.404 -> RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
13:31:39.457 -> TX_ADDR = 0xe7e7e7e7e7
13:31:39.457 -> RX_PW_P0-6 = 0x00 0x20 0x00 0x00 0x00 0x00
13:31:39.504 -> EN_AA = 0x3f
13:31:39.558 -> EN_RXADDR = 0x02
13:31:39.558 -> RF_CH = 0x4c
13:31:39.558 -> RF_SETUP = 0x27
13:31:39.605 -> CONFIG = 0x0e
13:31:39.605 -> DYNPD/FEATURE = 0x00 0x00
13:31:39.658 -> Data Rate = 250KBPS
13:31:39.658 -> Model = nRF24L01+
13:31:39.658 -> CRC Length = 16 bits
13:31:39.705 -> PA Power = PA_MAX
13:31:39.705 ->
13:31:39.705 ->
 
You said "no luck", but why do you conclude that ?

Sorry my post wasnt clear - forgot to paste the report in that post.

So I concluded that becasue originally I was getting this:

Code:
***** CheckConnection Starting *****



FIRST WITH THE DEFAULT ADDRESSES after power on

  Note that RF24 does NOT reset when Arduino resets - only when power is removed

  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not

     communicating with the nRF24



SPI Speedz	 = 10 Mhz
STATUS		 = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0

RX_ADDR_P0-1	 = 0x0000000000 0x0000000000

RX_ADDR_P2-5	 = 0x00 0x00 0x00 0x00

TX_ADDR		 = 0x0000000000

RX_PW_P0-6	 = 0x00 0x00 0x00 0x00 0x00 0x00

EN_AA		 = 0x00

EN_RXADDR	 = 0x00

RF_CH		 = 0x00

RF_SETUP	 = 0x00

CONFIG		 = 0x00

DYNPD/FEATURE	 = 0x00 0x00

Data Rate	 = 1MBPS

Model		 = nRF24L01

CRC Length	 = Disabled

PA Power	 = PA_MIN





AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1

 and 250KBPS data rate



SPI Speedz	 = 10 Mhz
STATUS		 = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0

RX_ADDR_P0-1	 = 0x0000000000 0x0000000000

RX_ADDR_P2-5	 = 0x00 0x00 0x00 0x00

TX_ADDR		 = 0x0000000000

RX_PW_P0-6	 = 0x00 0x00 0x00 0x00 0x00 0x00

EN_AA		 = 0x00

EN_RXADDR	 = 0x00

RF_CH		 = 0x00

RF_SETUP	 = 0x00

CONFIG		 = 0x00

DYNPD/FEATURE	 = 0x00 0x00

Data Rate	 = 1MBPS

Model		 = nRF24L01

CRC Length	 = Disabled

PA Power	 = PA_MIN
 
Thats indeed wrong ... getting all 0 means that the arduino is not interacting with the NRF24L01+ ... Have you tested all your NRF24L01+ transceivers with this or only one ?
 
Thats indeed wrong ... getting all 0 means that the arduino is not interacting with the NRF24L01+ ... Have you tested all your NRF24L01+ transceivers with this or only one ?

Several.

So does the 1st set of report output I posted - with the MCU & RF unit mounted on a Perf Baord look OK?
ie Post #45
 
Status
Not open for further replies.
Back
Top