ESPGeiger

More
1 day 13 hours ago #7312 by ChrisLX200
Replied by ChrisLX200 on topic ESPGeiger
I need to check voltages on these Cajoe boards, I noticed current draw varied from ~150mA up to ~300mA between the three.

Please Log in or Create an account to join the conversation.

More
7 hours 30 minutes ago #7314 by Simomax
Replied by Simomax on topic ESPGeiger
Ahh, I think you may have hit the nail on the head - not all ESP32's (or ESP8266's) are equal, as I have found out in the past. I generally stick to ESP32 Dev Kits v3/v4 (dev boards) and Wemos D1 Mini's or clones thereof. I have had a handful of different ESP modules over the years with little to no joy getting them to work easily, as in straight out of the box. As you are using a Meshtastic (I think) type of module, this may use a slightly different flavour of ESP32. In fact, looking at the metal can on yours the text is a little different. I generally use the ESP32-WROOM-32D ESP32's and ZY8266MOD ESP8266's, and since sticking to those two specific flavours, which seem to come on nearly all dev boards, I have hardly had any issues. You will be able to get others working, but will probably require specific settings for the memory/speeds/DIO mode (I forget what that is, but fell over it once!) etc. So it's just a matter of getting all of your ducks in a line and then it should work. For ease of use I just stick with the two I have been using.

     

Under the metal can on an ESP32/ESP8266 there is more than just the main MCU. You can see in the picture (of one I blew up earlier ) there is also an 8-pin SOP, which I think may be the EEPROM. Some have different memory capacities and there may be other differences. Putting it all together there could be 4,5 maybe 6 settings that all need to align with the actual MCU module you are using.

 

I would like to steal some of your Arduino code for uploading data to Radmon are you OK with that?

If you mean some of my code, here, on this forum, then sure, go for it. I posted it purely for people to use. It is very basic, but is the nuts and bolts needed to upload to Radmon with that particular device (at the time of writing I should add - The IDE changes, and so do libraries and other bits, so may or may not work now or in the future.)

I need to check voltages on these Cajoe boards, I noticed current draw varied from ~150mA up to ~300mA between the three.

That's one hell of a difference! ~20ma maybe, but ~150ma? Is that including your ESP32, or just the CAJOE boards? It is always worth checking the voltage at the tube, if you have facilities to do so. Something I have been meaning to do with the CAJOE, which you may be in a better place to do having three of them, is see if they are sensitive to temperature changes. I suspect they are, and I suspect the change could be quite dramatic. I'd like to see the difference between room temp and say 50 degrees C (oven on lowest) and also room temp and say, 5 degrees C (refrigerator). I think there could a quite a variance between 5 degrees and 50. As you have a few boards it would be good to see if the different boards vary differently, which I suspect they might also. If you can't do this, or just don't want to let me know and I can perform the tests, but I only have one spare CAJOE as my other one is in situ and running.
Attachments:

Please Log in or Create an account to join the conversation.

