Similar problem to other person but I have checked soldering and its good.
When run code doesn't initialize properly.
// LoRa 9x_TX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (transmitter)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example LoRa9x_RX
#include <SPI.h>
#include <RH_RF95.h>
#define RFM95_CS 13
#define RFM95_RST 12
#define RFM95_INT 5
// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 434.0
// Singleton instance of the radio driver
//RH_RF95 rf95(RFM95_CS, RFM95_INT);
RH_RF95 rf95(RFM95_CS, RFM95_INT);
void setup()
{
pinMode(RFM95_RST, OUTPUT);
digitalWrite(RFM95_RST, HIGH);
while (!Serial);
Serial.begin(115200);
delay(100);
Serial.println("Arduino LoRa TX Test!");
// manual reset
digitalWrite(RFM95_RST, LOW);
delay(10);
digitalWrite(RFM95_RST, HIGH);
delay(10);
while (!rf95.init()) {
Serial.println("LoRa radio init failed");
while (1);
}
Serial.println("LoRa radio init OK!");
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
if (!rf95.setFrequency(RF95_FREQ)) {
Serial.println("setFrequency failed");
while (1);
}
Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);
// Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on
// The default transmitter power is 13dBm, using PA_BOOST.
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
rf95.setTxPower(23, false);
}
int16_t packetnum = 0; // packet counter, we increment per xmission
void loop()
{
Serial.println("Sending to rf95_server");
// Send a message to rf95_server
char radiopacket[20] = "Hello World # ";
itoa(packetnum++, radiopacket+13, 10);
Serial.print("Sending "); Serial.println(radiopacket);
radiopacket[19] = 0;
Serial.println("Sending..."); delay(10);
rf95.send((uint8_t *)radiopacket, 20);
Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
Serial.println("Waiting for reply..."); delay(10);
if (rf95.waitAvailableTimeout(1000))
{
// Should be a reply message for us now
if (rf95.recv(buf, &len))
{
Serial.print("Got reply: ");
Serial.println((char*)buf);
Serial.print("RSSI: ");
Serial.println(rf95.lastRssi(), DEC);
}
else
{
Serial.println("Receive failed");
}
}
else
{
Serial.println("No reply, is there a listener around?");
}
delay(1000);
}
Thats not what the UNOs I ahve seen look like ?
Do we need to guess what the problem is ?
I've changed topic name
Can you post a schematic, including the pin numbers that you are using for the SPI interface, something does not look right, but its almost impossible to tell from a picture of a breadboard.
photo in post looks like an nano - check your wiring against the nano pinout which shows MOSI as pin 11 and MISO as pin12
Nano uses an ATmega328.
The SPI pins are therefore;
SCK 13
MISO 12
MOSI 11
Have made these changes and still has same error
And the pinout schematic is now ?
Did you change the code as well so it matches the schematic ?
Try this;
/*******************************************************************************************************
Program Operation - This is a standalone program that checks that a LoRa device can be accessed by doing
a test register write and read. If there is no device found a message is printed on the serial monitor.
The contents of the registers from 0x00 to 0x4F are printed. The program is for the SX127X LoRa devices.
The Arduino pin numbers that are connected to the LoRa device NSS and NRESET pins must be specified in
the hardware pin connections section. You will also need to connect the 3 SPI pins to the LoRa
module, SCK, MISO and MOSI. No other IO pin connections to the LoRa device are needed. Note that LoRa
modules are 3.3V logic devices and must not be connected directly to 5V logic Arduinos.
Typical printout;
78_Simple_LoRa_Register_Test
LoRa Device found
Device version 0x12
Registers
Reg 0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00 00 09 1A 0B 00 52 6C 80 00 4F 09 2B 20 08 02 0A
0x10 FF 70 15 0B 28 0C 12 47 32 3E 00 00 00 00 00 40
0x20 00 00 00 00 05 00 03 93 55 55 55 55 55 55 55 55
0x30 90 40 40 00 00 0F 00 00 00 F5 20 82 FD 02 80 40
0x40 00 00 12 24 2D 00 03 00 04 23 00 09 05 84 32 2B
Note: An SX1272 will report as version 0x22
Serial monitor baud rate is set at 115200.
*******************************************************************************************************/
const uint8_t REG_FRMID = 0x07; //register number for setting and reading frequency, mid byte
const uint8_t REG_VERSION = 0x42; //register containg version number of device
//********* Setup hardware pin definition here ! **************
#define NSS 10 //LoRa NSS device select
#define NRESET 9 //LoRa NRESET pin
//**************************************************************/
#include <SPI.h>
void loop()
{
Serial.println();
//The begin function setups the hardware pins used by device and then checks if device is found
if (begin(NSS, NRESET))
{
Serial.println(F("LoRa Device found"));
}
else
{
Serial.println(F("No device responding"));
}
Serial.print(F("Device version 0x"));
uint8_t deviceversion = readRegister(REG_VERSION);
if (deviceversion < 0x10)
{
Serial.print(F("0"));
}
Serial.println(deviceversion, HEX);
Serial.println(F("Registers")); //show the all registers
printRegisters(0x00, 0x4F);
delay(5000);
}
uint8_t readRegister(uint8_t address)
{
uint8_t regdata;
digitalWrite(NSS, LOW); //set NSS low
SPI.transfer(address & 0x7F); //mask address for read
regdata = SPI.transfer(0); //read the byte
digitalWrite(NSS, HIGH); //set NSS high
return regdata;
}
void writeRegister(uint8_t address, uint8_t value)
{
digitalWrite(NSS, LOW); //set NSS low
SPI.transfer(address | 0x80); //mask address for write
SPI.transfer(value); //write the byte
digitalWrite(NSS, HIGH); //set NSS high
}
void printRegisters(uint16_t Start, uint16_t End)
{
uint16_t Loopv1, Loopv2, RegData;
Serial.print(F("Reg 0 1 2 3 4 5 6 7 8 9 A B C D E F"));
Serial.println();
for (Loopv1 = Start; Loopv1 <= End;)
{
Serial.print(F("0x"));
if (Loopv1 < 0x10)
{
Serial.print(F("0"));
}
Serial.print((Loopv1), HEX);
Serial.print(F(" "));
for (Loopv2 = 0; Loopv2 <= 15; Loopv2++)
{
RegData = readRegister(Loopv1);
if (RegData < 0x10)
{
Serial.print(F("0"));
}
Serial.print(RegData, HEX);
Serial.print(F(" "));
Loopv1++;
}
Serial.println();
}
}
bool begin(int8_t pinNSS, int8_t pinNRESET)
{
pinMode(pinNSS, OUTPUT);
digitalWrite(pinNSS, HIGH);
pinMode(pinNRESET, OUTPUT);
digitalWrite(pinNRESET, HIGH);
delay(5);
digitalWrite(pinNRESET, LOW);
delay(5);
digitalWrite(pinNRESET, HIGH);
delay(5);
if (checkDevice())
{
return true;
}
return false;
}
bool checkDevice()
{
//check there is a device out there, writes a register and reads back
uint8_t Regdata1, Regdata2;
Regdata1 = readRegister(REG_FRMID); //low byte of frequency setting
writeRegister(REG_FRMID, (Regdata1 + 1));
Regdata2 = readRegister(REG_FRMID); //read changed value back
writeRegister(REG_FRMID, Regdata1); //restore register to original value
if (Regdata2 == (Regdata1 + 1))
{
return true;
}
else
{
return false;
}
}
void setup()
{
Serial.begin(115200);
Serial.println(F("78_Simple_Register_Test"));
SPI.begin();
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.



