Go Down

Topic: RF24 nRF24L01 Serial Chat example (Read 29676 times) previous topic - next topic

debkalpa

Hi Stanley,

Thanks a lot for the code.
I got this code running on two NRF24L01+ 's on Arduino Uno's; and it worked like a charm.
However, now I would like to run these using ATtiny84's, and just cannot get the code to compile. (serial was not declared in this scope).

What am I missing here?

Thanks!

HuCG1804

Hi. Im new in all this stuff so Im having problems with your sketch, when I verify the code I got an error:
"fatal error: printf.h: No such file or directory
compilation terminated."

So, it seems I need a printf.h library? If thats the case I cant find anything but information about being obsolete, so I need to use something different, the answer is what?

Thanks.

Whandall

printf.h
Code: [Select]
/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */
 /*  Galileo support from spaniakos <spaniakos@gmail.com> */

/**
 * @file printf.h
 *
 * Setup necessary to direct stdout to the Arduino Serial library, which
 * enables 'printf'
 */

#ifndef __PRINTF_H__
#define __PRINTF_H__

#if defined (ARDUINO) && !defined (__arm__) && !defined(__ARDUINO_X86__)

int serial_putc( char c, FILE * )
{
  Serial.write( c );

  return c;
}

void printf_begin(void)
{
  fdevopen( &serial_putc, 0 );
}

#elif defined (__arm__)

void printf_begin(void){}

#elif defined(__ARDUINO_X86__)
int serial_putc( char c, FILE * )
{
  Serial.write( c );

  return c;
}

void printf_begin(void)
{
  //JESUS - For reddirect stdout to /dev/ttyGS0 (Serial Monitor port)
  stdout = freopen("/dev/ttyGS0","w",stdout);
  delay(500);
  printf("redirecting to Serial...");
 
  //JESUS -----------------------------------------------------------
}
#else
#error This example is only for use on Arduino.
#endif // ARDUINO

#endif // __PRINTF_H__
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

vagulus

Stanley

I just copied and pasted your sketch from the original post  On compiling I get these errors
Code: [Select]
D:\Arduino\serialChat\serialChat.ino: In function 'void nRF_receive()':

serialChat:111: error: void value not ignored as it ought to be

         done = radio.read(&RecvPayload,len);

              ^

D:\Arduino\serialChat\serialChat.ino: In function 'void serial_receive()':

D:\Arduino\serialChat\serialChat.ino:137:14: warning: unused variable 'ok' [-Wunused-variable]

         bool ok = radio.write(&SendPayload,strlen(SendPayload));

              ^


I can see what the second one (ok) is about but I can make neither head nor tail of the first one (done).
I am using Arduino 1.6.13 which may make a difference.

However, I am reluctant to start fiddling with the code if there's a simple answer (which you might see being the author).  Can you suggest the solutions?

BTW: there is some really clever programming in this.  Thanks
"Answers are easy;
               it's asking the right questions
                                                      which is hard."
 The Doctor (Dr Who: The Face of Evil (1977))

darjiaus7

I found out, that I am getting ACK from nowhere. I turned off RPI3 and I still getting ACK messages. I have line
if (radio.available()) {

}
So I am having available data from somewhere?

So how I am getting ACK messages from nowhere? Maybe Aliens wants to contact with me? :D

SuperFatUnicorn

I tried the code shown here and on your github page, I even used 1.6, as it was the latest released build by 2015. I'm wondering if the reason it doesn't work is that I'm using an arduino leonardo. Could that be the case? And if so, how could I rewrite the code to use it on the arduino leonardo?

Robin2

Two or three hours spent thinking and reading documentation solves most programming problems.

haamidrezzaa

hi

when i was try  to  cmpil your cod (serial chat )  i take this err (void value not ignored as it ought to be)



at this line  (&&&)


void nRF_receive(void) {
 int len = 0;
 if ( radio.available() ) {
     bool done = false;
     while ( !done ) {
       len = radio.getDynamicPayloadSize();
       done = radio.read(&RecvPayload,len);..................>>>&&&
       delay(5);
     }


some help plz

Robin2

when i was try  to  cmpil your cod (serial chat )  i take this err (void value not ignored as it ought to be)
Post the complete programs that YOU have uploaded to your Arduinos.

Are you using the ManiacBug or the newer TMRh20 version of the RF24 library?

Have you tried the examples in my tutorial?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up