Hi guys,
i'm trying to send data from a breadboard arduino (an atmega328p-pu with internal 8Mhz oscillator) to a raspberry using NRF24L01 modules. I'm using the TMRh20 RF24 lib.
I used Arduino isp to flash the bootloader on the blank atmega, then configured the Arduino IDE to program directly (using the cp2102 usb board) on the atmega using internal oscillator.
The classic blink led example is working, so i assume that this "first" part is done well.
All the connections seems ok because the printDetails show correct information on both sides. i connected VCC-AVCC and GND-GND on the atmega, directly without caps.
nrf24 ------- atmega328
GND ---> GND
VCC ---> VCC
CE ----> PB1
CSN ----> PB2
SCK -----> PB5
MOSI ---> PB3
MISO --> PB4
take from ATmega328p-pu + NRF24L01: Sketch freezes on microcontroller but works on arduino - Microcontrollers - Arduino Forum
I used the GettingStarted_CallResponse example, modified.
#include <JeeLib.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
#include <OneWire.h>
#include <DallasTemperature.h>
int led = 13;
int relay=7;
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Setup for low power waiting
// Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(9,10);
byte addresses[2] = {0xF0F0F0F0E1LL,0x7365727631LL};
byte counter = 1;
const int max_payload_size = 512;
char payload[512+1]; // +1 to allow room for a terminating NULL char
char floatBuffer[20];
void setup(){
Serial.begin(9600);
printf_begin();
Serial.println("***Starting\n\r");
radio.begin();
radio.setAutoAck(1); // Ensure autoACK is enabled
radio.enableAckPayload(); // Allow optional ack payloads
radio.setRetries(15,15); // Smallest time between retries, max no. of retries
radio.setPayloadSize(1);
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(70);
radio.openWritingPipe(0xF0F0F0F0E1LL);
radio.openReadingPipe(1,0x7365727631LL);
radio.setCRCLength(RF24_CRC_16);
radio.powerUp();
radio.printDetails(); // Dump the configuration of the rf unit for debugging
}
void loop(void) {
delay(1000);
/****************** Ping Out Role ***************************/
//sensors.requestTemperatures(); // Invia il comando di lettura delle temperatura
delay(100);
float temperature = 12;//sensors.getTempCByIndex(0);
sendData(dtostrf(temperature,2,1,floatBuffer));
delay(100);
Sleepy::loseSomeTime(2000); // Try again later
//Sleepy::powerDown();
}
void sendData( char *value) {
uint8_t gotByte;
sprintf(payload, "%s", value);
Serial.print(payload);
unsigned long time = millis();
bool ok = radio.write( payload, strlen(payload));
if (ok)
{
if(!radio.available()){ // If nothing in the buffer, we got an ack but it is blank
printf("Got blank response. round-trip delay: %lu ms\n\r",millis()-time);
}
else
{
while(radio.available() ){ // If an ack with payload was received
radio.read( &gotByte, 1 ); // Read it, and display the response time
printf("Got response %d, round-trip delay: %lu ms\n\r",gotByte,millis()-time);
counter++; // Increment the counter variable
}
}
Serial.print(" send ok\n\r");
}
else
Serial.print(" send failed\n\r");
}
This is the output from the atmega side
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0x7365727631
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 =0x01 0x01 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR =0x02
RF_CH = 0x46
RF_SETUP =0x03
CONFIG = 0x0e
DYNPD/FEATURE = 0x3f 0x06
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
Output:
12.0 send failed
I'm powering all of this with 3.3V.
The only extra components i put is a 100uf cap between VCC and GND, without results.
Am i missing something?
Thanks!!
Yuri