You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a small app in order to test the range of the TTGO ESP32/SX1278/SSD1306 boards. The transmit side is straightforward and sends packets with the string "Block" followed by a number that increments from 0 to 999. the receiver is interrupt driven (code below). The problem was that after startup, the correct block number was displayed but all subsequent packets were displayed with the same block number. To fix it I had to comment out the following line from handleDio0Rise() in LoRa.cpp at line 484
writeRegister(REG_FIFO_ADDR_PTR, 0);
After that the correct packet was displayed.
Code:
#include <SPI.h>
#include <LoRa.h>
#include "SSD1306.h"
//****** SX1278 pins to ESP32 GPIOs ******//
#define SCK 5
#define MISO 19
#define MOSI 27
#define CS 18
#define RESET 14
#define IRQ 26 //(Interrupt Request)
#define BAND 915E6 // Set LORA band to 915MHz
//****** OLED pins to ESP32 GPIOs ******//
#define OLED_SDA 4 // GPIO4
#define OLED_SCL 15 // GPIO15
#define OLED_RST 16 // GPIO16
SSD1306 display(0x3c, OLED_SDA, OLED_SCL);
volatile int MessageLength = 0;
void PrintMessage(String Message)
{
display.clear();
display.println(Message);
display.drawLogBuffer(0, 0); // Draw it to the internal screen buffer
display.display(); // Display it on the screen
}
void setup()
{
//****** Set up OLED display ******//
pinMode(OLED_RST,OUTPUT);
digitalWrite(OLED_RST, LOW); // set GPIO16 low to reset OLED
delay(50);
digitalWrite(OLED_RST, HIGH); // while OLED is running, must set GPIO16 in high
display.init();
display.setContrast(255);
display.setLogBuffer(8, 30); // Initialise OLED buffer to 30x8 char
PrintMessage("LoRa Range Test starting");
//****** Set up LORA chip ******//
SPI.begin(SCK, MISO, MOSI, CS);
LoRa.setPins(CS, RESET, IRQ);
if (!LoRa.begin(BAND))
{
PrintMessage(" ");
PrintMessage(" ");
PrintMessage("LoRa failed to start!");
while (1);
}
LoRa.onReceive(onReceive); // register the receive callback
LoRa.receive(); // put the radio into receive mode
}
void loop()
{
if(MessageLength > 0)
{
HandleInterrupt(MessageLength);
MessageLength = 0;
}
}
void onReceive(int packetSize) // received a packet
{
MessageLength = packetSize;
}
void HandleInterrupt(int packetSize)
{
String Message = "Rcved: ";
for (int i = 0; i < packetSize; i++) Message = Message + (char)LoRa.read();
Message = Message + " RSSI: " + LoRa.packetRssi(); // print RSSI of packet
PrintMessage(Message);
}
The text was updated successfully, but these errors were encountered:
I wrote a small app in order to test the range of the TTGO ESP32/SX1278/SSD1306 boards. The transmit side is straightforward and sends packets with the string "Block" followed by a number that increments from 0 to 999. the receiver is interrupt driven (code below). The problem was that after startup, the correct block number was displayed but all subsequent packets were displayed with the same block number. To fix it I had to comment out the following line from handleDio0Rise() in LoRa.cpp at line 484
After that the correct packet was displayed.
Code:
The text was updated successfully, but these errors were encountered: