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

1 Answers1

1

Python is case sensitive.

Linux is case sensitive.

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

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

joan
  • 71,852
  • 5
  • 76
  • 108