#include <Adafruit_SSD1306.h>
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <LoRa.h>
#include <string>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
int counter = 1; // zähler für lora-pakete
int zz = 1; // zeilenzähler für oled-display
std::string ausgabe = "Sending packet: ";
void displayText(const char *text) {
if (zz == 9) {
oled.clearDisplay();
oled.setCursor(0, 0);
zz = 1;
}
oled.setTextColor(SSD1306_WHITE);
oled.setTextSize(1);
oled.println(text);
oled.display();
zz++;
}
void setup() {
Serial.begin(9600);
delay(2000);
Serial.println("Serial Rxd is on pin: "+String(RX));
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 OLED-Display allocation failed");
return;
}
oled.clearDisplay();
oled.display();
if (!LoRa.begin(868E6)) {
Serial.println("Starting LoRa failed!");
return;
}
}
void loop() {
displayText("Loop start");
delay(1000);
Serial.print("Sending packet: ");
Serial.println(counter);
std::string zaehler = std::to_string(counter);
ausgabe += zaehler; // "Sending packet: " + zaehler
//Serial.print(ausgabe.c_str());
displayText(ausgabe.c_str());
// send packet
//LoRa.beginPacket();
//LoRa.print("Sende Paket ");
//LoRa.print(counter);
//LoRa.endPacket();
counter++;
ausgabe = "Sending packet: "; // zurücksetzen auf starttext
delay(1000);
}