mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 14:00:49 +02:00
Display RN2483A LoRa Module test results on SSD1306 Oled
This commit is contained in:
parent
31059a780b
commit
44342c223d
2 changed files with 58 additions and 14 deletions
|
@ -12,4 +12,7 @@
|
|||
platform = espressif32
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
framework = arduino
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
adafruit/Adafruit SSD1306@^2.5.13
|
||||
adafruit/Adafruit GFX Library@^1.11.11
|
||||
|
|
67
src/main.cpp
67
src/main.cpp
|
@ -1,30 +1,71 @@
|
|||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
HardwareSerial mySerial(0); // Use UART0 (RX0, TX0)
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200); // Initialize Serial Monitor
|
||||
mySerial.begin(57600); // Initialize RN2483A Serial communication
|
||||
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||
|
||||
Serial.println("Testing RN2483A module...");
|
||||
void printSSD1306(String text) {
|
||||
display.clearDisplay();
|
||||
display.setCursor(0, 0);
|
||||
display.println(text);
|
||||
display.display();
|
||||
}
|
||||
|
||||
void Init_SSD1306() {
|
||||
// SSD1306 initialization
|
||||
if(!display.begin(0x3C, 0x3C)) { // Address 0x3C for 128x64
|
||||
for(;;);
|
||||
}
|
||||
display.display();
|
||||
delay(2000); // Pause for 2 seconds
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1); // Normal 1:1 pixel scale
|
||||
display.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
display.setCursor(0, 0); // Start at top-left corner
|
||||
|
||||
|
||||
display.println("SSD1306 Oled Initialized!");
|
||||
display.display();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void test_RN2483A() {
|
||||
// Send a command to the RN2483A module
|
||||
mySerial.println("sys get ver");
|
||||
Serial.println("sys get ver");
|
||||
|
||||
// Wait for a response
|
||||
delay(1000);
|
||||
|
||||
// Read the response from the RN2483A module
|
||||
while (mySerial.available()) {
|
||||
String response = mySerial.readString();
|
||||
Serial.println("RN2483A Response: " + response);
|
||||
while (Serial.available()) {
|
||||
String response = Serial.readString();
|
||||
printSSD1306("RN2483A Response:");
|
||||
printSSD1306(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
// Initialize RN2483A Serial communication
|
||||
Serial.begin(57600);
|
||||
|
||||
// Initialize SSD1306
|
||||
Init_SSD1306();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Idle loop
|
||||
mySerial.begin(115200);
|
||||
Serial.println("Idle...");
|
||||
test_RN2483A();
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue