SPI connection to RFM219

Hello there!

After decoding transmition packet from home weather station:

I want to receive this transmition via RFM219:
RFM219S-433S1.pdf (903,9 KB)
First I want to read registers :


But I gaet that:

I think there is missing something in configuration of SPI connection:

#include "SPI.h"

int cs=10;
int receiveData=0;
int data2write=0;

void setup() {
 Serial.begin(9600);
 pinMode(cs, OUTPUT);
 digitalWrite(cs, HIGH);
 
 SPI.begin();
 SPI.setBitOrder(MSBFIRST);
}

void loop() {
 digitalWrite(cs, LOW);
 delayMicroseconds(1);
 //I want to read register at 0x3F adress, bit no 7 to HIGH -> dec = 191
 data2write = 191;
 SPI.transfer(data2write);
 receiveData = SPI.transfer(0x00);
 digitalWrite(cs, HIGH);
 Serial.println(receiveData);
 delay(1000);
}

Please point the direction..

It may help us if you could tell us which Arduino you are using and which pins you were connected to when capturing the signals in the LA screenshot.

I used Arduino Nano, there is level translator module between RFM219 and NANO.
Captured signals are on the NANO side.

RFM219 -> NANO:

CSB ->D10/SS
SCL -> D13/SCK
SDA - > D11/MOSI

I changed analyzer resolution :blush: and BitOrder for LSBFIRST and we have now:


It looks OK? on the master side but as we can see there is no answer..
Could I destroy RFM219 when I connect without leveltranslator at the beggining ?

my current code :

#include <SPI.h>

int cs=10;
char receiveData=0;
char data2write=0b11111101;

void setup() {
 Serial.begin(9600);
  digitalWrite(cs, HIGH);
 
 SPI.begin();
 SPI.setClockDivider(SPI_CLOCK_DIV8);
 SPI.setBitOrder(LSBFIRST);
}

void loop() {
 digitalWrite(cs, LOW);
 SPI.transfer(data2write);

 receiveData = SPI.transfer(0x00);
 
 digitalWrite(cs, HIGH);
  Serial.println(receiveData);
 delay(1000);
}

Does that mean your Nano is a 5V variant as opposed to the 3V3 variant?

Did you supply the RFM219 with 5V or 3V3? The HopeRF datasheet says it's a 3V3 part.

My Nano is 5V, RFM 3V3 and I spupply this chip correctly all the time.
But I connected both chips without leveltranslator at the beginning..

Hmm, if I'm reading the RFM219 spec correctly, then it isn't 5V tolerant on its pins. I would suspect that the part has been damaged.

I got another chip, connect directly to ESP32 with 3v3 levels and I have same situation...
I think that my SPI setup for 3WIRE SPI could be insufficient ?

When I swap chip to working wheather station we can see comunication:

At my circuit I have:

I'm not sure I understand. The first picture in your post shows 4 channels. I can see the SPI Chip Select on the top trace, the SPI clock on the 2nd trace, MOSI on the 3rd and presumably MISO on the 4th?

It looks like the device is either not responding or is sending out 0xFF on the MISO trace. I'm not sure what is happening when the Chip Select line goes high briefly as there is activity on MOSI without any associated change in clock.

The second picture doesn't show the 4th trace, but the transfer of 4 bytes looks ok.

4th channel is only the next channel in the logic analyzer, not connected.
Chip has 3 WIRE SPI interface.

Till I send adress of register looks OK but there is no answer from the chip:

SPI is a 4 wire bus: SS (or CS), CLK, MOSI, MISO. Sometimes it's 3 wire, if the device only receives data so there's no need for a MISO line.

In your annotated LA picture, the bit where you wrote "there should be the answer", the answer comes back on the MISO (Master In Slave Out) line, not on the MOSI (Master Out Slave In) line.

Maybe you're thinking of an I2C bus where the data is transferred bidirectionally on the same wire?

EDIT: I took a quick look at the RFM219 manual that you provided in the initial post. para 5.6 on the SPI interface says:

The SDA is a bi-directional data pin. Address and data is always sent starting from the MSB.

Interestingly, the doc also refers to SPI as the Serial Port Interface. That is starting to suggest that HopeRF SPI is not the same as Arduino SPI.

There is some hint to wire both MISO and MOSI via resistor to SDA:

But this solution doesnt work.

its essentially no different than comms with a TM1638 7 Segment Display Keypad & LED Module , have a look at that method

You can probably use the shiftOut() and shiftIn() functions to talk to your RFM219.

@markd833 and @racpi Thanks!
Now I can read with shiftOut() and shiftIn() and writing it will be no problem.

Hi, how did you solved the shifin()?
I'm intrested because I'm trying to read out my watering meter :innocent:

Hi, I read with that function:

byte read_3WIRE(byte adres){

  byte answer = 0;

  digitalWrite(csb, LOW);

  shiftOut(sda, scl, MSBFIRST, adres);

  pinMode(sda, INPUT);

  answer = shiftIn(sda, scl, MSBFIRST);

  digitalWrite(csb, HIGH);

  digitalWrite(sda, LOW);

  pinMode(sda, OUTPUT);

  return answer;

}

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