Hi, Sorry for my english
i have problem on TX part
here is my working TX/RX. sorry for wire mess but working with SimpleRxAckPayload and SimpleTxAckPayload
there is another TX (not work)
i try everything like change arduino, change wires, with breadboard, without breadboard, change nrf with working other TX, try use RF24Network library use YwRobot on breadboard with good 3.3v etc.
there is lm1117T for 3.3v and 10uf cap. i use multimeter and 3.3v is good
when i upload helloworldtx sketch keep Sending.failed
when i remove miso and mosi pins keep Sending. ok. but not send anything
when upload SimpleTxAckPayload. data send ...... Acknowledge but no data
here is my other tx running properly sketch. but not work on this
// SimpleTxAckPayload - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
String Mesaj;
int sondurum=6;
int durum=2;
#define CE_PIN 7
#define CSN_PIN 8
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "30101Pe ";
char txNum;
char ackData[8]; // to hold the two values coming from the slave
bool newData = false;
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
//===============
void setup() {
Serial.begin(9600);
Serial.println(F("Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino"));
Serial.println("SimpleTxAckPayload Starting");
pinMode(4,INPUT);
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.enableAckPayload();
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//=============
void loop() {
durum=digitalRead(4);
//Serial.print(durum);
//Serial.print("-");
//Serial.print(sondurum);
if (durum != sondurum)
{
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
send();
sondurum = durum;
}
showData();
Mesaj=String(ackData);
if (digitalRead(4)==LOW && Mesaj=="30101 A")
{
sondurum=-1;
}
else if(digitalRead(4)==HIGH && Mesaj=="30101 K")
{
sondurum=-1;
}
}
}
//================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
if ( radio.isAckPayloadAvailable() ) {
radio.read(&ackData, sizeof(ackData));
newData = true;
}
else {
Serial.println(" Acknowledge but no data ");
}
updateMessage();
}
else {
Serial.println(" Tx failed");
}
prevMillis = millis();
}
//=================
void showData() {
if (newData == true) {
Serial.print(" Acknowledge data ");
Serial.print(ackData);
//Serial.print(", ");
//Serial.println(ackData[1]);
Serial.println();
newData = false;
}
}
//================
void updateMessage() {
durum=digitalRead(4);
if ( durum == HIGH) {
txNum = 'K';
}
else {
txNum = 'A';
}
//Serial.println(durum);//if
// so you can see that new data is being sent
// txNum += 1;
//if (txNum > '9') {
// txNum = '0';
//}
dataToSend[8] = txNum;
}
pins
ARDUINO NANO/MINI PRO | NRFL2401 | ||
---|---|---|---|
VCC (With lm1117T) | VCC | ||
GND (With lm1117T) | GND | ||
7 | CE | ||
8 | CS | ||
13 | SCK | ||
11 | MOSI | ||
12 | MISO |
there is no other component
here is my helloworldtx code
/*
Copyright (C) 2012 James Coliz, Jr. <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.
Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network
*
* TRANSMITTER NODE
* Every 2 seconds, send a payload to the receiver node.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 01; // Address of our node in Octal format
const uint16_t other_node = 00; // Address of the other node in Octal format
const unsigned long interval = 2000; //ms // How often to send 'hello world to the other unit
unsigned long last_sent; // When did we last send?
unsigned long packets_sent; // How many have we sent already
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_tx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {
network.update(); // Check the network regularly
unsigned long now = millis(); // If it's time to send a message, send it!
if ( now - last_sent >= interval )
{
last_sent = now;
Serial.print("Sending...");
payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&payload,sizeof(payload));
if (ok)
Serial.println("ok.");
else
Serial.println("failed.");
}
}
and here is my helloworldrx code
/*
Copyright (C) 2012 James Coliz, Jr. <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.
Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network,
*
* RECEIVER NODE
* Listens for messages from the transmitter and prints them out.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 00; // Address of our node in Octal format ( 04,031, etc)
const uint16_t other_node = 01; // Address of the other node in Octal format
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop(void){
network.update(); // Check the network regularly
while ( network.available() ) { // Is there anything ready for us?
RF24NetworkHeader header; // If so, grab it and print it out
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
}
}