1

I'm hoping someone can help me since I've been struggling with this all weekend. I've got 2 nRF24L01+ breakout cards and I'm trying to send data from a ATTiny85 to a Raspberry Pi 3.

My setup is (the attiny85 breadboard has a 3.3V power supply):

ATTiny85

RaspberryPi3

And the code I'm testing is for the ATTiny85:

#define CE_PIN 3
#define CSN_PIN 4
#include "RF24.h"
RF24 radio(CE_PIN, CSN_PIN);
const byte addr[6] = "00001";
int count = 0;
void setup() {
 radio.begin();
 radio.openWritingPipe(addr);
 radio.setPALevel(RF24_PA_MIN);
 radio.stopListening();
}
void loop(void){
 radio.write( &count, sizeof(count) );
 count++;
 delay(1000);
}

And for the Raspberry Pi 3:

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <unistd.h>
#include <RF24/RF24.h>
using namespace std;
// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_22, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
// Radio pipe addresses for the 2 nodes to communicate.
const uint8_t addr[6] = "00001";
int main(int argc, char** argv){
 radio.begin();
 radio.setPALevel(RF24_PA_MIN);
 radio.openReadingPipe(1, addr);
 radio.startListening();
 // Dump the configuration of the rf unit for debugging
 radio.printDetails();
 int count = 0;
 while (1)
 {
 while ( radio.available() )
 {
 radio.read( &count, sizeof(count) );
 printf("Count: %d\n", count);
 }
 sleep(1);
 }
 return 0;
}
asked Nov 20, 2016 at 19:07
5
  • Double check MISO/MOSI on ATtiny. They are DO and DI not MISO and MOSI (which are used when programming). Commented Nov 20, 2016 at 20:26
  • Double check what about them? As far as I understand, the RF24 library supports the attiny's USI for SPI Commented Nov 21, 2016 at 8:26
  • You might have got the wiring wrong; NRF24/MISO => ATtiny85/DI (Pin 5), MOSI => DO (Pin 6). Commented Nov 21, 2016 at 9:19
  • @MikaelPatel thanks! That looks like it could be the problem. I have been going off the chip pinout from the datasheet (MOSI pin 5, MISO to pin 6). However, I see now that tmrh20.github.io/RF24/ATTiny.html has them listed the other way around, like you say. I'll test when I get home tonight. Commented Nov 21, 2016 at 14:16
  • Yes, USI uses DO(utput) and DI(nput). The MISO/MOSI are for programming only. Commented Nov 21, 2016 at 14:59

1 Answer 1

2

As Mikael Patel pointed out, my MOSI and MISO pins were switched.

On the pinout for the ATtiny85, the MOSI and MISO pins are for when the chip is a slave (i.e. programming). DO and DI and used for output as SPI master.

enter image description here

answered Nov 21, 2016 at 18:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.