0

I am new to the Raspberry Pi platform and I have been trying to get my Pi to communicate with an NRF24L01 module. I have been at this for a few days and just cannot get it to work. Here is my info and what I have tried so far:

@raspberrypi:~ $ ./versioncheck.sh
- Original Installation
Raspberry Pi reference 2020-02-13
- Current OS
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
- Kernel
4.19.97-v7l+
- Model
Raspberry Pi 4 Model B Rev 1.1
- Firmware
Feb 12 2020 12:36:21 
Copyright (c) 2012 Broadcom
version c3c8dbdf147686fb0c3f32aece709d0653368810 (clean) (release) (start)
Filesystem created:       Sun Mar 15 20:45:11 2020

I have followed a bunch of tutorials and none have worked for me, however I was closest with this one: Youtube Tutorial

My code is:

import RPi.GPIO as GPIO
from lib_nrf24 import NRF24
import time
import spidev

GPIO.setmode(GPIO.BCM)

pipes = [[0xE8, 0xE8, 0xF0, 0xF0, 0xE1], [0xF0, 0xF0, 0xF0, 0xF0, 0xE1]]

radio = NRF24(GPIO,spidev.spiDev())
radio.begin(0,17)

radio.setPayloadsize (32)
radio.setChannel (0x76)
radio.setDataRate (NRF24.BR_1MBPS)
radio.setPALevel (NRF24.PA_MIN)

radio.setAutoAck(True)
radio.enableDynamicPayloads()
radio.enableAckPayload()

radio.openReadingPipe(1, pipes[1])
radio.printDetails()
radio.startListening()

while True:

        while not radio.available(0):
            time.sleep(1/100)

        recievedMessage = []
        radio.read(receivedMessage, radio.getDynamicPayLoadSize())
        print("Recieved: {}".format(recievedMessage))

        print("Translating our received message into unicode characters...")
        string = ""

        for n in receivedMessage:
            if (n >= 32 and n <= 126):
                string =+ chr(n)
            print("Our received message decodes to: {}".format (string))

When I run the code I get:

  File "/home/pi/Desktop/NRF24L01/recieveArduino.py", line 11, in <module>
    radio = NRF24(GPIO,spidev.spiDev())
AttributeError: module 'spidev' has no attribute 'spiDev'

I have tried the following:(I think the is everything)

sudo apt-get install python3-dev 
  174  wget https://github.com/Gadgetoid/py-spidev/archive/master.zip
  175  unzip master.zip
  176  ls
  177  rm master.zip
  178  cd py-spidev-master/
  179  sudo python3 setup.py install
  180  cd desktop
  181  cd
  182  cd desktop/
  183  cd Desktop/
  184  ls
  185  mkdir NRF24L01
  186  cd NRF24L01/
  187  git clone https://github.com/BLavery/lib_nrf24
  188  cd lib_nrf24/
  189  ls
  190  cp lib_nrf24.py ~/Desktop/NRF24L01/
194  cd
  195  cd Desktop
  196  git clone https://github.com/tmrh20/RF24

I tried updating:

sudo apt-get update
  258  sudo apt-get dist-upgrade
  259  sudo easy_install RPi.gpio
  260  sudo apt-get install python-rpi.gpio python3-rpi.gpio
  261  sudo reboot
  262  history
  263  sudo apt-get python-dev python3-dev gcc python3-setuptools python3-pip
  264  sudo apt-get python3-dev gcc python3-setuptools python3-pip
  265  sudo apt-get instal python-dev python3-dev gcc python3-setuptools python3-pip
  266  sudo apt-get install python-dev python3-dev gcc python3-setuptools python3-pip
  267  sudo pip3 install RPi.GPIO

And:

cd py-spydev
  283  git clone https://github.com/Gadgetoid/py-spydev
  284  sudo apt-get update
  285  sude apt-get install python-dev python3-dev -y
  286  sudo apt-get install python-dev python3-dev -y
  287  history
  288  wget https://github.com/Gadgetoid/py-spidev/archive/master.zip
  289  ls
  290  unzip master.zip
  291  rm master.zip
  292  cd py-spidev-master/
  293  ls
  294  sudo python setup.py install
  295  sudo python3 setup.py install

I have referenced the following answers:

Read this if you use Python Spidev

Raspberry Pi won't recognize nRF24L01+

'SpiDev' object has no attribute 'GPIO'

Possible SPI issues around NRF24 operations post RPi system update?

Problem with SPI after updating to Stretch

Sorry about the long post but I am at a loss and hoped to give as much info as I can in order to get this module to work. Thank you all in advance.

NOTE: Yes SPI is enabled and I have verified proper hardware connections

  • Hi, this guy does not seem to have your spiDev problem: raspberrypi.stackexchange.com/questions/107608/…. – tlfong01 Apr 15 at 5:13
  • 1
    True, however it got to the point that I was searching all over for any kind of hints that may help. – PiMikeTSQL Apr 15 at 6:02
  • Well, you got stuck at a point after "import spidev", So I would suggest to check if you import garbage, and therefore output garbage. You might like to study Ref 28 of my answer to the following question related to non standard spidav:. raspberrypi.stackexchange.com/questions/109773/…. Cheers. – tlfong01 Apr 15 at 6:28
  • 1
    @tlfong01 thank you very much for your comments it was really great information. I just needed to pay attention to my case sensitivity haha. – PiMikeTSQL Apr 15 at 8:44
  • 1
    I couldn't believe I spent 3 days over a typo however I have done the same with SQL so I should have looked closer but it happens :p. My program is actually running but for some reason it isnt communicating properly. I am not getting anything out of the 'receiveMessage []' its just blank so that is what I am working through now. – PiMikeTSQL Apr 15 at 19:48
1

Python is case sensitive.

Linux is case sensitive.

https://pypi.org/project/spidev/

Try spidev.SpiDev() not spidev.spiDev().

| improve this answer | |
  • 1
    Thank you so much I almost laughed when I read that. I also happened to find a few other typo's and what do ya know it works. Thank you so much! – PiMikeTSQL Apr 15 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.