diff --git a/README.md b/README.md
index 9324391..d6f6d11 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
- RadMon integration
- Clean code
- check MQTT reliability
-- OLED display support
+- ~~OLED display support~~
### Hardware
**RadiationD v1.1 (CAJOE)** it's a cheap(est) Geiger counter that you can found on China market. I recommend to order assembled ;) due lacks of documentations. Next one is ESP32. I like generic dev boards like **HW-394 - ESP32-WROOM-32** - they are cheap, have many gpio, now they have even USB-C ;) Let's go connect it together. My CAJOE arrived with DuPont jumper wire, but don't be confused: **VIN** on CAJOE is an signal output! After everything is connected, you can flash ESP with **Geiger-interface.ino**. On first boot, WiFiManager create access point named **ESP_xxxxxx**. After connect there will be captive portal (or under address http://192.168.4.1) where you can configure:
@@ -64,7 +64,8 @@ About J305 Tube conversion factor, you can read intresting article on: https://i
### 3D Printed case
-Files download here https://git.noop.re/drops/Geiger-interface/src/branch/main/stl
+Files download here https://git.noop.re/drops/Geiger-interface/src/branch/main/stl - case_bottom_oled.stl have more height due a gold pins on oled display esp32 board.
+If you have / order boards without gold pins and you use soldering wires to connect, you can print standard case.


@@ -72,6 +73,9 @@ Files download here https://git.noop.re/drops/Geiger-interface/src/branch/main/s



+
+
+
### Resources
- https://iot-devices.com.ua/
diff --git a/assets/photo5.jpg b/assets/photo5.jpg
new file mode 100644
index 0000000..08e5532
Binary files /dev/null and b/assets/photo5.jpg differ
diff --git a/assets/photo6.jpg b/assets/photo6.jpg
new file mode 100644
index 0000000..b8b9729
Binary files /dev/null and b/assets/photo6.jpg differ
diff --git a/assets/photo7.jpg b/assets/photo7.jpg
new file mode 100644
index 0000000..75c6bef
Binary files /dev/null and b/assets/photo7.jpg differ
diff --git a/geiger_interface.ino b/geiger_interface.ino
index 6559cf4..f6032b7 100644
--- a/geiger_interface.ino
+++ b/geiger_interface.ino
@@ -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
#include
@@ -12,6 +16,11 @@
#include
#include
#include
+#include "time.h"
+
+#include
+#include
+#include
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();
diff --git a/stl/case_bottom_oled.stl b/stl/case_bottom_oled.stl
new file mode 100644
index 0000000..eb49f92
Binary files /dev/null and b/stl/case_bottom_oled.stl differ
diff --git a/stl/case_lid_oled.stl b/stl/case_lid_oled.stl
new file mode 100644
index 0000000..fb9882a
Binary files /dev/null and b/stl/case_lid_oled.stl differ