Hi!
I am trying for the first time to use an RF Module in a project. I am using a very nice video from youtube as guidance Using Inexpensive 433 MHz RF Modules with Arduino - YouTube
In the example used in the video, the following library is being used: RadioHead: RadioHead Packet Radio library for embedded microprocessors
The library uses Pin 12 to transmit, and pin 11 to receive. I am already using these pins because I have an SD card reader connected to the board (arduino nano). Is it possible to modify the library to use other pins?
I have seen that pin 12 and pin 11 are used for SPI, which is being used then both by the RF modukle and the SD card reader. Does this mean that I cannot use this RF Module AND the SD card reader in the same project?
As you can read here:
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
it's possible to connect multiple slaves to the master by use of the slave select (SS) pin.
Thank you very much for your prompt contribution.
Could you perhaps guide me a bit more on how to implement this in my project? I dont really understand all of these concepts.
Lets say I will not modify anything that has to do with the SD card reader, but try to include the RF Module in the project.
I am using the following sketches to test the set up:
transmitter:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver;
void setup()
{
rf_driver.init();
}
void loop()
{
const char *msg = "Welcome to the Workshop!";
rf_driver.send((uint8_t *)msg, strlen(msg));
rf_driver.waitPacketSent();
delay(1000);
}
receiver:
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver;
void setup()
{
rf_driver.init();
Serial.begin(9600);
}
void loop()
{
uint8_t buf[24];
uint8_t buflen = sizeof(buf);
if (rf_driver.recv(buf, &buflen))
{
Serial.print("Message Received: ");
Serial.println((char*)buf);
}
}
How could I modify the sketches or the library in oder to use different pins that 12 and 11 for the RF Module?
You will need to find the Slave Select pins (labeled SS, NSS, CS, or similar) on both your SD card module and your RF module, and connect them each with a separate pin on your Arduino. The MOSI, MISO and SCLK will be shared by both devices. By switching the SS pins, you can select which devices receives your packet.
Have a read of this page:
The RF Module doesnt have a Slave Select pin. It is a very simple module that has V+, GND and Data
The library uses Pin 12 to transmit, and pin 11 to receive.
Those are the defaults. Use any pins you want for the RF modules by specifying them in the constructor. The radios don't use the SPI interface.
RH_ASK (uint16_t speed=2000, uint8_t rxPin=11, uint8_t txPin=12, uint8_t pttPin=10, bool pttInverted=false)
1 Like
camilozk:
The RF Module doesnt have a Slave Select pin. It is a very simple module that has V+, GND and Data
RF 433MHz Transmitter/Receiver Module With Arduino | Random Nerd Tutorials
Ahh you threw me off there, the transmitter not actually a SPI device. jremington got you your answer!
ok. I modified the pins in the library to 9 and 8 and it is working. thanks!