More
6 hours 19 minutes ago - 2 hours 12 minutes ago #7315 by ChrisLX200
Replied by ChrisLX200 on topic ESPGeiger
After two 4am coding sessions trying to get my head around Platformio I can say I'm only slightly wiser and nowhere near capable of resolving the issues I'm having with the V.7 ESPGeiger. My AI assistant is thick as a brick at times and although invaluable gives me some BS code snippets to try! Anyway, the problem is Steadramon's implementation of the WiFiManager library, I know the basic method works because I have it functional in my paltry Arduino code effort*. It creates the Access Point and I can configure WiFi access without using hard-coded credentials. It's such a pity I can't get ESPGeiger working because it's exactly what I need and so much effort has already been put into its development that is wasted if it can't be fixed. And yes, I tried an earlier 6.nn version but encountered the same issue, I'm not sure how far I need to go back to find a version that may possibly work.I will continue with my Arduino project for now, thanks for your code which is much better than mine! However I'm a bit wary of uploading garbage to Radmon in the process of development, but I will need something functional so we can see long term trends.The differences between the myriad ESP32 boards should not be a problem for ESPGeiger (IMHO) as they only involve what extra features are implemented on the development board and the core CPU/speed/memory capacity, the basic functions are the same. I have 3 different dev kits at the moment (with a 4th on the way!) which are all basic ESP32-WROOM-32 v1/S2 boards, two with OLEDs and one without. The OLEDs are I2C but a TFT version is SPI. ESPGeiger is designed to work with/without onboard OLED display. However ESPGeiger never gets further than trying to connect to WiFi which is a very basic function it runs early so any other differences are probably irrelevant at this point - and like I said, WiFiManager definitely works with the boards I have if it's coded right.Yes I do have a high voltage probe with which I can measure voltage at the tube without loading it down. I haven't done that yet though. It's something I need to do to ensure all three counters are as near balanced as I can make them. The current draw is a puzzle, it is measured as the current consumption with both ESP32 and board running together. One board's 'clicks' are noticeably at a very different pitch than the other two but all three are are actually different from each other. Might be just the cheap Piezos they use. I think temperature does affect all GM tubes to some extent, like it does with scintillators, and it would an interesting experiment when/if I get all 3 working in harmony :-). Another thought between different manufacturers of these tubes is what gas mixture is used inside, I doubt they're all the same. That's why I bought all 3 from the same source as they should be similar in most respects - but probably not representative of the wide range currently out there. The J305b are made in different factories and I would bet money they don't talk to each other or stick to some specification (I don't think there is one!). If it makes a click that's good enough. SBM20s on the other hand were probably all made to an accurate spec and are more consistant and dependable.

Edit: *also added a push button to pin 14 - same as ESPGeiger - but in my case it provides On Demand creation of new WiFi credentials via WiFiManager. At any time push the button to start the access point to enter new credentials, otherwise it uses those stored in flash. 
#define VERSION "V1.5.0"

#include <WiFiManager.h>
#include <WiFi.h>
#include <SSD1306.h>
#include <esp_task_wdt.h>

#define GEIGER_INPUT_PIN 13
#define BUTTON_PIN 14
#define CONVERSION_FACTOR 154.0
#define PERIOD_LOG 15
#define CONFIG_PORTAL_TIMEOUT 120
#define WDT_TIMEOUT_MS 10000

int counts = 0;
int cpm = 0;
float usv = 0.0;
unsigned long lastCountTime, startCountTime;

SSD1306 display(0x3c, 5, 4);

void IRAM_ATTR ISR_impulse() {
  counts++;
}

// ========== OLED ==========
void displayInit() {
  display.init();
  display.flipScreenVertically();
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.setFont(ArialMT_Plain_10);
  display.drawString(0, 0, "Radiation Monitor");
  display.display();
}

void showStatus(const String &line1, const String &line2 = "") {
  display.clear();
  display.setFont(ArialMT_Plain_10);
  display.drawString(0, 20, line1);
  display.drawString(0, 34, line2);
  display.display();
}

void showReadings(int cpm, float usv) {
  display.clear();
  display.setFont(ArialMT_Plain_10);
  display.drawString(0, 0, "Radiation Monitor");
  display.setFont(ArialMT_Plain_16);
  display.drawString(0, 18, "CPM: " + String(cpm));
  display.drawString(0, 40, "uSv/h: " + String(usv, 2));
  display.display();
}

// ========== WIFI SETUP ==========
void connectWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.begin();

  showStatus("Connecting to WiFi...");
  Serial.println("Connecting to saved WiFi...");

  unsigned long start = millis();
  while (WiFi.status() != WL_CONNECTED && millis() - start < 15000) {
    delay(250);
    Serial.print(".");
  }

  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("\nConnected! IP: ");
    Serial.println(WiFi.localIP());
    showStatus("WiFi Connected", WiFi.localIP().toString());
    delay(1000);
  } else {
    Serial.println("\nWiFi not connected.");
    showStatus("WiFi not set.", "Press button to config");
  }
}

void launchConfigPortal() {
  Serial.println("Launching WiFi config portal...");

  WiFiManager wm;
  wm.setConfigPortalTimeout(CONFIG_PORTAL_TIMEOUT);

  wm.resetSettings();  // ? Clear previous credentials!

  showStatus("Starting WiFi", "Config Portal...");

  esp_task_wdt_deinit();  // Disable watchdog during portal

  if (!wm.startConfigPortal("ESPGeiger")) {
    Serial.println("WiFiManager timeout. Restarting...");
    showStatus("Config Timeout", "Rebooting...");
    delay(2000);
    ESP.restart();
  }

  Serial.println("WiFi credentials saved.");
  showStatus("WiFi Config", "Rebooting...");
  delay(2000);
  ESP.restart();
}


// ========== SETUP ==========
void setup() {
  Serial.begin(115200);
  Serial.println("Starting Geiger Counter " VERSION);

  pinMode(GEIGER_INPUT_PIN, INPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  displayInit();
  connectWiFi();

  // Only attach interrupts if WiFi is working
  if (WiFi.status() == WL_CONNECTED) {
    attachInterrupt(digitalPinToInterrupt(GEIGER_INPUT_PIN), ISR_impulse, FALLING);
    startCountTime = lastCountTime = millis();
    esp_task_wdt_config_t wdt_config = {
  .timeout_ms = WDT_TIMEOUT_MS,
  .idle_core_mask = (1 << portNUM_PROCESSORS) - 1,
  .trigger_panic = true
};
esp_task_wdt_init(&wdt_config);

    esp_task_wdt_add(NULL);
  }
}

// ========== LOOP ==========
void loop() {
  // On-demand config: press button any time
  if (digitalRead(BUTTON_PIN) == LOW) {
    delay(50); // Debounce
    if (digitalRead(BUTTON_PIN) == LOW) {
      Serial.println("WiFi config button pressed.");
      launchConfigPortal();
    }
  }

  // Only run main logic if WiFi is working
  if (WiFi.status() == WL_CONNECTED) {
    esp_task_wdt_reset();

    if (millis() - lastCountTime > PERIOD_LOG * 1000) {
      unsigned long now = millis();
      cpm = (60000 * counts) / (now - startCountTime);
      usv = (float)cpm / CONVERSION_FACTOR;

      counts = 0;
      startCountTime = now;
      lastCountTime += PERIOD_LOG * 1000;

      showReadings(cpm, usv);

      Serial.print("CPM: ");
      Serial.print(cpm);
      Serial.print(" | uSv/h: ");
      Serial.println(usv, 2);
    }
  }

  delay(50);
}
 
Attachments:
Last edit: 2 hours 12 minutes ago by ChrisLX200.

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.168 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 29% Memory 14% Swap 0% CPU temp=52.5'C Uptime 9:41, Days