Arduino Uno / SPI Communication to RFM24W / Si 446x

Good day,

I've got an RFM24W transceiver module in order to control my garage door on 433.89 Mhz.
First thing I want to do is to establish an SPI connection. (see attachment for a setup image).

According to the RFM24W Datasheet on page 19, command 0x01 should report some basic information about the device.

#include <SPI.h>

const int ss = 7;

void setup()
{
  pinMode(ss, OUTPUT);
  pinMode(10, OUTPUT);
  SPI.begin();
  Serial.begin(9600);

  digitalWrite(ss, LOW);
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    SPI.transfer(0x01); // 0x01 PART_INFO Reports basic information about the device
    Serial.println("Command sent");
  SPI.endTransaction();
  digitalWrite(ss, HIGH);
}

void loop()
{

}

I was expecting the response on serial monitor, but this only shows my "Command sent" line.
After doing some research on the internet, I think I need to program a while loop, waiting for an answer.
Unfortunately, I have no clue where to start with.
What should I do next?

Very thankful for your help!

Steffl

Capture.JPG

Capture.JPG

You will find the reference for using SPI with Arduino with a Google search on 'Arduino spi reference'

Although if you have no experience of using basic SPI , implementing your own routines for the RFM24 might take a while.

The RFM24 is supported already by the Radiohead library.

Good day,

Regarding the Radio Head library, I am also aware of that and already tried out some code including the RH_RF24.h library. This didn't work at all unfortuntely, so I better do first things first!

I was googling a lot before posting here! I found many posts in MCU forums that have not been solved, so I try to be as specific as possible:
What I understand from SPI MISO communication is, that I need to send several bytes, as the answer will be always at least one byte behind. I revised my code as below (and settled down the speed):

#include <SPI.h>

const int ss = 7;
const int ansTime = 1;
const int sendDelay = 500;
void setup()
{
  pinMode(ss, OUTPUT);
  digitalWrite(ss, HIGH);
  pinMode(10, OUTPUT);
  SPI.begin();
  Serial.begin(9600);
}

byte sendCommand(const byte cmd)
{
  digitalWrite(ss, LOW);
  SPI.beginTransaction(SPISettings(100, MSBFIRST, SPI_MODE0));
    byte answer = SPI.transfer(cmd);
    Serial.println("Command sent");
    delay(ansTime);
    return answer;
  SPI.endTransaction();
  digitalWrite(ss, HIGH);
}

void loop()
{
   byte answer;
  delay(sendDelay);
  answer = sendCommand(0x01); // 0x01 PART_INFO Reports basic information about the device
  Serial.println(answer);
}

The serial monitor now shows:
Command sent
0
Command sent
0
Command sent
0
Command sent
0

So the answer is 0. How do I know, if this was from the chip?

steffl:
I am also aware of that and already tried out some code including the RH_RF24.h library. This didn't work at all unfortuntely, so I better do first things first!

Very unusual for library example code not to work. That it does not does suggests you have some form of connection\wiring\powersupply error.

You also might be powering the RFM24 from the UNOs 3.3V supply, althought its unlcear, schematics are normally easier to follow than pictures. The UNO 3.3V output is unlikley to have enought current capability to power a radio transmitter.

The RFM24 is a 3.3V device, so wont accept direct connection from a 5V logic UNO.

Much easier to use 3.3V radio devices from say an 3.3V Arduino Pro Mini.

Very unusual for library example code not to work. That it does not does suggests you have some form of connection\wiring\powersupply error.

In order to eliminate this source of error, I had wanted to get this simple SPI communication running first.

The RFM24 is a 3.3V device, so wont accept direct connection from a 5V logic UNO.

Yes. So my workaround is to use voltage dividers (see image). I checked the voltage - 3.32 V.

The UNO 3.3V output is unlikley to have enought current capability to power a radio transmitter.

Ok. So I'd like to try at least to send anything in order to see if my code is working.
The current should be enough to send anything over a distance of 10 cm, shouldn't it?

So I'm going to connect the interrupt pin XIRQ of RFM24w to PIN 2 of the Arduino Uno.
Regarding the RH_RF24.h method, I'll have a bunch of further questions, though.
What I tried out yesterday was this:

#include <RadioHead.h>
#include <RH_RF24.h>
#include <SPI.h>

RH_RF24 rf24;

const int ss = 7;
unsigned long code[13] = {0x88, 0x88, 0x8E, 0x8E, 0xEE, 0xEE, 0x8E, 0x8E, 0x88, 0xEE, 0x88, 0xEE, 0x80};

void setup()
{
  pinMode(ss, OUTPUT);
  pinMode(10, OUTPUT);
  SPI.begin();
  Serial.begin(9600);
  rf24.init();
  rf24.setFrequency(433.89,0.05);

  digitalWrite(ss, LOW);
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
    SPI.transfer(0x11); // Command for accessing SET_PROPERTY Register
    SPI.transfer(0x91); // Register MODEM_MOD_TYPE (No Preamble, OOK etc.) 
    Serial.println("Command sent");
  SPI.endTransaction();
  digitalWrite(ss, HIGH);
}

void loop()
{
  delay(2000);
  Serial.println("Sending Code");
  rf24.send(code,sizeof(code));
  rf24.waitPacketSent();
  rf24.sleep();
}

I am still looking for a good example or tutorial that helps me understand what to do in which order...

steffl:
I am still looking for a good example or tutorial that helps me understand what to do in which order...

I dont know the RadioHead library specifically, but as I mentioned it would be unusual for library examples to be broken, as you seem to be thinking.
I would suggest you try the code on an 3.3V Arduino that can communicate directly with the RFM24, without the need for resistor networks etc.

Ok, I've ordered an Arduino Mini.
Will be back as soon as I've tried that one out!

Thanks for your support so far!

Good day!

I managed to establish a communication between Arduino Mini 3.3V and the rfm24w transceiver - thanks for the hint!

I also used WDS (Wireless Development Suite configuration software) in order to set OOK, remove all synch words, preambles, CRC etc.
I included the resulting radio_config_Si4464.h file into RH_RF24.cpp library as explained on http://https://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html !

Carrier frequency and modulation are good now!
However, I wonder how to create the "bitstream" that I need.
Looking on SDR monitor and recording the signal, this is not what I expected!

I'm not sure, if this can really be done via rf24.send(x,y) command.

What I'd like to do is to simply implement this basic principle:
.

Any further ideas?

Thank you in advance!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.