mirror of
https://github.com/MOSH-Insa-Toulouse/5ISS-2024-2025-MARIN--MULLER-BOUJON.git
synced 2025-06-08 22:10: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
|
@ -13,3 +13,6 @@ platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
lib_deps =
|
||||||
|
adafruit/Adafruit SSD1306@^2.5.13
|
||||||
|
adafruit/Adafruit GFX Library@^1.11.11
|
||||||
|
|
65
src/main.cpp
65
src/main.cpp
|
@ -1,30 +1,71 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <HardwareSerial.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() {
|
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
|
||||||
Serial.begin(115200); // Initialize Serial Monitor
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||||
mySerial.begin(57600); // Initialize RN2483A Serial communication
|
|
||||||
|
|
||||||
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
|
// Send a command to the RN2483A module
|
||||||
mySerial.println("sys get ver");
|
Serial.println("sys get ver");
|
||||||
|
|
||||||
// Wait for a response
|
// Wait for a response
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
// Read the response from the RN2483A module
|
// Read the response from the RN2483A module
|
||||||
while (mySerial.available()) {
|
while (Serial.available()) {
|
||||||
String response = mySerial.readString();
|
String response = Serial.readString();
|
||||||
Serial.println("RN2483A Response: " + response);
|
printSSD1306("RN2483A Response:");
|
||||||
|
printSSD1306(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// Initialize RN2483A Serial communication
|
||||||
|
Serial.begin(57600);
|
||||||
|
|
||||||
|
// Initialize SSD1306
|
||||||
|
Init_SSD1306();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Idle loop
|
test_RN2483A();
|
||||||
mySerial.begin(115200);
|
|
||||||
Serial.println("Idle...");
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue