oled #1
@@ -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.
|
||||
|
||||
<img src="assets/bottom1.png" width="600"><br>
|
||||
<img src="assets/case1.png" width="600"><br>
|
||||
@@ -72,6 +73,9 @@ Files download here https://git.noop.re/drops/Geiger-interface/src/branch/main/s
|
||||
<img src="assets/photo4.jpg" width="600"><br>
|
||||
<img src="assets/photo1.jpg" width="600"><br>
|
||||
<img src="assets/photo3.jpg" width="600"><br>
|
||||
<img src="assets/photo5.jpg" width="600"><br>
|
||||
<img src="assets/photo6.jpg" width="600"><br>
|
||||
<img src="assets/photo7.jpg" width="600"><br>
|
||||
|
||||
### Resources
|
||||
- https://iot-devices.com.ua/
|
||||
|
||||
BIN
assets/photo5.jpg
Normal file
BIN
assets/photo5.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 259 KiB |
BIN
assets/photo6.jpg
Normal file
BIN
assets/photo6.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 324 KiB |
BIN
assets/photo7.jpg
Normal file
BIN
assets/photo7.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 314 KiB |
@@ -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
BIN
stl/case_bottom_oled.stl
Normal file
Binary file not shown.
BIN
stl/case_lid_oled.stl
Normal file
BIN
stl/case_lid_oled.stl
Normal file
Binary file not shown.
Reference in New Issue
Block a user