Compare commits

...

2 Commits

Author SHA1 Message Date
Bartosz Mazurczak
2e867717f2 add oled support 2025-01-12 18:50:16 +01:00
Bartosz Mazurczak
fddc52d53d added casse with oled 2025-01-12 18:49:49 +01:00
6 changed files with 62 additions and 1 deletions

BIN
assets/photo5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 KiB

BIN
assets/photo6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

BIN
assets/photo7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

View File

@@ -4,6 +4,10 @@
#define JSON_CONFIG_FILE "/config.json"
#define TUBE_NAME "J305"
#define TUBE_FACTOR 0.00812
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define i2c_Address 0x3c
#define OLED_RESET -1
#include <ESP_DoubleResetDetector.h>
#include <LittleFS.h>
@@ -12,6 +16,11 @@
#include <ArduinoJson.h>
#include <PubSubClient.h>
#include <HTTPClient.h>
#include "time.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
DoubleResetDetector* drd;
@@ -19,6 +28,8 @@ WiFiClient espClient; // connection for MQTT
WiFiClient espClient2; // connection fot HTTP Client
PubSubClient client(espClient);
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Initialize LittleFS
void initLittleFS() {
if (!LittleFS.begin(true)) {
@@ -53,11 +64,17 @@ void ICACHE_RAM_ATTR handleInterrupt() {
GeigerCounts++;
}
const char* ntpServer = "europe.pool.ntp.org";
const long gmtOffset_sec = 3600; // GMT +1 = 3600
const int daylightOffset_sec = 3600;
String GMCMap_Request_payload = "http://www.GMCmap.com/log2.asp";
String GMCMap_Request = "";
String GMCMap_Data = "";
String GMCMap = "NONE";
struct tm timeinfo;
void saveConfigFile()
{
Serial.println(F("Saving config"));
@@ -152,6 +169,38 @@ void reconnect() {
}
}
void lcdPrint(String x) {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 10);
display.println(x);
display.display();
}
void lcdUpdate() {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println(printLocalTime());
display.println("uSv/h: " + String(buf2));
display.println("CPM: " + String(buf));
display.display();
}
String printLocalTime()
{
//if(!getLocalTime(&timeinfo)){
// Serial.println("Failed to obtain time");
// return "Failed to obtain time";
//}
char buffer[80];
//strftime(buffer, 80, "%H:%M:%S %d-%m-%Y ", &timeinfo);
strftime(buffer, 80, "%H:%M <|> %d-%m-%Y ", &timeinfo);
return String(buffer);
}
void setup() {
// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
// it is a good practice to make sure your code sets wifi mode how you want it.
@@ -161,6 +210,10 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING );
initLittleFS();
display.begin(i2c_Address, true);
lcdPrint("Geiger Interace");
drd = new DoubleResetDetector(DRD_TIMEOUT, DRD_ADDRESS);
bool forceConfig = false;
if (drd->detectDoubleReset()) {
@@ -205,7 +258,6 @@ void setup() {
}
}
//tutaj bez sensu
strcpy(mqttServer, custom_mqttServer.getValue());
strcpy(mqttUser, custom_mqttUser.getValue());
strcpy(mqttPass, custom_mqttPass.getValue());
@@ -228,6 +280,9 @@ void setup() {
client.setServer(mqttServer, 1883);
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
}
void loop() {
@@ -252,10 +307,16 @@ void loop() {
client.publish("esp32/uSv", buf2);
GeigerCounts = 0;
mold += 60000;
lcdUpdate();
}
client.loop();
}
getLocalTime(&timeinfo);
if (timeinfo.tm_sec == 0){
lcdUpdate();
}
// if GMC IDs provided
if (String(gmcAccountID) != "") {
currentMillis = millis();

BIN
stl/case_bottom_oled.stl Normal file

Binary file not shown.

BIN
stl/case_lid_oled.stl Normal file

Binary file not shown.