├── .github └── workflows │ └── build.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── hardware └── kicad │ ├── lib │ ├── geiger.dcm │ └── geiger.lib │ └── project │ └── geiger │ ├── geiger-cache.lib │ ├── geiger.kicad_pcb │ ├── geiger.pro │ ├── geiger.sch │ └── sym-lib-table ├── include ├── GeigerData.h ├── README ├── credentials.h ├── display.h └── ingest.h ├── lib └── README ├── media ├── geiger-counter-pcb.jpg ├── geiger-signal-formed.png ├── geiger-signal-raw.png ├── kicad-circuit-sketch.png ├── pulse-forming-schematic.png └── thingspeak.png ├── platformio.ini ├── src ├── GeigerData.cpp ├── TEMPLATE_secret_credentials.h ├── credentials.cpp ├── display.cpp ├── ingest.cpp └── main.cpp └── test └── README /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: PlatformIO CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Cache pip 13 | uses: actions/cache@v2 14 | with: 15 | path: ~/.cache/pip 16 | key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} 17 | restore-keys: | 18 | ${{ runner.os }}-pip- 19 | - name: Cache PlatformIO 20 | uses: actions/cache@v2 21 | with: 22 | path: ~/.platformio 23 | key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} 24 | - name: Set up Python 25 | uses: actions/setup-python@v2 26 | - name: Install PlatformIO 27 | run: | 28 | python -m pip install --upgrade pip 29 | pip install --upgrade platformio 30 | - name: Run PlatformIO 31 | run: pio run 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | .pioenvs 3 | .piolibdeps 4 | .vscode 5 | secret_* 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.7" 4 | 5 | sudo: false 6 | cache: 7 | directories: 8 | - "~/.platformio" 9 | - $HOME/.cache/pip 10 | 11 | install: 12 | - pip install -U platformio 13 | - pio update 14 | 15 | script: 16 | - pio run 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Holger Fleischmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![PlatformIO CI](https://github.com/grillbaer/esp32-geiger-counter/workflows/PlatformIO%20CI/badge.svg) [![Build Status](https://travis-ci.org/grillbaer/esp32-geiger-counter.svg?branch=master)](https://travis-ci.org/grillbaer/esp32-geiger-counter) 2 | 3 | # IoT Geiger Counter with ESP32, OLED Display, Thingspeak Channel and MQTT 4 | 5 | - Measures radioactive gamma and beta radiation with quite good resolution at the typical low levels of the natural radiation (due to the big STS-6 tube) 6 | - Displays the current counts per minute (CPM), estimated dose equivalent rate in micro-Sievert per hour (µS/h) and 10 minutes history with 5 second resolution as bargraph 7 | ![Circuit Board](media/geiger-counter-pcb.jpg) 8 | - Low-power mode for use with batteries, OLED display and click sounds on, WiFi off 9 | - WiFi mode for 10 | - optional thingspeak data upload every minute, see https://thingspeak.com/channels/758223 11 | [![https://thingspeak.com/channels/758223](media/thingspeak.png)](https://thingspeak.com/channels/758223) 12 | - MQTT publishing to a broker every minute with optional SSL/TLS support 13 | 14 | Feel free to use this project as a base for your own projects AT YOUR OWN RISK! 15 | 16 | # Hardware 17 | 18 | - Russian Geiger counter tube STS-6 (CTC-6) at 400 V with ~5 MΩ series resistor 19 | - High voltage circuit from ArnoR at mikrocontroller.net https://www.mikrocontroller.net/topic/380666, schematic https://www.mikrocontroller.net/attachment/273334/HystereseStepUpTLC555-2.png. *Keep the high-voltage capacitor small to avoid dangerous charges! For safety avoid any contact with the high voltage parts!* 20 | - ~400 µs pulse generation using Geiger tube series resistors as voltage divider, high impedance input to darlington transistor and TLC 555 timer for rectangle pulse generation (schematic and pulses see below) 21 | - ESP32 board EzSBC ESP32-01 22 | - OLED 128x64 with controller SH1106 at I2C 23 | - Voltage supply from either USB or power supply or 3x 1.5V AAA batteries, circuit works stable from 3.0 V up to 5.0 V 24 | - Pulse input is expected at GPIO 15 (high pulses with at least about 250 µs length) 25 | - Switch for WiFi mode is expected at GPIO 4 (low=WiFi mode, high=low-power mode) 26 | - OLED I2C bus is expected at GPIO 22 (SCK) and 21 (SDA) 27 | - Pins may be adjusted in `main.cpp` 28 | 29 | # Software 30 | 31 | - [PlatformIO VSCode project](https://github.com/platformio/platformio-vscode-ide) using [Arduino](https://github.com/arduino/Arduino) library, [Espressif ESP-IDF](https://github.com/espressif/esp-idf) for sleep functions, [U8g2](https://github.com/olikraus/u8g2) for display output and [Arduino-MQTT](https://github.com/256dpi/arduino-mqtt). 32 | - Low-power mode uses light sleep, a wake-up for each signal pulse change and a wake-up every 1000 ms to update pulse statistics and OLED. This results in about 90% sleep. Could be improved using deep sleep and ULP. However, light sleep is already quite good and much easier. 33 | - WiFi mode uses no sleep and simple interrupts for pulse counting. Pulse statistics and OLED are updated every 1000 ms, data is sent to thingspeak every 60 s. 34 | - Credentials, addresses and user for WiFi, thingspeak channel and mqtt broker are declared in `credentials.h` and replaced by dummy values in `credentials.cpp` by default. Define your real secrets in a sibling file named `secret_credentials.h` (do never commit!). It will be automatically included by `credentials.cpp` if it exists. You may copy `TEMPLATE_secret_credentials.h` as a starting point. 35 | 36 | # MQTT Message Format 37 | 38 | Published messages have the following JSON format: 39 | ```json 40 | { 41 | "pulses": 69, 42 | "cpm": 69, 43 | "uSph": 0.08, 44 | "secs": 60 45 | } 46 | ``` 47 | 48 | # Geiger Tube Pulse Forming 49 | 50 | ![Pulse forming schematic](media/pulse-forming-schematic.png) 51 | 52 | The 5.4 MΩ series resistor is split up to reduce the voltage on each of them. The diode partially removes the noise spikes from the high voltage circuit. 53 | 54 | This is the raw pulse at point A, about 2 V for less than 100 µs, then falling back to 0 V in the next several 100 µs. Remainings of the little noise spikes are still visible: 55 | 56 | ![Raw pulse at point A](media/geiger-signal-raw.png) 57 | 58 | This is the formed pulse at point B, from 5 V to about 0.5 V for 200 µs: 59 | 60 | ![Formed pulse at output point B](media/geiger-signal-formed.png) 61 | 62 | It is then fed into a 555 timer to further extend its duration for the ESP32 wake-up from low-power mode. 63 | 64 | # Schematic 65 | 66 | KiCad files are located in folder `hardware`. Currently only schematic, no PCB. 67 | 68 | ![Schematics](media/kicad-circuit-sketch.png) 69 | -------------------------------------------------------------------------------- /hardware/kicad/lib/geiger.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | $CMP MPSA44 4 | D 0.5A Ic, 400V Vce, NPN High Voltage Transistor, TO-92 5 | K NPN High Voltage Transistor 6 | F http://www.onsemi.com/pub_link/Collateral/MPSA42-D.PDF 7 | $ENDCMP 8 | # 9 | #End Doc Library 10 | -------------------------------------------------------------------------------- /hardware/kicad/lib/geiger.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # ADS1115_ADC_Module 5 | # 6 | DEF ADS1115_ADC_Module U 0 40 Y Y 1 F N 7 | F0 "U" 300 150 50 H V C CNN 8 | F1 "ADS1115_ADC_Module" 350 50 50 H V C CNN 9 | F2 "" 300 150 50 H I C CNN 10 | F3 "" 300 150 50 H I C CNN 11 | DRAW 12 | S 100 -50 550 -1150 0 1 0 f 13 | X A3 1 0 -1050 100 R 50 50 1 1 I 14 | X VDD 10 0 -150 100 R 50 50 1 1 W 15 | X A2 2 0 -950 100 R 50 50 1 1 I 16 | X A1 3 0 -850 100 R 50 50 1 1 I 17 | X A0 4 0 -750 100 R 50 50 1 1 I 18 | X ALRT 5 650 -650 100 L 50 50 1 1 O 19 | X ADDR 6 650 -550 100 L 50 50 1 1 I 20 | X SDA 7 650 -450 100 L 50 50 1 1 B 21 | X SCL 8 650 -350 100 L 50 50 1 1 I 22 | X GND 9 0 -250 100 R 50 50 1 1 W 23 | ENDDRAW 24 | ENDDEF 25 | # 26 | # EzSBC_ESP32-01 27 | # 28 | DEF EzSBC_ESP32-01 U 0 40 Y Y 1 F N 29 | F0 "U" 0 900 50 H V C CNN 30 | F1 "EzSBC_ESP32-01" 0 750 50 H V C CNN 31 | F2 "" 0 900 50 H I C CNN 32 | F3 "" 0 900 50 H I C CNN 33 | DRAW 34 | S -850 1050 850 -1050 0 1 0 f 35 | X GND 20 -950 -950 100 R 50 50 0 0 W 36 | X GND 21 950 -950 100 L 50 50 0 0 W 37 | X Vin 22 950 -850 100 L 50 50 0 0 W 38 | X 3.3V 23 950 -750 100 L 50 50 0 0 w 39 | X GND 3 -950 750 100 R 50 50 0 0 W 40 | X 3.3V 32 950 150 100 L 50 50 0 0 w 41 | X Vin 37 950 650 100 L 50 50 0 0 W 42 | X GND 38 950 750 100 L 50 50 0 0 W 43 | X IO36 1 -950 950 100 R 50 50 1 1 I 44 | X IO25/RTC6 10 -950 50 100 R 50 50 1 1 B 45 | X IO26/RTC7 11 -950 -50 100 R 50 50 1 1 B 46 | X IO27/RTC17 12 -950 -150 100 R 50 50 1 1 B 47 | X n.c. 13 -950 -250 100 R 50 50 1 1 N 48 | X IO23/VSPI_MOSI 14 -950 -350 100 R 50 50 1 1 B 49 | X IO22/I2C_SCL 15 -950 -450 100 R 50 50 1 1 B 50 | X IO21/I2C_SDA 16 -950 -550 100 R 50 50 1 1 B 51 | X EN/Reset 17 -950 -650 100 R 50 50 1 1 I 52 | X 3.3V 18 -950 -750 100 R 50 50 1 1 w 53 | X Vin 19 -950 -850 100 R 50 50 1 1 W 54 | X IO39 2 -950 850 100 R 50 50 1 1 I 55 | X IO0/RTC11/Boot 24 950 -650 100 L 50 50 1 1 B 56 | X IO2/RTC12 25 950 -550 100 L 50 50 1 1 B 57 | X IO4/RTC10 26 950 -450 100 L 50 50 1 1 B 58 | X IO5/VSPI_SS 27 950 -350 100 L 50 50 1 1 B 59 | X IO12/RTC15/HSPI_MISO 28 950 -250 100 L 50 50 1 1 B 60 | X IO13/RTC14/HSPI_MOSI 29 950 -150 100 L 50 50 1 1 B 61 | X IO14/RTC16/HSPI_SCK 30 950 -50 100 L 50 50 1 1 B 62 | X IO15/RTC13/HSPI_SS 31 950 50 100 L 50 50 1 1 B 63 | X IO16/L1_RED 33 950 250 100 L 50 50 1 1 B 64 | X IO17/L1_GREEN 34 950 350 100 L 50 50 1 1 B 65 | X IO18/VSPI_SCK/L1_BLUE 35 950 450 100 L 50 50 1 1 B 66 | X IO19/VSPI_MISO/L2_BLUE 36 950 550 100 L 50 50 1 1 B 67 | X IO3/RX0 39 950 850 100 L 50 50 1 1 I 68 | X Vin 4 -950 650 100 R 50 50 1 1 W 69 | X IO1/TX0 40 950 950 100 L 50 50 1 1 O 70 | X IO35 5 -950 550 100 R 50 50 1 1 I 71 | X IO34 6 -950 450 100 R 50 50 1 1 I 72 | X IO33/RTC8 7 -950 350 100 R 50 50 1 1 B 73 | X IO32/RTC9 8 -950 250 100 R 50 50 1 1 B 74 | X 3.3V 9 -950 150 100 R 50 50 1 1 w 75 | ENDDRAW 76 | ENDDEF 77 | # 78 | # MPSA44 79 | # 80 | DEF MPSA44 Q 0 40 Y N 1 F N 81 | F0 "Q" 200 75 50 H V L CNN 82 | F1 "MPSA44" 200 0 50 H V L CNN 83 | F2 "Package_TO_SOT_THT:TO-92_Inline" 200 -75 50 H I L CIN 84 | F3 "" 0 0 50 H I L CNN 85 | $FPLIST 86 | TO?92* 87 | $ENDFPLIST 88 | DRAW 89 | C 50 0 111 0 1 10 N 90 | P 2 0 1 0 0 0 25 0 N 91 | P 2 0 1 0 25 25 100 100 N 92 | P 3 0 1 0 25 -25 100 -100 100 -100 N 93 | P 3 0 1 20 25 75 25 -75 25 -75 N 94 | P 5 0 1 0 50 -70 70 -50 90 -90 50 -70 50 -70 F 95 | X E 1 100 -200 100 U 50 50 1 1 P 96 | X B 2 -200 0 200 R 50 50 1 1 I 97 | X C 3 100 200 100 D 50 50 1 1 P 98 | ENDDRAW 99 | ENDDEF 100 | # 101 | # Pressure_R_Bridge 102 | # 103 | DEF Pressure_R_Bridge U 0 40 Y Y 1 F N 104 | F0 "U" 650 -850 50 V V C CNN 105 | F1 "Pressure_R_Bridge" 550 -850 50 V V C CNN 106 | F2 "" 650 -850 50 V I C CNN 107 | F3 "" 650 -850 50 V I C CNN 108 | DRAW 109 | A -450 -850 50 -899 899 0 1 0 N -450 -900 -450 -800 110 | S -450 -450 450 -1250 0 1 0 f 111 | S -250 -1000 -50 -1100 0 1 0 N 112 | S -250 -700 -50 -600 0 1 0 N 113 | S 50 -1100 250 -1000 0 1 0 N 114 | S 50 -600 250 -700 0 1 0 N 115 | P 2 0 1 4 -50 -1050 50 -1050 N 116 | P 2 0 1 4 0 -1050 0 -1250 N 117 | P 2 0 1 4 0 -450 0 -650 N 118 | P 2 0 1 4 50 -650 -50 -650 N 119 | P 3 0 1 4 -300 -1250 -300 -1050 -250 -1050 N 120 | P 3 0 1 4 -300 -450 -300 -650 -250 -650 N 121 | P 3 0 1 0 -200 -1000 -150 -1100 -100 -1000 N 122 | P 3 0 1 0 -200 -700 -150 -600 -100 -700 N 123 | P 3 0 1 0 100 -1100 150 -1000 200 -1100 N 124 | P 3 0 1 0 100 -600 150 -700 200 -600 N 125 | P 5 0 1 4 250 -1050 300 -1050 300 -450 300 -650 250 -650 N 126 | X A_low 1 -300 -1350 100 U 50 50 1 1 P 127 | X A_mid 2 0 -1350 100 U 50 50 1 1 P 128 | X n.c. 3 300 -1350 100 U 50 50 1 1 N 129 | X AB_top 4 300 -350 100 D 50 50 1 1 P 130 | X B_mid 5 0 -350 100 D 50 50 1 1 P 131 | X B_low 6 -300 -350 100 D 50 50 1 1 P 132 | ENDDRAW 133 | ENDDEF 134 | # 135 | #End Library 136 | -------------------------------------------------------------------------------- /hardware/kicad/project/geiger/geiger-cache.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # Connector_Conn_01x02_Male 5 | # 6 | DEF Connector_Conn_01x02_Male J 0 40 Y N 1 F N 7 | F0 "J" 0 100 50 H V C CNN 8 | F1 "Connector_Conn_01x02_Male" 0 -200 50 H V C CNN 9 | F2 "" 0 0 50 H I C CNN 10 | F3 "" 0 0 50 H I C CNN 11 | $FPLIST 12 | Connector*:*_1x??_* 13 | $ENDFPLIST 14 | DRAW 15 | S 34 -95 0 -105 1 1 6 F 16 | S 34 5 0 -5 1 1 6 F 17 | P 2 1 1 6 50 -100 34 -100 N 18 | P 2 1 1 6 50 0 34 0 N 19 | X Pin_1 1 200 0 150 L 50 50 1 1 P 20 | X Pin_2 2 200 -100 150 L 50 50 1 1 P 21 | ENDDRAW 22 | ENDDEF 23 | # 24 | # Connector_Conn_01x04_Female 25 | # 26 | DEF Connector_Conn_01x04_Female J 0 40 Y N 1 F N 27 | F0 "J" 0 200 50 H V C CNN 28 | F1 "Connector_Conn_01x04_Female" 0 -300 50 H V C CNN 29 | F2 "" 0 0 50 H I C CNN 30 | F3 "" 0 0 50 H I C CNN 31 | $FPLIST 32 | Connector*:*_1x??_* 33 | $ENDFPLIST 34 | DRAW 35 | A 0 -200 20 901 -901 1 1 6 N 0 -180 0 -220 36 | A 0 -100 20 901 -901 1 1 6 N 0 -80 0 -120 37 | A 0 0 20 901 -901 1 1 6 N 0 20 0 -20 38 | A 0 100 20 901 -901 1 1 6 N 0 120 0 80 39 | P 2 1 1 6 -50 -200 -20 -200 N 40 | P 2 1 1 6 -50 -100 -20 -100 N 41 | P 2 1 1 6 -50 0 -20 0 N 42 | P 2 1 1 6 -50 100 -20 100 N 43 | X Pin_1 1 -200 100 150 R 50 50 1 1 P 44 | X Pin_2 2 -200 0 150 R 50 50 1 1 P 45 | X Pin_3 3 -200 -100 150 R 50 50 1 1 P 46 | X Pin_4 4 -200 -200 150 R 50 50 1 1 P 47 | ENDDRAW 48 | ENDDEF 49 | # 50 | # Connector_Screw_Terminal_01x02 51 | # 52 | DEF Connector_Screw_Terminal_01x02 J 0 40 Y N 1 F N 53 | F0 "J" 0 100 50 H V C CNN 54 | F1 "Connector_Screw_Terminal_01x02" 0 -200 50 H V C CNN 55 | F2 "" 0 0 50 H I C CNN 56 | F3 "" 0 0 50 H I C CNN 57 | $FPLIST 58 | TerminalBlock*:* 59 | $ENDFPLIST 60 | DRAW 61 | C 0 -100 25 1 1 6 N 62 | C 0 0 25 1 1 6 N 63 | S -50 50 50 -150 1 1 10 f 64 | P 2 1 1 6 -21 -87 13 -120 N 65 | P 2 1 1 6 -21 13 13 -20 N 66 | P 2 1 1 6 -14 -80 20 -113 N 67 | P 2 1 1 6 -14 20 20 -13 N 68 | X Pin_1 1 -200 0 150 R 50 50 1 1 P 69 | X Pin_2 2 -200 -100 150 R 50 50 1 1 P 70 | ENDDRAW 71 | ENDDEF 72 | # 73 | # Device_Buzzer 74 | # 75 | DEF Device_Buzzer BZ 0 1 Y N 1 F N 76 | F0 "BZ" 150 50 50 H V L CNN 77 | F1 "Device_Buzzer" 150 -50 50 H V L CNN 78 | F2 "" -25 100 50 V I C CNN 79 | F3 "" -25 100 50 V I C CNN 80 | $FPLIST 81 | *Buzzer* 82 | $ENDFPLIST 83 | DRAW 84 | A 0 0 125 -899 899 0 1 0 N 0 -125 0 125 85 | P 2 0 1 0 -65 75 -45 75 N 86 | P 2 0 1 0 -55 85 -55 65 N 87 | P 2 0 1 0 0 125 0 -125 N 88 | X - 1 -100 100 100 R 50 50 1 1 P 89 | X + 2 -100 -100 100 R 50 50 1 1 P 90 | ENDDRAW 91 | ENDDEF 92 | # 93 | # Device_C 94 | # 95 | DEF Device_C C 0 10 N Y 1 F N 96 | F0 "C" 25 100 50 H V L CNN 97 | F1 "Device_C" 25 -100 50 H V L CNN 98 | F2 "" 38 -150 50 H I C CNN 99 | F3 "" 0 0 50 H I C CNN 100 | $FPLIST 101 | C_* 102 | $ENDFPLIST 103 | DRAW 104 | P 2 0 1 20 -80 -30 80 -30 N 105 | P 2 0 1 20 -80 30 80 30 N 106 | X ~ 1 0 150 110 D 50 50 1 1 P 107 | X ~ 2 0 -150 110 U 50 50 1 1 P 108 | ENDDRAW 109 | ENDDEF 110 | # 111 | # Device_CP 112 | # 113 | DEF Device_CP C 0 10 N Y 1 F N 114 | F0 "C" 25 100 50 H V L CNN 115 | F1 "Device_CP" 25 -100 50 H V L CNN 116 | F2 "" 38 -150 50 H I C CNN 117 | F3 "" 0 0 50 H I C CNN 118 | $FPLIST 119 | CP_* 120 | $ENDFPLIST 121 | DRAW 122 | S -90 20 90 40 0 1 0 N 123 | S 90 -20 -90 -40 0 1 0 F 124 | P 2 0 1 0 -70 90 -30 90 N 125 | P 2 0 1 0 -50 110 -50 70 N 126 | X ~ 1 0 150 110 D 50 50 1 1 P 127 | X ~ 2 0 -150 110 U 50 50 1 1 P 128 | ENDDRAW 129 | ENDDEF 130 | # 131 | # Device_D 132 | # 133 | DEF Device_D D 0 40 N N 1 F N 134 | F0 "D" 0 100 50 H V C CNN 135 | F1 "Device_D" 0 -100 50 H V C CNN 136 | F2 "" 0 0 50 H I C CNN 137 | F3 "" 0 0 50 H I C CNN 138 | $FPLIST 139 | TO-???* 140 | *_Diode_* 141 | *SingleDiode* 142 | D_* 143 | $ENDFPLIST 144 | DRAW 145 | P 2 0 1 10 -50 50 -50 -50 N 146 | P 2 0 1 0 50 0 -50 0 N 147 | P 4 0 1 10 50 50 50 -50 -50 0 50 50 N 148 | X K 1 -150 0 100 R 50 50 1 1 P 149 | X A 2 150 0 100 L 50 50 1 1 P 150 | ENDDRAW 151 | ENDDEF 152 | # 153 | # Device_D_Zener 154 | # 155 | DEF Device_D_Zener D 0 40 N N 1 F N 156 | F0 "D" 0 100 50 H V C CNN 157 | F1 "Device_D_Zener" 0 -100 50 H V C CNN 158 | F2 "" 0 0 50 H I C CNN 159 | F3 "" 0 0 50 H I C CNN 160 | $FPLIST 161 | TO-???* 162 | *_Diode_* 163 | *SingleDiode* 164 | D_* 165 | $ENDFPLIST 166 | DRAW 167 | P 2 0 1 0 50 0 -50 0 N 168 | P 3 0 1 10 -50 -50 -50 50 -30 50 N 169 | P 4 0 1 10 50 -50 50 50 -50 0 50 -50 N 170 | X K 1 -150 0 100 R 50 50 1 1 P 171 | X A 2 150 0 100 L 50 50 1 1 P 172 | ENDDRAW 173 | ENDDEF 174 | # 175 | # Device_L 176 | # 177 | DEF Device_L L 0 40 N N 1 F N 178 | F0 "L" -50 0 50 V V C CNN 179 | F1 "Device_L" 75 0 50 V V C CNN 180 | F2 "" 0 0 50 H I C CNN 181 | F3 "" 0 0 50 H I C CNN 182 | $FPLIST 183 | Choke_* 184 | *Coil* 185 | Inductor_* 186 | L_* 187 | $ENDFPLIST 188 | DRAW 189 | A 0 -75 25 -899 899 0 1 0 N 0 -100 0 -50 190 | A 0 -25 25 -899 899 0 1 0 N 0 -50 0 0 191 | A 0 25 25 -899 899 0 1 0 N 0 0 0 50 192 | A 0 75 25 -899 899 0 1 0 N 0 50 0 100 193 | X 1 1 0 150 50 D 50 50 1 1 P 194 | X 2 2 0 -150 50 U 50 50 1 1 P 195 | ENDDRAW 196 | ENDDEF 197 | # 198 | # Device_R 199 | # 200 | DEF Device_R R 0 0 N Y 1 F N 201 | F0 "R" 80 0 50 V V C CNN 202 | F1 "Device_R" 0 0 50 V V C CNN 203 | F2 "" -70 0 50 V I C CNN 204 | F3 "" 0 0 50 H I C CNN 205 | $FPLIST 206 | R_* 207 | $ENDFPLIST 208 | DRAW 209 | S -40 -100 40 100 0 1 10 N 210 | X ~ 1 0 150 50 D 50 50 1 1 P 211 | X ~ 2 0 -150 50 U 50 50 1 1 P 212 | ENDDRAW 213 | ENDDEF 214 | # 215 | # Jumper_Jumper_2_Bridged 216 | # 217 | DEF Jumper_Jumper_2_Bridged JP 0 0 Y N 1 F N 218 | F0 "JP" 0 75 50 H V C CNN 219 | F1 "Jumper_Jumper_2_Bridged" 0 -100 50 H V C CNN 220 | F2 "" 0 0 50 H I C CNN 221 | F3 "" 0 0 50 H I C CNN 222 | $FPLIST 223 | Jumper* 224 | TestPoint*2Pads* 225 | TestPoint*Bridge* 226 | $ENDFPLIST 227 | DRAW 228 | A 0 -70 100 1269 531 0 1 0 N -60 10 60 10 229 | C -80 0 20 0 0 0 N 230 | C 80 0 20 0 0 0 N 231 | X A 1 -200 0 100 R 50 50 1 1 P 232 | X B 2 200 0 100 L 50 50 1 1 P 233 | ENDDRAW 234 | ENDDEF 235 | # 236 | # Jumper_Jumper_2_Open 237 | # 238 | DEF Jumper_Jumper_2_Open JP 0 0 Y N 1 F N 239 | F0 "JP" 0 110 50 H V C CNN 240 | F1 "Jumper_Jumper_2_Open" 0 -90 50 H V C CNN 241 | F2 "" 0 0 50 H I C CNN 242 | F3 "" 0 0 50 H I C CNN 243 | $FPLIST 244 | Jumper* 245 | TestPoint*2Pads* 246 | TestPoint*Bridge* 247 | $ENDFPLIST 248 | DRAW 249 | A 0 -30 100 1269 531 0 1 0 N -60 50 60 50 250 | C -80 0 20 0 0 0 N 251 | C 80 0 20 0 0 0 N 252 | X A 1 -200 0 100 R 50 50 1 1 P 253 | X B 2 200 0 100 L 50 50 1 1 P 254 | ENDDRAW 255 | ENDDEF 256 | # 257 | # Sensor_Nuclear-Radiation_Detector 258 | # 259 | DEF Sensor_Nuclear-Radiation_Detector V 0 0 Y N 1 F N 260 | F0 "V" 200 50 50 H V L CNN 261 | F1 "Sensor_Nuclear-Radiation_Detector" 200 -50 50 H V L CNN 262 | F2 "" 200 100 50 H I C CNN 263 | F3 "" 0 0 50 H I C CNN 264 | DRAW 265 | A -125 135 16 -184 1084 0 1 0 N -110 130 -130 150 266 | A -205 135 16 -184 1084 1 1 0 N -190 130 -210 150 267 | A -175 125 16 1616 -716 1 1 0 N -190 130 -170 110 268 | A -165 95 16 -184 1084 1 1 0 N -150 90 -170 110 269 | A -165 175 16 -184 1084 1 1 0 N -150 170 -170 190 270 | A -135 165 16 1616 -716 1 1 0 N -150 170 -130 150 271 | C 0 0 111 0 1 0 N 272 | C 55 -35 10 0 1 0 F 273 | T 0 80 125 50 0 0 0 + Normal 0 C C 274 | P 2 0 1 0 -45 -60 45 -60 N 275 | P 2 0 1 0 -45 60 45 60 N 276 | P 2 0 1 0 0 -60 0 -100 N 277 | P 2 0 1 0 0 100 0 60 N 278 | P 4 0 1 0 -100 140 -120 120 -80 100 -100 140 F 279 | P 4 1 1 0 -140 100 -160 80 -120 60 -140 100 F 280 | X 1 1 0 200 100 D 50 50 1 1 P 281 | X 2 2 0 -200 100 U 50 50 1 1 P 282 | ENDDRAW 283 | ENDDEF 284 | # 285 | # Timer_TLC555xP 286 | # 287 | DEF Timer_TLC555xP U 0 20 Y Y 1 F N 288 | F0 "U" -400 350 50 H V L CNN 289 | F1 "Timer_TLC555xP" 100 350 50 H V L CNN 290 | F2 "Package_DIP:DIP-8_W7.62mm" 650 -400 50 H I C CNN 291 | F3 "" 850 -400 50 H I C CNN 292 | ALIAS LM555xN ICM7555xP LMC555xN MC1455P TLC555xP NA555P SE555P SA555P 293 | $FPLIST 294 | DIP*W7.62mm* 295 | $ENDFPLIST 296 | DRAW 297 | S -350 -300 350 300 0 1 10 f 298 | S -350 -300 350 300 0 1 10 f 299 | X GND 1 0 -400 100 U 50 50 0 0 W 300 | X VCC 8 0 400 100 D 50 50 0 0 W 301 | X TR 2 -500 200 150 R 50 50 1 1 I 302 | X Q 3 500 200 150 L 50 50 1 1 O 303 | X R 4 -500 -200 150 R 50 50 1 1 I I 304 | X CV 5 -500 0 150 R 50 50 1 1 I 305 | X THR 6 500 -200 150 L 50 50 1 1 I 306 | X DIS 7 500 0 150 L 50 50 1 1 I 307 | ENDDRAW 308 | ENDDEF 309 | # 310 | # Transistor_BJT_BC328 311 | # 312 | DEF Transistor_BJT_BC328 Q 0 0 Y N 1 F N 313 | F0 "Q" 200 75 50 H V L CNN 314 | F1 "Transistor_BJT_BC328" 200 0 50 H V L CNN 315 | F2 "Package_TO_SOT_THT:TO-92_Inline" 200 -75 50 H I L CIN 316 | F3 "" 0 0 50 H I L CNN 317 | ALIAS BC556 BC558 BC559 BC560 BC327 BC328 318 | $FPLIST 319 | TO?92* 320 | $ENDFPLIST 321 | DRAW 322 | C 50 0 111 0 1 10 N 323 | P 2 0 1 0 25 25 100 100 N 324 | P 3 0 1 0 25 -25 100 -100 100 -100 N 325 | P 3 0 1 20 25 75 25 -75 25 -75 N 326 | P 5 0 1 0 90 -70 70 -90 50 -50 90 -70 90 -70 F 327 | X C 1 100 200 100 D 50 50 1 1 P 328 | X B 2 -200 0 225 R 50 50 1 1 I 329 | X E 3 100 -200 100 U 50 50 1 1 P 330 | ENDDRAW 331 | ENDDEF 332 | # 333 | # Transistor_BJT_BC517 334 | # 335 | DEF Transistor_BJT_BC517 Q 0 0 Y N 1 F N 336 | F0 "Q" 200 75 50 H V L CNN 337 | F1 "Transistor_BJT_BC517" 200 0 50 H V L CNN 338 | F2 "Package_TO_SOT_THT:TO-92_Inline" 200 -75 50 H I L CIN 339 | F3 "" 0 0 50 H I L CNN 340 | $FPLIST 341 | TO?92* 342 | $ENDFPLIST 343 | DRAW 344 | C 50 0 111 0 1 10 N 345 | P 2 0 1 0 25 25 100 100 N 346 | P 3 0 1 0 25 -25 100 -100 100 -100 N 347 | P 3 0 1 0 25 0 100 75 100 100 N 348 | P 3 0 1 20 25 75 25 -75 25 -75 N 349 | P 5 0 1 0 50 -70 70 -50 90 -90 50 -70 50 -70 F 350 | X C 1 100 200 100 D 50 50 1 1 P 351 | X B 2 -200 0 225 R 50 50 1 1 I 352 | X E 3 100 -200 100 U 50 50 1 1 P 353 | ENDDRAW 354 | ENDDEF 355 | # 356 | # power_GND 357 | # 358 | DEF power_GND #PWR 0 0 Y Y 1 F P 359 | F0 "#PWR" 0 -250 50 H I C CNN 360 | F1 "power_GND" 0 -150 50 H V C CNN 361 | F2 "" 0 0 50 H I C CNN 362 | F3 "" 0 0 50 H I C CNN 363 | DRAW 364 | P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N 365 | X GND 1 0 0 0 D 50 50 1 1 W N 366 | ENDDRAW 367 | ENDDEF 368 | # 369 | # power_GNDPWR 370 | # 371 | DEF power_GNDPWR #PWR 0 0 Y Y 1 F P 372 | F0 "#PWR" 0 -200 50 H I C CNN 373 | F1 "power_GNDPWR" 0 -130 50 H V C CNN 374 | F2 "" 0 -50 50 H I C CNN 375 | F3 "" 0 -50 50 H I C CNN 376 | DRAW 377 | P 2 0 1 0 0 -50 0 0 N 378 | P 3 0 1 8 -40 -50 -50 -80 -50 -80 N 379 | P 3 0 1 8 -20 -50 -30 -80 -30 -80 N 380 | P 3 0 1 8 0 -50 -10 -80 -10 -80 N 381 | P 3 0 1 8 20 -50 10 -80 10 -80 N 382 | P 3 0 1 8 40 -50 -40 -50 -40 -50 N 383 | P 4 0 1 8 40 -50 30 -80 30 -80 30 -80 N 384 | X GNDPWR 1 0 0 0 D 50 50 1 1 W N 385 | ENDDRAW 386 | ENDDEF 387 | # 388 | # power_PWR_FLAG 389 | # 390 | DEF power_PWR_FLAG #FLG 0 0 N N 1 F P 391 | F0 "#FLG" 0 75 50 H I C CNN 392 | F1 "power_PWR_FLAG" 0 150 50 H V C CNN 393 | F2 "" 0 0 50 H I C CNN 394 | F3 "" 0 0 50 H I C CNN 395 | DRAW 396 | P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N 397 | X pwr 1 0 0 0 U 50 50 0 0 w 398 | ENDDRAW 399 | ENDDEF 400 | # 401 | # power_VCC 402 | # 403 | DEF power_VCC #PWR 0 0 Y Y 1 F P 404 | F0 "#PWR" 0 -150 50 H I C CNN 405 | F1 "power_VCC" 0 150 50 H V C CNN 406 | F2 "" 0 0 50 H I C CNN 407 | F3 "" 0 0 50 H I C CNN 408 | DRAW 409 | P 2 0 1 0 -30 50 0 100 N 410 | P 2 0 1 0 0 0 0 100 N 411 | P 2 0 1 0 0 100 30 50 N 412 | X VCC 1 0 0 0 U 50 50 1 1 W N 413 | ENDDRAW 414 | ENDDEF 415 | # 416 | # project_EzSBC_ESP32-01 417 | # 418 | DEF project_EzSBC_ESP32-01 U 0 40 Y Y 1 F N 419 | F0 "U" 0 900 50 H V C CNN 420 | F1 "project_EzSBC_ESP32-01" 0 750 50 H V C CNN 421 | F2 "" 0 900 50 H I C CNN 422 | F3 "" 0 900 50 H I C CNN 423 | DRAW 424 | S -850 1050 850 -1050 0 1 0 f 425 | X GND 20 -950 -950 100 R 50 50 0 0 W 426 | X GND 21 950 -950 100 L 50 50 0 0 W 427 | X Vin 22 950 -850 100 L 50 50 0 0 W 428 | X 3.3V 23 950 -750 100 L 50 50 0 0 w 429 | X GND 3 -950 750 100 R 50 50 0 0 W 430 | X 3.3V 32 950 150 100 L 50 50 0 0 w 431 | X Vin 37 950 650 100 L 50 50 0 0 W 432 | X GND 38 950 750 100 L 50 50 0 0 W 433 | X IO36 1 -950 950 100 R 50 50 1 1 I 434 | X IO25/RTC6 10 -950 50 100 R 50 50 1 1 B 435 | X IO26/RTC7 11 -950 -50 100 R 50 50 1 1 B 436 | X IO27/RTC17 12 -950 -150 100 R 50 50 1 1 B 437 | X n.c. 13 -950 -250 100 R 50 50 1 1 N 438 | X IO23/VSPI_MOSI 14 -950 -350 100 R 50 50 1 1 B 439 | X IO22/I2C_SCL 15 -950 -450 100 R 50 50 1 1 B 440 | X IO21/I2C_SDA 16 -950 -550 100 R 50 50 1 1 B 441 | X EN/Reset 17 -950 -650 100 R 50 50 1 1 I 442 | X 3.3V 18 -950 -750 100 R 50 50 1 1 w 443 | X Vin 19 -950 -850 100 R 50 50 1 1 W 444 | X IO39 2 -950 850 100 R 50 50 1 1 I 445 | X IO0/RTC11/Boot 24 950 -650 100 L 50 50 1 1 B 446 | X IO2/RTC12 25 950 -550 100 L 50 50 1 1 B 447 | X IO4/RTC10 26 950 -450 100 L 50 50 1 1 B 448 | X IO5/VSPI_SS 27 950 -350 100 L 50 50 1 1 B 449 | X IO12/RTC15/HSPI_MISO 28 950 -250 100 L 50 50 1 1 B 450 | X IO13/RTC14/HSPI_MOSI 29 950 -150 100 L 50 50 1 1 B 451 | X IO14/RTC16/HSPI_SCK 30 950 -50 100 L 50 50 1 1 B 452 | X IO15/RTC13/HSPI_SS 31 950 50 100 L 50 50 1 1 B 453 | X IO16/L1_RED 33 950 250 100 L 50 50 1 1 B 454 | X IO17/L1_GREEN 34 950 350 100 L 50 50 1 1 B 455 | X IO18/VSPI_SCK/L1_BLUE 35 950 450 100 L 50 50 1 1 B 456 | X IO19/VSPI_MISO/L2_BLUE 36 950 550 100 L 50 50 1 1 B 457 | X IO3/RX0 39 950 850 100 L 50 50 1 1 I 458 | X Vin 4 -950 650 100 R 50 50 1 1 W 459 | X IO1/TX0 40 950 950 100 L 50 50 1 1 O 460 | X IO35 5 -950 550 100 R 50 50 1 1 I 461 | X IO34 6 -950 450 100 R 50 50 1 1 I 462 | X IO33/RTC8 7 -950 350 100 R 50 50 1 1 B 463 | X IO32/RTC9 8 -950 250 100 R 50 50 1 1 B 464 | X 3.3V 9 -950 150 100 R 50 50 1 1 w 465 | ENDDRAW 466 | ENDDEF 467 | # 468 | # project_MPSA44 469 | # 470 | DEF project_MPSA44 Q 0 40 Y N 1 F N 471 | F0 "Q" 200 75 50 H V L CNN 472 | F1 "project_MPSA44" 200 0 50 H V L CNN 473 | F2 "Package_TO_SOT_THT:TO-92_Inline" 200 -75 50 H I L CIN 474 | F3 "" 0 0 50 H I L CNN 475 | $FPLIST 476 | TO?92* 477 | $ENDFPLIST 478 | DRAW 479 | C 50 0 111 0 1 10 N 480 | P 2 0 1 0 0 0 25 0 N 481 | P 2 0 1 0 25 25 100 100 N 482 | P 3 0 1 0 25 -25 100 -100 100 -100 N 483 | P 3 0 1 20 25 75 25 -75 25 -75 N 484 | P 5 0 1 0 50 -70 70 -50 90 -90 50 -70 50 -70 F 485 | X E 1 100 -200 100 U 50 50 1 1 P 486 | X B 2 -200 0 200 R 50 50 1 1 I 487 | X C 3 100 200 100 D 50 50 1 1 P 488 | ENDDRAW 489 | ENDDEF 490 | # 491 | #End Library 492 | -------------------------------------------------------------------------------- /hardware/kicad/project/geiger/geiger.kicad_pcb: -------------------------------------------------------------------------------- 1 | (kicad_pcb (version 4) (host kicad "dummy file") ) 2 | -------------------------------------------------------------------------------- /hardware/kicad/project/geiger/geiger.pro: -------------------------------------------------------------------------------- 1 | update=22/05/2015 07:44:53 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [pcbnew] 9 | version=1 10 | LastNetListRead= 11 | UseCmpFile=1 12 | PadDrill=0.600000000000 13 | PadDrillOvalY=0.600000000000 14 | PadSizeH=1.500000000000 15 | PadSizeV=1.500000000000 16 | PcbTextSizeV=1.500000000000 17 | PcbTextSizeH=1.500000000000 18 | PcbTextThickness=0.300000000000 19 | ModuleTextSizeV=1.000000000000 20 | ModuleTextSizeH=1.000000000000 21 | ModuleTextSizeThickness=0.150000000000 22 | SolderMaskClearance=0.000000000000 23 | SolderMaskMinWidth=0.000000000000 24 | DrawSegmentWidth=0.200000000000 25 | BoardOutlineThickness=0.100000000000 26 | ModuleOutlineThickness=0.150000000000 27 | [cvpcb] 28 | version=1 29 | NetIExt=net 30 | [eeschema] 31 | version=1 32 | LibDir= 33 | [eeschema/libraries] 34 | -------------------------------------------------------------------------------- /hardware/kicad/project/geiger/geiger.sch: -------------------------------------------------------------------------------- 1 | EESchema Schematic File Version 4 2 | EELAYER 30 0 3 | EELAYER END 4 | $Descr A4 11693 8268 5 | encoding utf-8 6 | Sheet 1 1 7 | Title "ESP32 Geiger Counter" 8 | Date "2021-03-07" 9 | Rev "" 10 | Comp "Holger Fleischmann" 11 | Comment1 "" 12 | Comment2 "" 13 | Comment3 "" 14 | Comment4 "" 15 | $EndDescr 16 | $Comp 17 | L Timer:TLC555xP U2 18 | U 1 1 60147334 19 | P 1650 3200 20 | F 0 "U2" H 1350 3600 50 0000 C CNN 21 | F 1 "TLC555xP" H 1650 3200 50 0000 C CNN 22 | F 2 "Package_DIP:DIP-8_W7.62mm" H 2300 2800 50 0001 C CNN 23 | F 3 "http://www.ti.com/lit/ds/symlink/tlc555.pdf" H 2500 2800 50 0001 C CNN 24 | 1 1650 3200 25 | 1 0 0 -1 26 | $EndComp 27 | $Comp 28 | L Transistor_BJT:BC328 Q1 29 | U 1 1 60149CD9 30 | P 1150 2150 31 | F 0 "Q1" H 1341 2104 50 0000 L CNN 32 | F 1 "BC328" H 1341 2195 50 0000 L CNN 33 | F 2 "Package_TO_SOT_THT:TO-92_Inline" H 1350 2075 50 0001 L CIN 34 | F 3 "http://www.redrok.com/PNP_BC327_-45V_-800mA_0.625W_Hfe100_TO-92.pdf" H 1150 2150 50 0001 L CNN 35 | 1 1150 2150 36 | -1 0 0 1 37 | $EndComp 38 | $Comp 39 | L project:MPSA44 Q2 40 | U 1 1 6014CD74 41 | P 2850 3000 42 | F 0 "Q2" H 3041 3046 50 0000 L CNN 43 | F 1 "MPSA44" H 3041 2955 50 0000 L CNN 44 | F 2 "Package_TO_SOT_THT:TO-92_Inline" H 3050 2925 50 0001 L CIN 45 | F 3 "http://www.onsemi.com/pub_link/Collateral/MPSA42-D.PDF" H 2850 3000 50 0001 L CNN 46 | 1 2850 3000 47 | 1 0 0 -1 48 | $EndComp 49 | $Comp 50 | L Device:D_Zener D3 51 | U 1 1 6014D6FE 52 | P 4150 3150 53 | F 0 "D3" V 4104 3230 50 0000 L CNN 54 | F 1 "200V" V 4195 3230 50 0000 L CNN 55 | F 2 "" H 4150 3150 50 0001 C CNN 56 | F 3 "~" H 4150 3150 50 0001 C CNN 57 | 1 4150 3150 58 | 0 1 1 0 59 | $EndComp 60 | $Comp 61 | L Device:D_Zener D2 62 | U 1 1 6014E074 63 | P 4150 2850 64 | F 0 "D2" V 4104 2930 50 0000 L CNN 65 | F 1 "200V" V 4195 2930 50 0000 L CNN 66 | F 2 "" H 4150 2850 50 0001 C CNN 67 | F 3 "~" H 4150 2850 50 0001 C CNN 68 | 1 4150 2850 69 | 0 1 1 0 70 | $EndComp 71 | $Comp 72 | L Device:L L1 73 | U 1 1 6014E85C 74 | P 2950 2400 75 | F 0 "L1" H 2800 2450 50 0000 L CNN 76 | F 1 "10m" H 2750 2350 50 0000 L CNN 77 | F 2 "" H 2950 2400 50 0001 C CNN 78 | F 3 "~" H 2950 2400 50 0001 C CNN 79 | 1 2950 2400 80 | 1 0 0 -1 81 | $EndComp 82 | $Comp 83 | L Device:R R7 84 | U 1 1 6015014A 85 | P 2950 1900 86 | F 0 "R7" H 3150 1850 50 0000 R CNN 87 | F 1 "15" H 3150 1950 50 0000 R CNN 88 | F 2 "" V 2880 1900 50 0001 C CNN 89 | F 3 "~" H 2950 1900 50 0001 C CNN 90 | 1 2950 1900 91 | -1 0 0 1 92 | $EndComp 93 | $Comp 94 | L Device:R R6 95 | U 1 1 60150993 96 | P 2900 3750 97 | F 0 "R6" V 3000 3750 50 0000 C CNN 98 | F 1 "10k" V 2800 3750 50 0000 C CNN 99 | F 2 "" V 2830 3750 50 0001 C CNN 100 | F 3 "~" H 2900 3750 50 0001 C CNN 101 | 1 2900 3750 102 | 0 -1 -1 0 103 | $EndComp 104 | $Comp 105 | L Device:R R5 106 | U 1 1 601514C6 107 | P 2350 3750 108 | F 0 "R5" V 2250 3750 50 0000 C CNN 109 | F 1 "100k" V 2450 3750 50 0000 C CNN 110 | F 2 "" V 2280 3750 50 0001 C CNN 111 | F 3 "~" H 2350 3750 50 0001 C CNN 112 | 1 2350 3750 113 | 0 1 1 0 114 | $EndComp 115 | $Comp 116 | L power:GND #PWR04 117 | U 1 1 60152872 118 | P 2950 3300 119 | F 0 "#PWR04" H 2950 3050 50 0001 C CNN 120 | F 1 "GND" H 2955 3127 50 0000 C CNN 121 | F 2 "" H 2950 3300 50 0001 C CNN 122 | F 3 "" H 2950 3300 50 0001 C CNN 123 | 1 2950 3300 124 | 1 0 0 -1 125 | $EndComp 126 | $Comp 127 | L Device:C C1 128 | U 1 1 60154776 129 | P 3650 3000 130 | F 0 "C1" H 3765 3046 50 0000 L CNN 131 | F 1 "47n" H 3765 2955 50 0000 L CNN 132 | F 2 "" H 3688 2850 50 0001 C CNN 133 | F 3 "~" H 3650 3000 50 0001 C CNN 134 | 1 3650 3000 135 | 1 0 0 -1 136 | $EndComp 137 | $Comp 138 | L Device:R R3 139 | U 1 1 601553A6 140 | P 5400 2050 141 | F 0 "R3" H 5470 2096 50 0000 L CNN 142 | F 1 "1M8" H 5470 2005 50 0000 L CNN 143 | F 2 "" V 5330 2050 50 0001 C CNN 144 | F 3 "~" H 5400 2050 50 0001 C CNN 145 | 1 5400 2050 146 | 1 0 0 -1 147 | $EndComp 148 | $Comp 149 | L Device:R R2 150 | U 1 1 6015E49D 151 | P 5400 1750 152 | F 0 "R2" H 5470 1796 50 0000 L CNN 153 | F 1 "1M8" H 5470 1705 50 0000 L CNN 154 | F 2 "" V 5330 1750 50 0001 C CNN 155 | F 3 "~" H 5400 1750 50 0001 C CNN 156 | 1 5400 1750 157 | 1 0 0 -1 158 | $EndComp 159 | $Comp 160 | L Device:R R1 161 | U 1 1 6015E703 162 | P 5400 1450 163 | F 0 "R1" H 5470 1496 50 0000 L CNN 164 | F 1 "1M8" H 5470 1405 50 0000 L CNN 165 | F 2 "" V 5330 1450 50 0001 C CNN 166 | F 3 "~" H 5400 1450 50 0001 C CNN 167 | 1 5400 1450 168 | 1 0 0 -1 169 | $EndComp 170 | $Comp 171 | L Device:R R4 172 | U 1 1 6014F66C 173 | P 2350 3000 174 | F 0 "R4" V 2250 3000 50 0000 C CNN 175 | F 1 "1k5" V 2450 3000 50 0000 C CNN 176 | F 2 "" V 2280 3000 50 0001 C CNN 177 | F 3 "~" H 2350 3000 50 0001 C CNN 178 | 1 2350 3000 179 | 0 1 1 0 180 | $EndComp 181 | Wire Wire Line 182 | 2150 3000 2200 3000 183 | Wire Wire Line 184 | 2500 3000 2600 3000 185 | Wire Wire Line 186 | 2600 3000 2600 3200 187 | Wire Wire Line 188 | 2600 3200 2150 3200 189 | Connection ~ 2600 3000 190 | Wire Wire Line 191 | 2600 3000 2650 3000 192 | $Comp 193 | L power:GND #PWR02 194 | U 1 1 60167B0B 195 | P 1650 3850 196 | F 0 "#PWR02" H 1650 3600 50 0001 C CNN 197 | F 1 "GND" H 1655 3677 50 0000 C CNN 198 | F 2 "" H 1650 3850 50 0001 C CNN 199 | F 3 "" H 1650 3850 50 0001 C CNN 200 | 1 1650 3850 201 | 1 0 0 -1 202 | $EndComp 203 | Wire Wire Line 204 | 2950 3200 2950 3300 205 | $Comp 206 | L power:GND #PWR05 207 | U 1 1 60168350 208 | P 3650 3300 209 | F 0 "#PWR05" H 3650 3050 50 0001 C CNN 210 | F 1 "GND" H 3655 3127 50 0000 C CNN 211 | F 2 "" H 3650 3300 50 0001 C CNN 212 | F 3 "" H 3650 3300 50 0001 C CNN 213 | 1 3650 3300 214 | 1 0 0 -1 215 | $EndComp 216 | Wire Wire Line 217 | 3650 3300 3650 3150 218 | Wire Wire Line 219 | 2950 2800 2950 2650 220 | Wire Wire Line 221 | 3650 2650 3650 2850 222 | Wire Wire Line 223 | 2950 2550 2950 2650 224 | Connection ~ 2950 2650 225 | Connection ~ 2950 2150 226 | Wire Wire Line 227 | 1350 2150 2950 2150 228 | Wire Wire Line 229 | 2950 2150 2950 2050 230 | Wire Wire Line 231 | 2950 2150 2950 2250 232 | Wire Wire Line 233 | 3650 2650 4150 2650 234 | Connection ~ 3650 2650 235 | Text GLabel 4550 2650 2 50 Output ~ 0 236 | 400V 237 | Wire Wire Line 238 | 1150 3200 1150 3400 239 | Wire Wire Line 240 | 1050 3000 1150 3000 241 | Wire Wire Line 242 | 2200 3750 1650 3750 243 | Wire Wire Line 244 | 1650 3600 1650 3750 245 | Wire Wire Line 246 | 1650 3750 1650 3850 247 | Connection ~ 1650 3750 248 | Wire Wire Line 249 | 1050 3000 1050 4150 250 | Wire Wire Line 251 | 4150 2650 4150 2700 252 | Connection ~ 4150 2650 253 | Wire Wire Line 254 | 4150 2650 4550 2650 255 | Wire Wire Line 256 | 2600 3400 2600 3750 257 | Connection ~ 2600 3750 258 | Wire Wire Line 259 | 2600 3750 2500 3750 260 | Wire Wire Line 261 | 2600 4150 2600 3750 262 | Wire Wire Line 263 | 1050 2350 1050 3000 264 | Connection ~ 1050 3000 265 | Wire Wire Line 266 | 2950 1750 2950 1650 267 | Wire Wire Line 268 | 1050 1650 1050 1950 269 | Wire Wire Line 270 | 4150 3750 3050 3750 271 | Wire Wire Line 272 | 1050 4150 2600 4150 273 | Wire Wire Line 274 | 2150 3400 2600 3400 275 | Wire Wire Line 276 | 2750 3750 2600 3750 277 | Wire Wire Line 278 | 4150 3300 4150 3750 279 | $Comp 280 | L power:VCC #PWR03 281 | U 1 1 60192168 282 | P 2950 1400 283 | F 0 "#PWR03" H 2950 1250 50 0001 C CNN 284 | F 1 "VCC" H 2965 1573 50 0000 C CNN 285 | F 2 "" H 2950 1400 50 0001 C CNN 286 | F 3 "" H 2950 1400 50 0001 C CNN 287 | 1 2950 1400 288 | 1 0 0 -1 289 | $EndComp 290 | Connection ~ 2950 1650 291 | $Comp 292 | L power:VCC #PWR01 293 | U 1 1 601944CB 294 | P 1650 2500 295 | F 0 "#PWR01" H 1650 2350 50 0001 C CNN 296 | F 1 "VCC" H 1665 2673 50 0000 C CNN 297 | F 2 "" H 1650 2500 50 0001 C CNN 298 | F 3 "" H 1650 2500 50 0001 C CNN 299 | 1 1650 2500 300 | 1 0 0 -1 301 | $EndComp 302 | Text Notes 1350 1350 0 118 ~ 0 303 | High Voltage\nGenerator 304 | $Comp 305 | L Sensor:Nuclear-Radiation_Detector V1 306 | U 1 1 601CE94E 307 | P 5400 2500 308 | F 0 "V1" H 5550 2600 50 0000 L CNN 309 | F 1 "Geiger Tube" H 5550 2500 50 0000 L CNN 310 | F 2 "" H 5600 2600 50 0001 C CNN 311 | F 3 "~" H 5400 2500 50 0001 C CNN 312 | 1 5400 2500 313 | 1 0 0 -1 314 | $EndComp 315 | $Comp 316 | L Device:R R8 317 | U 1 1 601D38A3 318 | P 5400 3050 319 | F 0 "R8" H 5470 3096 50 0000 L CNN 320 | F 1 "220k" H 5470 3005 50 0000 L CNN 321 | F 2 "" V 5330 3050 50 0001 C CNN 322 | F 3 "~" H 5400 3050 50 0001 C CNN 323 | 1 5400 3050 324 | 1 0 0 -1 325 | $EndComp 326 | $Comp 327 | L Device:R R9 328 | U 1 1 601D3F54 329 | P 6100 2800 330 | F 0 "R9" V 6000 2800 50 0000 C CNN 331 | F 1 "100k" V 6200 2800 50 0000 C CNN 332 | F 2 "" V 6030 2800 50 0001 C CNN 333 | F 3 "~" H 6100 2800 50 0001 C CNN 334 | 1 6100 2800 335 | 0 1 1 0 336 | $EndComp 337 | Wire Wire Line 338 | 5400 2700 5400 2800 339 | Connection ~ 5400 2800 340 | Wire Wire Line 341 | 5400 2800 5400 2900 342 | Wire Wire Line 343 | 5400 2300 5400 2200 344 | Text GLabel 5400 1200 1 50 Input ~ 0 345 | 400V 346 | Wire Wire Line 347 | 5400 1300 5400 1200 348 | $Comp 349 | L power:GND #PWR06 350 | U 1 1 601DC6F1 351 | P 5400 3300 352 | F 0 "#PWR06" H 5400 3050 50 0001 C CNN 353 | F 1 "GND" H 5405 3127 50 0000 C CNN 354 | F 2 "" H 5400 3300 50 0001 C CNN 355 | F 3 "" H 5400 3300 50 0001 C CNN 356 | 1 5400 3300 357 | 1 0 0 -1 358 | $EndComp 359 | Wire Wire Line 360 | 5400 3200 5400 3300 361 | $Comp 362 | L Transistor_BJT:BC517 Q3 363 | U 1 1 601DDA69 364 | P 6500 2800 365 | F 0 "Q3" H 6691 2846 50 0000 L CNN 366 | F 1 "BC517" H 6691 2755 50 0000 L CNN 367 | F 2 "Package_TO_SOT_THT:TO-92_Inline" H 6700 2725 50 0001 L CIN 368 | F 3 "https://www.onsemi.com/pub/Collateral/BC517-D74Z-D.PDF" H 6500 2800 50 0001 L CNN 369 | 1 6500 2800 370 | 1 0 0 -1 371 | $EndComp 372 | $Comp 373 | L Device:D D1 374 | U 1 1 601DEE4A 375 | P 3300 2650 376 | F 0 "D1" H 3300 2500 50 0000 C CNN 377 | F 1 "MUR160" H 3300 2800 50 0000 C CNN 378 | F 2 "" H 3300 2650 50 0001 C CNN 379 | F 3 "~" H 3300 2650 50 0001 C CNN 380 | 1 3300 2650 381 | -1 0 0 1 382 | $EndComp 383 | Wire Wire Line 384 | 2950 2650 3150 2650 385 | Wire Wire Line 386 | 3450 2650 3650 2650 387 | $Comp 388 | L Device:D D4 389 | U 1 1 601E31A0 390 | P 5800 3050 391 | F 0 "D4" V 5754 3130 50 0000 L CNN 392 | F 1 "1N4148" V 5845 3130 50 0000 L CNN 393 | F 2 "" H 5800 3050 50 0001 C CNN 394 | F 3 "~" H 5800 3050 50 0001 C CNN 395 | 1 5800 3050 396 | 0 1 1 0 397 | $EndComp 398 | $Comp 399 | L Device:R R10 400 | U 1 1 601E516A 401 | P 6600 2250 402 | F 0 "R10" H 6670 2296 50 0000 L CNN 403 | F 1 "10k" H 6670 2205 50 0000 L CNN 404 | F 2 "" V 6530 2250 50 0001 C CNN 405 | F 3 "~" H 6600 2250 50 0001 C CNN 406 | 1 6600 2250 407 | 1 0 0 -1 408 | $EndComp 409 | Wire Wire Line 410 | 6600 2400 6600 2500 411 | Wire Wire Line 412 | 6250 2800 6300 2800 413 | Wire Wire Line 414 | 5400 2800 5800 2800 415 | Wire Wire Line 416 | 5800 2900 5800 2800 417 | Connection ~ 5800 2800 418 | Wire Wire Line 419 | 5800 2800 5950 2800 420 | $Comp 421 | L power:GND #PWR07 422 | U 1 1 601E833F 423 | P 5800 3300 424 | F 0 "#PWR07" H 5800 3050 50 0001 C CNN 425 | F 1 "GND" H 5805 3127 50 0000 C CNN 426 | F 2 "" H 5800 3300 50 0001 C CNN 427 | F 3 "" H 5800 3300 50 0001 C CNN 428 | 1 5800 3300 429 | 1 0 0 -1 430 | $EndComp 431 | Wire Wire Line 432 | 5800 3300 5800 3200 433 | $Comp 434 | L power:GND #PWR09 435 | U 1 1 601EDA33 436 | P 6600 3300 437 | F 0 "#PWR09" H 6600 3050 50 0001 C CNN 438 | F 1 "GND" H 6605 3127 50 0000 C CNN 439 | F 2 "" H 6600 3300 50 0001 C CNN 440 | F 3 "" H 6600 3300 50 0001 C CNN 441 | 1 6600 3300 442 | 1 0 0 -1 443 | $EndComp 444 | Wire Wire Line 445 | 6600 3000 6600 3300 446 | $Comp 447 | L power:VCC #PWR08 448 | U 1 1 601EE844 449 | P 6600 2000 450 | F 0 "#PWR08" H 6600 1850 50 0001 C CNN 451 | F 1 "VCC" H 6615 2173 50 0000 C CNN 452 | F 2 "" H 6600 2000 50 0001 C CNN 453 | F 3 "" H 6600 2000 50 0001 C CNN 454 | 1 6600 2000 455 | 1 0 0 -1 456 | $EndComp 457 | Wire Wire Line 458 | 6600 2000 6600 2100 459 | Text GLabel 7150 2500 2 50 Output ~ 0 460 | PULSE-A 461 | Wire Wire Line 462 | 6600 2500 7150 2500 463 | Connection ~ 6600 2500 464 | Wire Wire Line 465 | 6600 2500 6600 2600 466 | Text Notes 5750 1300 0 118 ~ 0 467 | Detector 468 | $Comp 469 | L Device:C C2 470 | U 1 1 602027DD 471 | P 3250 2150 472 | F 0 "C2" V 3100 2150 50 0000 C CNN 473 | F 1 "100n" V 3400 2150 50 0000 C CNN 474 | F 2 "" H 3288 2000 50 0001 C CNN 475 | F 3 "~" H 3250 2150 50 0001 C CNN 476 | 1 3250 2150 477 | 0 1 1 0 478 | $EndComp 479 | $Comp 480 | L power:GND #PWR011 481 | U 1 1 6020354A 482 | P 3550 2250 483 | F 0 "#PWR011" H 3550 2000 50 0001 C CNN 484 | F 1 "GND" H 3555 2077 50 0000 C CNN 485 | F 2 "" H 3550 2250 50 0001 C CNN 486 | F 3 "" H 3550 2250 50 0001 C CNN 487 | 1 3550 2250 488 | 1 0 0 -1 489 | $EndComp 490 | Wire Wire Line 491 | 2950 2150 3100 2150 492 | Wire Wire Line 493 | 1650 2500 1650 2650 494 | $Comp 495 | L Device:CP C4 496 | U 1 1 6020B537 497 | P 3250 1650 498 | F 0 "C4" V 3400 1650 50 0000 C CNN 499 | F 1 "100u" V 3100 1650 50 0000 C CNN 500 | F 2 "" H 3288 1500 50 0001 C CNN 501 | F 3 "~" H 3250 1650 50 0001 C CNN 502 | 1 3250 1650 503 | 0 -1 -1 0 504 | $EndComp 505 | Wire Wire Line 506 | 3100 1650 2950 1650 507 | Wire Wire Line 508 | 3400 2150 3550 2150 509 | Wire Wire Line 510 | 3550 2150 3550 1650 511 | Connection ~ 3550 2150 512 | Wire Wire Line 513 | 3400 1650 3550 1650 514 | $Comp 515 | L Timer:TLC555xP U3 516 | U 1 1 6021C84F 517 | P 9450 2700 518 | F 0 "U3" H 9150 3100 50 0000 C CNN 519 | F 1 "TLC555xP" H 9450 2700 50 0000 C CNN 520 | F 2 "Package_DIP:DIP-8_W7.62mm" H 10100 2300 50 0001 C CNN 521 | F 3 "http://www.ti.com/lit/ds/symlink/tlc555.pdf" H 10300 2300 50 0001 C CNN 522 | 1 9450 2700 523 | 1 0 0 -1 524 | $EndComp 525 | $Comp 526 | L power:VCC #PWR013 527 | U 1 1 60233035 528 | P 9450 1650 529 | F 0 "#PWR013" H 9450 1500 50 0001 C CNN 530 | F 1 "VCC" H 9465 1823 50 0000 C CNN 531 | F 2 "" H 9450 1650 50 0001 C CNN 532 | F 3 "" H 9450 1650 50 0001 C CNN 533 | 1 9450 1650 534 | 1 0 0 -1 535 | $EndComp 536 | Text GLabel 8350 2500 0 50 Input ~ 0 537 | PULSE-A 538 | Wire Wire Line 539 | 8350 2500 8950 2500 540 | $Comp 541 | L Device:C C7 542 | U 1 1 6023B393 543 | P 10200 3200 544 | F 0 "C7" H 10315 3246 50 0000 L CNN 545 | F 1 "100n" H 10315 3155 50 0000 L CNN 546 | F 2 "" H 10238 3050 50 0001 C CNN 547 | F 3 "~" H 10200 3200 50 0001 C CNN 548 | 1 10200 3200 549 | 1 0 0 -1 550 | $EndComp 551 | $Comp 552 | L Device:C C5 553 | U 1 1 6023BE0A 554 | P 8600 3200 555 | F 0 "C5" H 8715 3246 50 0000 L CNN 556 | F 1 "100n" H 8715 3155 50 0000 L CNN 557 | F 2 "" H 8638 3050 50 0001 C CNN 558 | F 3 "~" H 8600 3200 50 0001 C CNN 559 | 1 8600 3200 560 | 1 0 0 -1 561 | $EndComp 562 | $Comp 563 | L Device:R R11 564 | U 1 1 6023C0C4 565 | P 10200 2300 566 | F 0 "R11" H 10270 2346 50 0000 L CNN 567 | F 1 "3k9" H 10270 2255 50 0000 L CNN 568 | F 2 "" V 10130 2300 50 0001 C CNN 569 | F 3 "~" H 10200 2300 50 0001 C CNN 570 | 1 10200 2300 571 | 1 0 0 -1 572 | $EndComp 573 | Wire Wire Line 574 | 8600 3050 8600 2700 575 | Wire Wire Line 576 | 8600 2700 8950 2700 577 | $Comp 578 | L power:GND #PWR014 579 | U 1 1 6024A8F8 580 | P 9450 3500 581 | F 0 "#PWR014" H 9450 3250 50 0001 C CNN 582 | F 1 "GND" H 9455 3327 50 0000 C CNN 583 | F 2 "" H 9450 3500 50 0001 C CNN 584 | F 3 "" H 9450 3500 50 0001 C CNN 585 | 1 9450 3500 586 | 1 0 0 -1 587 | $EndComp 588 | $Comp 589 | L power:GND #PWR012 590 | U 1 1 6024B0C6 591 | P 8600 3500 592 | F 0 "#PWR012" H 8600 3250 50 0001 C CNN 593 | F 1 "GND" H 8605 3327 50 0000 C CNN 594 | F 2 "" H 8600 3500 50 0001 C CNN 595 | F 3 "" H 8600 3500 50 0001 C CNN 596 | 1 8600 3500 597 | 1 0 0 -1 598 | $EndComp 599 | $Comp 600 | L power:GND #PWR016 601 | U 1 1 6024B2C9 602 | P 10200 3500 603 | F 0 "#PWR016" H 10200 3250 50 0001 C CNN 604 | F 1 "GND" H 10205 3327 50 0000 C CNN 605 | F 2 "" H 10200 3500 50 0001 C CNN 606 | F 3 "" H 10200 3500 50 0001 C CNN 607 | 1 10200 3500 608 | 1 0 0 -1 609 | $EndComp 610 | Wire Wire Line 611 | 10200 3350 10200 3500 612 | Wire Wire Line 613 | 9450 3100 9450 3500 614 | Wire Wire Line 615 | 8600 3350 8600 3500 616 | Wire Wire Line 617 | 10200 2450 10200 2700 618 | Wire Wire Line 619 | 9950 2700 10200 2700 620 | Connection ~ 10200 2700 621 | Wire Wire Line 622 | 10200 2700 10200 2900 623 | Wire Wire Line 624 | 10200 2900 9950 2900 625 | Connection ~ 10200 2900 626 | Wire Wire Line 627 | 10200 2900 10200 3050 628 | Text GLabel 10550 2500 2 50 Output ~ 0 629 | PULSE-B 630 | Wire Wire Line 631 | 9950 2500 10550 2500 632 | Wire Wire Line 633 | 8950 2900 8850 2900 634 | $Comp 635 | L Device:C C6 636 | U 1 1 60268467 637 | P 9650 2100 638 | F 0 "C6" V 9500 2100 50 0000 C CNN 639 | F 1 "100n" V 9800 2100 50 0000 C CNN 640 | F 2 "" H 9688 1950 50 0001 C CNN 641 | F 3 "~" H 9650 2100 50 0001 C CNN 642 | 1 9650 2100 643 | 0 1 1 0 644 | $EndComp 645 | Wire Wire Line 646 | 9450 1650 9450 1750 647 | $Comp 648 | L power:GND #PWR015 649 | U 1 1 6026C1B5 650 | P 9800 2100 651 | F 0 "#PWR015" H 9800 1850 50 0001 C CNN 652 | F 1 "GND" V 9805 1972 50 0000 R CNN 653 | F 2 "" H 9800 2100 50 0001 C CNN 654 | F 3 "" H 9800 2100 50 0001 C CNN 655 | 1 9800 2100 656 | 0 -1 -1 0 657 | $EndComp 658 | Wire Wire Line 659 | 10200 1750 10200 2150 660 | Connection ~ 9450 1750 661 | Wire Wire Line 662 | 8850 1750 9450 1750 663 | Wire Wire Line 664 | 8850 1750 8850 2900 665 | Wire Wire Line 666 | 9450 1750 10200 1750 667 | Wire Wire Line 668 | 9450 1750 9450 2100 669 | Wire Wire Line 670 | 9500 2100 9450 2100 671 | Connection ~ 9450 2100 672 | Wire Wire Line 673 | 9450 2100 9450 2300 674 | $Comp 675 | L Device:C C3 676 | U 1 1 6027E87B 677 | P 1850 2650 678 | F 0 "C3" V 1700 2650 50 0000 C CNN 679 | F 1 "100n" V 2000 2650 50 0000 C CNN 680 | F 2 "" H 1888 2500 50 0001 C CNN 681 | F 3 "~" H 1850 2650 50 0001 C CNN 682 | 1 1850 2650 683 | 0 1 1 0 684 | $EndComp 685 | $Comp 686 | L power:GND #PWR010 687 | U 1 1 60280D56 688 | P 2000 2650 689 | F 0 "#PWR010" H 2000 2400 50 0001 C CNN 690 | F 1 "GND" V 2005 2522 50 0000 R CNN 691 | F 2 "" H 2000 2650 50 0001 C CNN 692 | F 3 "" H 2000 2650 50 0001 C CNN 693 | 1 2000 2650 694 | 0 -1 -1 0 695 | $EndComp 696 | Wire Wire Line 697 | 1700 2650 1650 2650 698 | Connection ~ 1650 2650 699 | Wire Wire Line 700 | 1650 2650 1650 2800 701 | Wire Wire Line 702 | 2950 1400 2950 1650 703 | Text Notes 8750 1300 0 118 ~ 0 704 | Pulse Extension 705 | $Comp 706 | L Device:Buzzer BZ1 707 | U 1 1 60297F5A 708 | P 9600 5350 709 | F 0 "BZ1" H 9752 5379 50 0000 L CNN 710 | F 1 "Buzzer" H 9752 5288 50 0000 L CNN 711 | F 2 "" V 9575 5450 50 0001 C CNN 712 | F 3 "~" V 9575 5450 50 0001 C CNN 713 | 1 9600 5350 714 | 1 0 0 -1 715 | $EndComp 716 | $Comp 717 | L power:GND #PWR018 718 | U 1 1 6029AEBD 719 | P 9400 5500 720 | F 0 "#PWR018" H 9400 5250 50 0001 C CNN 721 | F 1 "GND" H 9405 5327 50 0000 C CNN 722 | F 2 "" H 9400 5500 50 0001 C CNN 723 | F 3 "" H 9400 5500 50 0001 C CNN 724 | 1 9400 5500 725 | 1 0 0 -1 726 | $EndComp 727 | Wire Wire Line 728 | 9500 5450 9400 5450 729 | Wire Wire Line 730 | 9400 5450 9400 5500 731 | Text GLabel 8850 5250 0 50 Input ~ 0 732 | PULSE-B 733 | $Comp 734 | L Jumper:Jumper_2_Open JP1 735 | U 1 1 6029F8D4 736 | P 9150 5250 737 | F 0 "JP1" H 9150 5485 50 0000 C CNN 738 | F 1 "Buzzer on" H 9150 5394 50 0000 C CNN 739 | F 2 "" H 9150 5250 50 0001 C CNN 740 | F 3 "~" H 9150 5250 50 0001 C CNN 741 | 1 9150 5250 742 | 1 0 0 -1 743 | $EndComp 744 | Wire Wire Line 745 | 9350 5250 9500 5250 746 | $Comp 747 | L Connector:Conn_01x02_Male J1 748 | U 1 1 602A360A 749 | P 9700 6100 750 | F 0 "J1" H 9672 5982 50 0000 R CNN 751 | F 1 "Pulse Out" H 9672 6073 50 0000 R CNN 752 | F 2 "" H 9700 6100 50 0001 C CNN 753 | F 3 "~" H 9700 6100 50 0001 C CNN 754 | 1 9700 6100 755 | -1 0 0 1 756 | $EndComp 757 | Wire Wire Line 758 | 8850 5250 8950 5250 759 | Text GLabel 8850 6000 0 50 Input ~ 0 760 | PULSE-B 761 | $Comp 762 | L power:GND #PWR019 763 | U 1 1 602AAF13 764 | P 9400 6150 765 | F 0 "#PWR019" H 9400 5900 50 0001 C CNN 766 | F 1 "GND" H 9405 5977 50 0000 C CNN 767 | F 2 "" H 9400 6150 50 0001 C CNN 768 | F 3 "" H 9400 6150 50 0001 C CNN 769 | 1 9400 6150 770 | 1 0 0 -1 771 | $EndComp 772 | Wire Wire Line 773 | 8850 6000 9500 6000 774 | Wire Wire Line 775 | 9400 6150 9400 6100 776 | Wire Wire Line 777 | 9400 6100 9500 6100 778 | $Comp 779 | L Device:R R12 780 | U 1 1 602C68B9 781 | P 1900 6200 782 | F 0 "R12" V 2000 6200 50 0000 C CNN 783 | F 1 "3k3" V 1784 6200 50 0000 C CNN 784 | F 2 "" V 1830 6200 50 0001 C CNN 785 | F 3 "~" H 1900 6200 50 0001 C CNN 786 | 1 1900 6200 787 | 0 1 1 0 788 | $EndComp 789 | $Comp 790 | L Device:D_Zener D5 791 | U 1 1 602C754E 792 | P 2150 6450 793 | F 0 "D5" V 2104 6530 50 0000 L CNN 794 | F 1 "3V3" V 2195 6530 50 0000 L CNN 795 | F 2 "" H 2150 6450 50 0001 C CNN 796 | F 3 "~" H 2150 6450 50 0001 C CNN 797 | 1 2150 6450 798 | 0 1 1 0 799 | $EndComp 800 | Text GLabel 1550 6200 0 50 Input ~ 0 801 | PULSE-B 802 | Wire Wire Line 803 | 1550 6200 1750 6200 804 | $Comp 805 | L power:GND #PWR017 806 | U 1 1 602CD14A 807 | P 2150 6750 808 | F 0 "#PWR017" H 2150 6500 50 0001 C CNN 809 | F 1 "GND" H 2155 6577 50 0000 C CNN 810 | F 2 "" H 2150 6750 50 0001 C CNN 811 | F 3 "" H 2150 6750 50 0001 C CNN 812 | 1 2150 6750 813 | 1 0 0 -1 814 | $EndComp 815 | $Comp 816 | L project:EzSBC_ESP32-01 U1 817 | U 1 1 602D4760 818 | P 3650 6150 819 | F 0 "U1" H 3650 7365 50 0000 C CNN 820 | F 1 "EzSBC_ESP32-01" H 3650 7274 50 0000 C CNN 821 | F 2 "" H 3650 7050 50 0001 C CNN 822 | F 3 "" H 3650 7050 50 0001 C CNN 823 | 1 3650 6150 824 | -1 0 0 1 825 | $EndComp 826 | Wire Wire Line 827 | 2050 6200 2150 6200 828 | Wire Wire Line 829 | 2150 6200 2150 6300 830 | Wire Wire Line 831 | 2150 6600 2150 6750 832 | $Comp 833 | L Device:C C8 834 | U 1 1 6032AB87 835 | P 5050 6950 836 | F 0 "C8" H 5165 6996 50 0000 L CNN 837 | F 1 "100n" H 5165 6905 50 0000 L CNN 838 | F 2 "" H 5088 6800 50 0001 C CNN 839 | F 3 "~" H 5050 6950 50 0001 C CNN 840 | 1 5050 6950 841 | 1 0 0 -1 842 | $EndComp 843 | $Comp 844 | L Device:CP C9 845 | U 1 1 6032EF00 846 | P 5800 6950 847 | F 0 "C9" H 5918 6996 50 0000 L CNN 848 | F 1 "1000u" H 5918 6905 50 0000 L CNN 849 | F 2 "" H 5838 6800 50 0001 C CNN 850 | F 3 "~" H 5800 6950 50 0001 C CNN 851 | 1 5800 6950 852 | 1 0 0 -1 853 | $EndComp 854 | Wire Wire Line 855 | 4600 6800 5050 6800 856 | Wire Wire Line 857 | 4600 6900 4750 6900 858 | Wire Wire Line 859 | 4750 6900 4750 7100 860 | Wire Wire Line 861 | 4750 7100 5050 7100 862 | Connection ~ 5050 7100 863 | $Comp 864 | L power:GND #PWR020 865 | U 1 1 60339CCE 866 | P 5050 7150 867 | F 0 "#PWR020" H 5050 6900 50 0001 C CNN 868 | F 1 "GND" H 5055 6977 50 0000 C CNN 869 | F 2 "" H 5050 7150 50 0001 C CNN 870 | F 3 "" H 5050 7150 50 0001 C CNN 871 | 1 5050 7150 872 | 1 0 0 -1 873 | $EndComp 874 | Wire Wire Line 875 | 5050 7100 5050 7150 876 | Wire Wire Line 877 | 5800 7100 5050 7100 878 | $Comp 879 | L power:VCC #PWR021 880 | U 1 1 6033D2F0 881 | P 5800 6350 882 | F 0 "#PWR021" H 5800 6200 50 0001 C CNN 883 | F 1 "VCC" H 5815 6523 50 0000 C CNN 884 | F 2 "" H 5800 6350 50 0001 C CNN 885 | F 3 "" H 5800 6350 50 0001 C CNN 886 | 1 5800 6350 887 | 1 0 0 -1 888 | $EndComp 889 | Wire Wire Line 890 | 2700 5700 2450 5700 891 | Wire Wire Line 892 | 5050 6800 5200 6800 893 | Connection ~ 5050 6800 894 | Wire Wire Line 895 | 5600 6800 5800 6800 896 | Wire Wire Line 897 | 5800 6800 5800 6350 898 | Connection ~ 5800 6800 899 | $Comp 900 | L Jumper:Jumper_2_Bridged JP3 901 | U 1 1 6035A20F 902 | P 5400 6800 903 | F 0 "JP3" H 5400 6995 50 0000 C CNN 904 | F 1 "VCC to uC" H 5400 6904 50 0000 C CNN 905 | F 2 "" H 5400 6800 50 0001 C CNN 906 | F 3 "~" H 5400 6800 50 0001 C CNN 907 | 1 5400 6800 908 | 1 0 0 -1 909 | $EndComp 910 | Text Notes 4850 6500 0 50 Italic 0 911 | (!) WARNING (!)\nDO NOT CLOSE\nWHEN POWERED FROM\nBOTH USB AND VCC 912 | $Comp 913 | L Connector:Conn_01x04_Female J2 914 | U 1 1 60363882 915 | P 5250 4950 916 | F 0 "J2" V 5200 5200 50 0000 R CNN 917 | F 1 "I2C OLED 128x64 with SH1106" V 5350 5400 50 0000 R CNN 918 | F 2 "" H 5250 4950 50 0001 C CNN 919 | F 3 "~" H 5250 4950 50 0001 C CNN 920 | 1 5250 4950 921 | 0 -1 -1 0 922 | $EndComp 923 | Wire Wire Line 924 | 2700 6900 2550 6900 925 | Wire Wire Line 926 | 2550 6900 2550 7450 927 | Wire Wire Line 928 | 2550 7450 4750 7450 929 | Wire Wire Line 930 | 4750 7100 4750 7450 931 | Connection ~ 4750 7100 932 | Wire Wire Line 933 | 5150 5300 5150 5150 934 | Wire Wire Line 935 | 5450 5600 5450 5150 936 | Wire Wire Line 937 | 4600 5700 5350 5700 938 | Wire Wire Line 939 | 5350 5700 5350 5150 940 | $Comp 941 | L power:GND #PWR022 942 | U 1 1 6038B23D 943 | P 5250 5350 944 | F 0 "#PWR022" H 5250 5100 50 0001 C CNN 945 | F 1 "GND" H 5255 5177 50 0000 C CNN 946 | F 2 "" H 5250 5350 50 0001 C CNN 947 | F 3 "" H 5250 5350 50 0001 C CNN 948 | 1 5250 5350 949 | 1 0 0 -1 950 | $EndComp 951 | Wire Wire Line 952 | 5250 5150 5250 5350 953 | Text Notes 5550 5100 0 50 Italic 0 954 | pin layout depends \non used module 955 | Text Notes 1000 5250 0 118 ~ 0 956 | ESP32\nMicrocontroller 957 | Text Notes 8800 4800 0 118 ~ 0 958 | Outputs 959 | $Comp 960 | L Device:R R13 961 | U 1 1 603B2486 962 | P 4950 5450 963 | F 0 "R13" H 5020 5496 50 0000 L CNN 964 | F 1 "4k7" H 5020 5405 50 0000 L CNN 965 | F 2 "" V 4880 5450 50 0001 C CNN 966 | F 3 "~" H 4950 5450 50 0001 C CNN 967 | 1 4950 5450 968 | 1 0 0 -1 969 | $EndComp 970 | Wire Wire Line 971 | 4600 5600 4950 5600 972 | Wire Wire Line 973 | 4950 5300 5150 5300 974 | Connection ~ 4950 5600 975 | Wire Wire Line 976 | 4950 5600 5450 5600 977 | Text Notes 7150 2350 0 50 ~ 0 978 | pulse\napprox. 200us\nlow 0 V 979 | Text Notes 10550 2350 0 50 ~ 0 980 | pulse\napprox. 400us\nhigh VCC 981 | Wire Wire Line 982 | 3550 2150 3550 2250 983 | NoConn ~ 2700 5200 984 | NoConn ~ 2700 5300 985 | NoConn ~ 2700 5400 986 | NoConn ~ 2700 5500 987 | NoConn ~ 2700 5600 988 | NoConn ~ 2700 5800 989 | NoConn ~ 2700 5900 990 | NoConn ~ 2700 6000 991 | NoConn ~ 2700 6100 992 | NoConn ~ 2700 6300 993 | NoConn ~ 2700 6400 994 | NoConn ~ 2700 6500 995 | NoConn ~ 2700 6700 996 | NoConn ~ 2700 6800 997 | NoConn ~ 4600 5200 998 | NoConn ~ 4600 5500 999 | NoConn ~ 4600 5800 1000 | NoConn ~ 4600 5900 1001 | NoConn ~ 4600 6000 1002 | NoConn ~ 4600 6100 1003 | NoConn ~ 4600 6200 1004 | NoConn ~ 4600 6300 1005 | NoConn ~ 4600 6400 1006 | NoConn ~ 4600 6500 1007 | NoConn ~ 4600 6600 1008 | NoConn ~ 4600 6700 1009 | NoConn ~ 4600 7000 1010 | NoConn ~ 2700 7000 1011 | NoConn ~ 2700 7100 1012 | NoConn ~ 4600 7100 1013 | $Comp 1014 | L power:GND #PWR0101 1015 | U 1 1 601D64A6 1016 | P 1950 5800 1017 | F 0 "#PWR0101" H 1950 5550 50 0001 C CNN 1018 | F 1 "GND" H 1955 5627 50 0000 C CNN 1019 | F 2 "" H 1950 5800 50 0001 C CNN 1020 | F 3 "" H 1950 5800 50 0001 C CNN 1021 | 1 1950 5800 1022 | 1 0 0 -1 1023 | $EndComp 1024 | Wire Wire Line 1025 | 2050 5700 1950 5700 1026 | Wire Wire Line 1027 | 1950 5700 1950 5800 1028 | $Comp 1029 | L Jumper:Jumper_2_Bridged JP2 1030 | U 1 1 60343981 1031 | P 2250 5700 1032 | F 0 "JP2" H 2250 5895 50 0000 C CNN 1033 | F 1 "WiFi on" H 2250 5804 50 0000 C CNN 1034 | F 2 "" H 2250 5700 50 0001 C CNN 1035 | F 3 "~" H 2250 5700 50 0001 C CNN 1036 | 1 2250 5700 1037 | 1 0 0 -1 1038 | $EndComp 1039 | Wire Wire Line 1040 | 1050 1650 2950 1650 1041 | $Comp 1042 | L power:GND #PWR024 1043 | U 1 1 601E1EB9 1044 | P 7750 5400 1045 | F 0 "#PWR024" H 7750 5150 50 0001 C CNN 1046 | F 1 "GND" H 7755 5227 50 0000 C CNN 1047 | F 2 "" H 7750 5400 50 0001 C CNN 1048 | F 3 "" H 7750 5400 50 0001 C CNN 1049 | 1 7750 5400 1050 | 1 0 0 -1 1051 | $EndComp 1052 | $Comp 1053 | L power:VCC #PWR023 1054 | U 1 1 601E23DB 1055 | P 7750 5100 1056 | F 0 "#PWR023" H 7750 4950 50 0001 C CNN 1057 | F 1 "VCC" H 7765 5273 50 0000 C CNN 1058 | F 2 "" H 7750 5100 50 0001 C CNN 1059 | F 3 "" H 7750 5100 50 0001 C CNN 1060 | 1 7750 5100 1061 | 1 0 0 -1 1062 | $EndComp 1063 | $Comp 1064 | L Connector:Screw_Terminal_01x02 J3 1065 | U 1 1 601E2CC3 1066 | P 7200 5300 1067 | F 0 "J3" H 7200 5100 50 0000 C CNN 1068 | F 1 "Power in" H 7500 5250 50 0000 C CNN 1069 | F 2 "" H 7200 5300 50 0001 C CNN 1070 | F 3 "~" H 7200 5300 50 0001 C CNN 1071 | 1 7200 5300 1072 | -1 0 0 1 1073 | $EndComp 1074 | Wire Wire Line 1075 | 7400 5300 7500 5300 1076 | $Comp 1077 | L power:GNDPWR #PWR0102 1078 | U 1 1 601FD717 1079 | P 7500 5400 1080 | F 0 "#PWR0102" H 7500 5200 50 0001 C CNN 1081 | F 1 "GNDPWR" H 7504 5246 50 0000 C CNN 1082 | F 2 "" H 7500 5350 50 0001 C CNN 1083 | F 3 "" H 7500 5350 50 0001 C CNN 1084 | 1 7500 5400 1085 | 1 0 0 -1 1086 | $EndComp 1087 | $Comp 1088 | L power:PWR_FLAG #FLG0101 1089 | U 1 1 601FEC15 1090 | P 7500 5100 1091 | F 0 "#FLG0101" H 7500 5175 50 0001 C CNN 1092 | F 1 "PWR_FLAG" H 7500 5273 50 0000 C CNN 1093 | F 2 "" H 7500 5100 50 0001 C CNN 1094 | F 3 "~" H 7500 5100 50 0001 C CNN 1095 | 1 7500 5100 1096 | 1 0 0 -1 1097 | $EndComp 1098 | Wire Wire Line 1099 | 7500 5400 7500 5300 1100 | Connection ~ 7500 5300 1101 | Wire Wire Line 1102 | 7400 5200 7500 5200 1103 | Wire Wire Line 1104 | 7500 5100 7500 5200 1105 | Connection ~ 7500 5200 1106 | Wire Wire Line 1107 | 7750 5200 7750 5100 1108 | Wire Wire Line 1109 | 7500 5200 7750 5200 1110 | Wire Wire Line 1111 | 7750 5300 7750 5400 1112 | Wire Wire Line 1113 | 7500 5300 7750 5300 1114 | Wire Wire Line 1115 | 4800 5400 4600 5400 1116 | Wire Wire Line 1117 | 4800 5300 4800 5400 1118 | Wire Wire Line 1119 | 4950 5300 4800 5300 1120 | Connection ~ 4950 5300 1121 | NoConn ~ 4600 5300 1122 | Wire Wire Line 1123 | 2150 6200 2700 6200 1124 | Connection ~ 2150 6200 1125 | NoConn ~ 2700 6600 1126 | $EndSCHEMATC 1127 | -------------------------------------------------------------------------------- /hardware/kicad/project/geiger/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name project)(type Legacy)(uri C:/dev/git/esp32-geiger-counter/hardware/kicad/lib/geiger.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /include/GeigerData.h: -------------------------------------------------------------------------------- 1 | #ifndef GEIGERDATA_H_ 2 | #define GEIGERDATA_H_ 3 | 4 | #include "Arduino.h" 5 | 6 | // Russion STS-6 ("CTC-6") Geiger tube: 7 | // N = (2.28-3.42)*10^3 at 0.36 µR/h; Nmax = 6*10^4; Nf = 110 8 | const float STS6_CPM_PER_USPH = 825; // 875 is a little bit too low compared to official station 9 | 10 | // Holds pulse counter history and performs calculations 11 | class GeigerData 12 | { 13 | public: 14 | const uint16_t sampleCount; 15 | const uint16_t sampleSeconds; 16 | const float cpm_per_uSph; 17 | 18 | private: 19 | uint16_t currentSample; 20 | uint16_t *pulsesPerSample; 21 | uint16_t next(uint16_t index); 22 | uint16_t prev(uint16_t index); 23 | 24 | public: 25 | GeigerData(uint16_t sampleCount, uint16_t sampleSeconds, 26 | float cpm_per_uSph); 27 | virtual ~GeigerData(); 28 | 29 | virtual void addPulses(uint16_t pulses); 30 | virtual void nextSample(); 31 | 32 | virtual uint16_t getCurrentSample(); 33 | virtual uint32_t getPreviousPulses(uint16_t offset, uint16_t samples); 34 | virtual float toMicroSievertPerHour(uint32_t pulses, uint16_t samples); 35 | }; 36 | 37 | #endif /* GEIGERDATA_H_ */ 38 | -------------------------------------------------------------------------------- /include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /include/credentials.h: -------------------------------------------------------------------------------- 1 | #ifndef CREDENTIALS_H_ 2 | #define CREDENTIALS_H_ 3 | 4 | extern const char *wifiSsid; 5 | extern const char *wifiPassword; 6 | extern const char *thingspeakApiKey; 7 | 8 | extern const char *mqttHost; 9 | extern int mqttPort; 10 | extern const char *mqttTlsServerRootCert; 11 | extern const char *mqttUser; 12 | extern const char *mqttPassword; 13 | extern const char *mqttTopic; 14 | 15 | #endif /* CREDENTIALS_H_ */ 16 | -------------------------------------------------------------------------------- /include/display.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPLAY_H_ 2 | #define DISPLAY_H_ 3 | 4 | #include "GeigerData.h" 5 | 6 | void initDisplay(); 7 | void updateDisplay(GeigerData &geigerData, char uSphStr[16], char cpmStr[16]); 8 | 9 | #endif /* DISPLAY_H_ */ 10 | -------------------------------------------------------------------------------- /include/ingest.h: -------------------------------------------------------------------------------- 1 | #ifndef INGEST_H_ 2 | #define INGEST_H_ 3 | 4 | #include "GeigerData.h" 5 | 6 | void initIngest(); 7 | void loopIngest(); 8 | void deinitIngest(); 9 | void ingestToThingspeak(GeigerData &geigerData, uint16_t intervalSamples); 10 | void ingestToMqtt(GeigerData &geigerData, uint16_t intervalSamples); 11 | 12 | #endif /* INGEST_H_ */ 13 | -------------------------------------------------------------------------------- /lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /media/geiger-counter-pcb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/geiger-counter-pcb.jpg -------------------------------------------------------------------------------- /media/geiger-signal-formed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/geiger-signal-formed.png -------------------------------------------------------------------------------- /media/geiger-signal-raw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/geiger-signal-raw.png -------------------------------------------------------------------------------- /media/kicad-circuit-sketch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/kicad-circuit-sketch.png -------------------------------------------------------------------------------- /media/pulse-forming-schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/pulse-forming-schematic.png -------------------------------------------------------------------------------- /media/thingspeak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grillbaer/esp32-geiger-counter/92b42556f84049272eff9ab4e9a114a58a60763b/media/thingspeak.png -------------------------------------------------------------------------------- /platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:lolin32] 12 | platform = espressif32 13 | board = lolin32 14 | framework = arduino 15 | monitor_speed = 115200 16 | lib_deps = 17 | U8g2@^2.27.6 18 | 256dpi/MQTT@^2.4.7 19 | -------------------------------------------------------------------------------- /src/GeigerData.cpp: -------------------------------------------------------------------------------- 1 | #include "GeigerData.h" 2 | 3 | GeigerData::GeigerData(uint16_t sampleCount, uint16_t sampleSeconds, 4 | float cpm_per_uSph) : sampleCount(sampleCount), sampleSeconds(sampleSeconds), cpm_per_uSph(cpm_per_uSph), pulsesPerSample(new uint16_t[sampleCount]) 5 | { 6 | currentSample = 0; 7 | for (int i = 0; i < sampleCount; i++) 8 | { 9 | pulsesPerSample[i] = 0; 10 | } 11 | } 12 | 13 | GeigerData::~GeigerData() 14 | { 15 | delete[] pulsesPerSample; 16 | } 17 | 18 | uint16_t GeigerData::next(uint16_t index) 19 | { 20 | return index + 1 < sampleCount ? index + 1 : 0; 21 | } 22 | 23 | uint16_t GeigerData::prev(uint16_t index) 24 | { 25 | return index > 0 ? index - 1 : sampleCount - 1; 26 | } 27 | 28 | void GeigerData::addPulses(uint16_t pulses) 29 | { 30 | if (pulsesPerSample[currentSample] <= UINT16_MAX - pulses) 31 | pulsesPerSample[currentSample] += pulses; 32 | } 33 | 34 | void GeigerData::nextSample() 35 | { 36 | currentSample = next(currentSample); 37 | pulsesPerSample[currentSample] = 0; 38 | } 39 | 40 | uint16_t GeigerData::getCurrentSample() 41 | { 42 | return currentSample; 43 | } 44 | 45 | uint32_t GeigerData::getPreviousPulses(uint16_t offset, uint16_t samples) 46 | { 47 | uint32_t pulses = 0; 48 | uint16_t index = (currentSample + sampleCount - offset) % sampleCount; 49 | for (uint16_t i = 0; i < samples; i++) 50 | { 51 | pulses += pulsesPerSample[index]; 52 | index = prev(index); 53 | } 54 | 55 | return pulses; 56 | } 57 | 58 | float GeigerData::toMicroSievertPerHour(uint32_t pulses, uint16_t samples) 59 | { 60 | float cpm = pulses / (sampleSeconds / 60. * samples); 61 | return cpm / cpm_per_uSph; 62 | } 63 | -------------------------------------------------------------------------------- /src/TEMPLATE_secret_credentials.h: -------------------------------------------------------------------------------- 1 | #define _SECRET_CREDENTIALS 2 | 3 | // Copy this file to secret_credentials.h and adjust for 4 | // your needs and environment. 5 | 6 | // !!! NEVER COMMIT YOUR SECRETS !!! 7 | 8 | const char *wifiSsid = "MyWiFi"; 9 | const char *wifiPassword = "mypassword"; 10 | 11 | 12 | // ThingsPeak Channel 13 | 14 | // set key to NULL or empty string to disable ThingsPeak ingest: 15 | const char *thingspeakApiKey = "MYAPIKEY"; 16 | 17 | 18 | // MQTT Broker 19 | 20 | // set host to NULL or empty string to disable MQTT publishing: 21 | const char *mqttHost = "my.mqtt.server"; 22 | int mqttPort = 1833; 23 | // set MQTT server's root CA cert to NULL or empty string to disable MQTT TLS/SSL: 24 | const char *mqttTlsServerRootCert = R""""( 25 | -----BEGIN CERTIFICATE----- 26 | MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G 27 | A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp 28 | Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1 29 | MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG 30 | A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI 31 | hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL 32 | v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8 33 | eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq 34 | tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd 35 | C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa 36 | zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB 37 | mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH 38 | V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n 39 | bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG 40 | 3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs 41 | J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO 42 | 291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS 43 | ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd 44 | AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 45 | TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== 46 | -----END CERTIFICATE----- 47 | )""""; 48 | const char *mqttUser = "user"; 49 | const char *mqttPassword = "mypassword"; 50 | const char *mqttTopic = "home/radioactivity"; 51 | -------------------------------------------------------------------------------- /src/credentials.cpp: -------------------------------------------------------------------------------- 1 | #include "credentials.h" 2 | 3 | #if __has_include("secret_credentials.h") 4 | // keep secret credentials in an external file that is never committed: 5 | #include "secret_credentials.h" 6 | #endif 7 | 8 | #ifndef _SECRET_CREDENTIALS 9 | 10 | // use dummy credentials to make it compilable without secrets 11 | const char *wifiSsid = "unset-wifi-ssid"; 12 | const char *wifiPassword = "unset-password"; 13 | const char *thingspeakApiKey = ""; // empty to disable thinkspeak 14 | 15 | const char *mqttHost = ""; // empty to disable MQTT 16 | int mqttPort = 1833; 17 | extern const char *mqttTlsServerRootCert = ""; // empty to disable TLS 18 | const char *mqttUser = "user"; 19 | const char *mqttPassword = "unset-password"; 20 | const char *mqttTopic = "home/geiger/radioactivity"; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/display.cpp: -------------------------------------------------------------------------------- 1 | #include "U8g2lib.h" 2 | 3 | #include "display.h" 4 | 5 | // OLED display 128x64 with SH1106 controller 6 | // on I2C GPIOs SCL 22 and SDA 21 7 | U8G2_SH1106_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, 22, 21); 8 | 9 | void initDisplay() 10 | { 11 | // high I2c clock still results in about 100ms buffer transmission to OLED: 12 | u8g2.setBusClock(1000000); 13 | u8g2.begin(); 14 | } 15 | 16 | void renderDigits(char uSphStr[16], char cpmStr[16]) 17 | { 18 | uint16_t y = 14; 19 | uint16_t xCpm = 56; 20 | uint16_t xUSph = 127; 21 | 22 | u8g2.setFont(u8g2_font_crox4hb_tr); 23 | u8g2_uint_t w = u8g2.getStrWidth(uSphStr); 24 | u8g2.setCursor(xUSph - w, y); 25 | u8g2.print(uSphStr); 26 | 27 | w = u8g2.getStrWidth(cpmStr); 28 | u8g2.setCursor(xCpm - w, y); 29 | u8g2.print(cpmStr); 30 | 31 | y = 21; 32 | u8g2.setFont(u8g2_font_4x6_tf); 33 | w = u8g2.getStrWidth("\xB5S/h"); 34 | u8g2.setCursor(xUSph - w, y); 35 | u8g2.print("\xB5S/h"); 36 | 37 | w = u8g2.getStrWidth("cnt/min"); 38 | u8g2.setCursor(xCpm - w, y); 39 | u8g2.print("cnt/min"); 40 | } 41 | 42 | void renderHistoryBarGraph(GeigerData &geigerData) 43 | { 44 | const uint16_t bars = 120; 45 | const uint16_t maxBarHeight = 40; 46 | const uint16_t samplesPerBar = geigerData.sampleCount / bars; 47 | const uint16_t barsPerMinute = 60 / (samplesPerBar * geigerData.sampleSeconds); 48 | 49 | // determine max value for y scale: 50 | uint16_t offset = geigerData.getCurrentSample() % samplesPerBar + 1; 51 | uint32_t maxPulses = 0; 52 | for (int16_t i = 0; i < bars - 1; i++) 53 | { 54 | const uint32_t prevPulses = geigerData.getPreviousPulses(offset, 55 | samplesPerBar); 56 | if (prevPulses > maxPulses) 57 | maxPulses = prevPulses; 58 | 59 | offset += samplesPerBar; 60 | } 61 | 62 | const float maxUSph = geigerData.toMicroSievertPerHour(maxPulses, 63 | samplesPerBar); 64 | const float uSphPerPixel = maxUSph > 40. ? 10. : maxUSph > 4. ? 1. : maxUSph > 0.4 ? 0.1 : 0.01; 65 | // labels and grid 66 | u8g2.setFont(u8g2_font_4x6_tn); 67 | char s[10]; 68 | for (uint16_t i = 10; i <= maxBarHeight; i += 10) 69 | { 70 | u8g2.setCursor(0, 63 - i + 3); 71 | if (uSphPerPixel >= 0.1) 72 | sprintf(s, "%.0f", i * uSphPerPixel); 73 | else 74 | sprintf(s, ".%.0f", i * uSphPerPixel * 10); 75 | 76 | u8g2.print(s); 77 | for (int16_t x = 127 - barsPerMinute; x >= 8; x -= barsPerMinute) 78 | { 79 | u8g2.drawPixel(x, 63 - i); 80 | } 81 | } 82 | 83 | // bars 84 | offset = geigerData.getCurrentSample() % samplesPerBar + 1; 85 | for (int16_t i = 0; i < bars - 1; i++) 86 | { 87 | const uint32_t prevPulses = geigerData.getPreviousPulses(offset, 88 | samplesPerBar); 89 | const float uSph = geigerData.toMicroSievertPerHour(prevPulses, 90 | samplesPerBar); 91 | offset += samplesPerBar; 92 | uint16_t barHeight = 1 + (int)((uSph / uSphPerPixel)); 93 | if (barHeight > 40) 94 | barHeight = 40; 95 | 96 | u8g2.drawVLine(127 - i, 63 - barHeight, barHeight); 97 | } 98 | } 99 | 100 | void updateDisplay(GeigerData &geigerData, char uSphStr[16], char cpmStr[16]) 101 | { 102 | u8g2.clearBuffer(); 103 | renderDigits(uSphStr, cpmStr); 104 | renderHistoryBarGraph(geigerData); 105 | u8g2.sendBuffer(); 106 | } 107 | -------------------------------------------------------------------------------- /src/ingest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "GeigerData.h" 6 | 7 | #include "credentials.h" 8 | 9 | const char *thingsPeakUrl = "api.thingspeak.com"; 10 | 11 | WiFiClient mqttWifiClient; 12 | WiFiClientSecure mqttWifiClientSecure; 13 | MQTTClient mqttClient; 14 | 15 | bool connectWiFi() 16 | { 17 | WiFi.persistent(false); 18 | 19 | uint16_t retries = 10; 20 | while (WiFi.status() != WL_CONNECTED && (retries--) > 0) 21 | { 22 | Serial.print("Trying to connect to "); 23 | Serial.print(wifiSsid); 24 | Serial.print(" ... "); 25 | WiFi.begin(wifiSsid, wifiPassword); 26 | uint16_t waitRemaining = 8; 27 | while (WiFi.status() != WL_CONNECTED && (--waitRemaining) > 0) 28 | { 29 | delay(500); 30 | } 31 | if (WiFi.status() == WL_CONNECTED) 32 | { 33 | Serial.println("successful"); 34 | return true; 35 | } 36 | else 37 | { 38 | Serial.print("failed status="); 39 | Serial.println(WiFi.status()); 40 | } 41 | } 42 | 43 | return WiFi.status() == WL_CONNECTED; 44 | } 45 | 46 | void disconnectWiFi() 47 | { 48 | Serial.println("Disconnecting WiFi"); 49 | WiFi.disconnect(true, true); 50 | } 51 | 52 | void initIngest() 53 | { 54 | connectWiFi(); 55 | } 56 | 57 | void loopIngest() 58 | { 59 | if (mqttClient.connected()) 60 | { 61 | mqttClient.loop(); 62 | } 63 | } 64 | 65 | void deinitIngest() 66 | { 67 | if (WiFi.status() == WL_CONNECTED) 68 | { 69 | disconnectWiFi(); 70 | } 71 | } 72 | 73 | void ingestToThingspeak(GeigerData &geigerData, uint16_t intervalSamples) 74 | { 75 | if (!connectWiFi()) 76 | return; 77 | 78 | if (thingsPeakUrl == NULL || thingsPeakUrl[0] == 0) 79 | return; 80 | 81 | WiFiClient client; 82 | if (!client.connect(thingsPeakUrl, 80)) 83 | { 84 | Serial.print("Connecting to "); 85 | Serial.print(thingsPeakUrl); 86 | Serial.println(" failed"); 87 | // disconnect from WiFi to trigger fresh connect on next ingest 88 | disconnectWiFi(); 89 | } 90 | else 91 | { 92 | client.setTimeout(30); 93 | 94 | const uint32_t pulses = geigerData.getPreviousPulses(1, 95 | intervalSamples); 96 | const uint32_t cpm = uint32_t( 97 | pulses / ((float)intervalSamples * geigerData.sampleSeconds / 60.) + 0.5); 98 | const float uSph = geigerData.toMicroSievertPerHour(pulses, 99 | intervalSamples); 100 | 101 | const String content = "api_key=" + String(thingspeakApiKey) + "&field1=" + String(cpm) + "&field2=" + String(uSph, 3); 102 | 103 | Serial.print("Ingesting cpm="); 104 | Serial.print(cpm); 105 | Serial.print(" uSph="); 106 | Serial.print(uSph, 3); 107 | Serial.print(" ... "); 108 | 109 | client.print("POST /update HTTP/1.1\n"); 110 | 111 | client.print("Host: "); 112 | client.print(thingsPeakUrl); 113 | client.print("\n"); 114 | 115 | client.print("Connection: close\n"); 116 | 117 | client.print("Content-Type: application/x-www-form-urlencoded\n"); 118 | client.print("Content-Length: "); 119 | client.print(content.length()); 120 | client.print("\n\n"); 121 | 122 | client.print(content); 123 | 124 | uint16_t timeout = 40; 125 | while (client.available() == 0 && (--timeout) > 0) 126 | { 127 | delay(50); 128 | } 129 | if (client.available() == 0) 130 | { 131 | Serial.println("failed (no response)"); 132 | } 133 | 134 | Serial.println("response:"); 135 | while (client.available()) 136 | { 137 | char c = client.read(); 138 | Serial.write(c); 139 | } 140 | Serial.println(); 141 | 142 | client.stop(); 143 | } 144 | } 145 | 146 | bool connectMqtt() 147 | { 148 | if (!connectWiFi()) 149 | return false; 150 | 151 | if (mqttHost == NULL || mqttHost[0] == 0) 152 | return false; 153 | 154 | if (!mqttClient.connected()) 155 | { 156 | const bool tls = mqttTlsServerRootCert != NULL && mqttTlsServerRootCert[0] != 0; 157 | Serial.print("Connecting to MQTT host "); 158 | Serial.print(mqttHost); 159 | Serial.print(":"); 160 | Serial.print(mqttPort); 161 | Serial.print(" user "); 162 | Serial.print(mqttUser); 163 | if (tls) { 164 | Serial.print(" with TLS "); 165 | mqttWifiClientSecure.setCACert(mqttTlsServerRootCert); 166 | mqttClient.begin(mqttHost, mqttPort, mqttWifiClientSecure); 167 | } else { 168 | Serial.print(" without TLS "); 169 | mqttClient.begin(mqttHost, mqttPort, mqttWifiClient); 170 | } 171 | 172 | if (mqttClient.connect("esp32-geiger-counter", mqttUser, mqttPassword)) 173 | { 174 | Serial.println(" successful"); 175 | } 176 | else 177 | { 178 | Serial.println(" failed"); 179 | // disconnect from WiFi to trigger fresh connect on next ingest 180 | disconnectWiFi(); 181 | return false; 182 | } 183 | } 184 | 185 | return true; 186 | } 187 | 188 | void disconnectMqtt() 189 | { 190 | mqttClient.disconnect(); 191 | } 192 | 193 | void ingestToMqtt(GeigerData &geigerData, uint16_t intervalSamples) 194 | { 195 | if (connectMqtt()) 196 | { 197 | const unsigned long pulses = geigerData.getPreviousPulses(1, 198 | intervalSamples); 199 | const unsigned long cpm = (unsigned long)(pulses / ((float)intervalSamples * geigerData.sampleSeconds / 60.) + 0.5); 200 | const float uSph = geigerData.toMicroSievertPerHour(pulses, 201 | intervalSamples); 202 | char payload[129]; 203 | sprintf(payload, "{\"pulses\":%lu, \"cpm\":%lu,\"uSph\":%.3f,\"secs\":%d}", 204 | pulses, cpm, uSph, (int)intervalSamples); 205 | 206 | if (!mqttClient.publish(mqttTopic, payload)) 207 | { 208 | mqttClient.disconnect(); 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "driver/pcnt.h" 3 | #include "driver/gpio.h" 4 | #include "driver/rtc_io.h" 5 | #include "display.h" 6 | #include "ingest.h" 7 | #include "GeigerData.h" 8 | 9 | // ~400µs high pulses from Geiger tube on GPIO 18 10 | #define PULSE_PIN 15 11 | #define PULSE_GPIO GPIO_NUM_15 12 | 13 | // switch input for WiFi on (low) and off (high) 14 | #define WIFI_SWITCH_PIN 4 15 | 16 | // blinky LED 17 | #define BLINKY_LED_PIN 18 18 | 19 | // Keep 600 samples of 1s in history (10 minutes), 20 | // calculate radiation for russian STS-6 ("CTC-6") Geiger tube 21 | GeigerData geigerData(600, 1, STS6_CPM_PER_USPH); 22 | 23 | // blinky state 24 | int blinky = 1; 25 | 26 | // Pulses counted by interrupt (while CPU is awake) 27 | volatile uint16_t intPulseCount = 0; 28 | // Pulses counted during ESP light sleep 29 | volatile uint16_t pulseCount = 0; 30 | 31 | // Sample duration in µs 32 | const uint32_t sampleMicros = geigerData.sampleSeconds * 1000000; 33 | // Absolute sample interval start micros 34 | uint32_t sampleStart = 0; 35 | 36 | const int16_t ingestInterval = 60; 37 | int16_t ingestCountdown; 38 | 39 | const int watchdogTimeoutMicros = 40000000L; 40 | hw_timer_t *watchdogTimer = NULL; 41 | 42 | void pulse(); 43 | uint32_t calcRemainingWait(); 44 | boolean wifiSwitchOn(); 45 | uint16_t takeSampleNoSleep(); 46 | uint16_t takeSampleLowPower(); 47 | void IRAM_ATTR watchdogExpired(); 48 | 49 | void setup() 50 | { 51 | Serial.begin(115200); 52 | Serial.println("Starting!"); 53 | 54 | // initialize watchdog timer 55 | watchdogTimer = timerBegin(0, 80, true); 56 | timerAttachInterrupt(watchdogTimer, &watchdogExpired, true); 57 | timerAlarmWrite(watchdogTimer, watchdogTimeoutMicros, false); 58 | timerAlarmEnable(watchdogTimer); 59 | 60 | // OLED 61 | initDisplay(); 62 | 63 | // blinky 64 | pinMode(BLINKY_LED_PIN, OUTPUT); 65 | 66 | // Geiger pulse input 67 | pinMode(PULSE_PIN, INPUT); 68 | 69 | // WiFi switch input 70 | pinMode(WIFI_SWITCH_PIN, INPUT_PULLUP); 71 | if (wifiSwitchOn()) 72 | { 73 | initIngest(); 74 | } 75 | 76 | // initialize sample start 77 | sampleStart = micros(); 78 | ingestCountdown = ingestInterval; 79 | } 80 | 81 | void loop() 82 | { 83 | // blinky 84 | 85 | digitalWrite(BLINKY_LED_PIN, blinky); 86 | blinky = !blinky; 87 | 88 | // reset watchdog 89 | timerWrite(watchdogTimer, 0); 90 | 91 | const uint16_t pulses = 92 | wifiSwitchOn() ? takeSampleNoSleep() : takeSampleLowPower(); 93 | 94 | geigerData.addPulses(pulses); 95 | geigerData.nextSample(); 96 | 97 | if (wifiSwitchOn()) 98 | { 99 | loopIngest(); 100 | ingestCountdown--; 101 | if (ingestCountdown <= 0) 102 | { 103 | ingestCountdown = ingestInterval; 104 | ingestToThingspeak(geigerData, ingestInterval); 105 | ingestToMqtt(geigerData, ingestInterval); 106 | } 107 | } 108 | else 109 | { 110 | deinitIngest(); 111 | } 112 | 113 | // determine current value, average 6 seconds 114 | // because this is very near to the 5 seconds history 115 | // bar width and gives nicely rounded count values 116 | 117 | const uint16_t samples = 6; 118 | const uint32_t prevPulses = geigerData.getPreviousPulses(1, samples); 119 | const uint32_t cpm = prevPulses * (60 / samples); 120 | const float uSph = geigerData.toMicroSievertPerHour(prevPulses, samples); 121 | 122 | // test for display layout: 123 | // const uint32_t cpm = 1000*60; 124 | // const float uSph = geigerData.toMicroSievertPerHour(cpm, 60); 125 | 126 | char cpmStr[16]; 127 | ltoa(cpm, cpmStr, 10); 128 | char uSphStr[16]; 129 | sprintf(uSphStr, "%.2f", uSph); 130 | 131 | // serial output cpm and µS/h 132 | 133 | Serial.print(pulses); 134 | Serial.print(" "); 135 | Serial.print(cpmStr); 136 | Serial.print(" "); 137 | Serial.println(uSphStr); 138 | 139 | updateDisplay(geigerData, uSphStr, cpmStr); 140 | } 141 | 142 | // interrupt handler 143 | void pulse() 144 | { 145 | ++intPulseCount; 146 | } 147 | 148 | uint32_t calcRemainingWait() 149 | { 150 | const uint32_t remaining = sampleMicros - (micros() - sampleStart); 151 | return remaining > sampleMicros ? 0 : remaining; 152 | } 153 | 154 | boolean wifiSwitchOn() 155 | { 156 | return digitalRead(WIFI_SWITCH_PIN) == 0; 157 | } 158 | 159 | uint16_t takeSampleNoSleep() 160 | { 161 | attachInterrupt(PULSE_PIN, pulse, RISING); 162 | 163 | int32_t remainingWait = calcRemainingWait(); 164 | delayMicroseconds(remainingWait); 165 | sampleStart = micros(); 166 | noInterrupts(); 167 | const int16_t pulses = intPulseCount; 168 | intPulseCount = 0; 169 | interrupts(); 170 | 171 | return pulses; 172 | } 173 | 174 | uint16_t takeSampleLowPower() 175 | { 176 | // To save battery power, use light sleep as much as possible. 177 | // During light sleep, no counters or interrupts are working. 178 | // Therefore simply wake up on each pulse signal change. This 179 | // is fast enough for the low frequencies from a Geiger tube 180 | // (below 2kHz): 181 | // Wake up at end of sample period. Also 182 | // wake up on pulse getting high and getting low. 183 | // Waking up directly on rising/falling edges is not possible, 184 | // so wait until level change. 185 | // Switch to interrupt counting while awake for calculations 186 | // and display update. 187 | 188 | // stop interrupt (switch to active wakeup counting loop): 189 | detachInterrupt(PULSE_PIN); 190 | 191 | int32_t remainingWait = calcRemainingWait(); 192 | esp_sleep_wakeup_cause_t cause = ESP_SLEEP_WAKEUP_UNDEFINED; 193 | while (cause != ESP_SLEEP_WAKEUP_TIMER && remainingWait > 0) 194 | { 195 | 196 | if (digitalRead(PULSE_PIN)) 197 | { 198 | // wait for low pulse start or sample time end 199 | esp_sleep_enable_timer_wakeup(remainingWait); 200 | gpio_wakeup_enable(PULSE_GPIO, GPIO_INTR_LOW_LEVEL); 201 | esp_sleep_enable_gpio_wakeup(); 202 | esp_light_sleep_start(); 203 | cause = esp_sleep_get_wakeup_cause(); 204 | } 205 | 206 | remainingWait = calcRemainingWait(); 207 | if (cause != ESP_SLEEP_WAKEUP_TIMER && remainingWait > 0) 208 | { 209 | // wait for high pulse start or sample time end 210 | esp_sleep_enable_timer_wakeup(remainingWait); 211 | gpio_wakeup_enable(PULSE_GPIO, GPIO_INTR_HIGH_LEVEL); 212 | esp_sleep_enable_gpio_wakeup(); 213 | esp_light_sleep_start(); 214 | cause = esp_sleep_get_wakeup_cause(); 215 | if (cause == ESP_SLEEP_WAKEUP_GPIO) 216 | { 217 | ++pulseCount; 218 | } 219 | } 220 | 221 | remainingWait = calcRemainingWait(); 222 | } 223 | 224 | // take sample and add to statistics 225 | 226 | sampleStart = micros(); 227 | const int16_t pulses = pulseCount + intPulseCount; 228 | // Serial.print("pc="); 229 | // Serial.print(pulseCount); 230 | // Serial.print(" ipc="); 231 | // Serial.println(intPulseCount); 232 | attachInterrupt(PULSE_PIN, pulse, RISING); 233 | interrupts(); 234 | // reset counters AFTER enabling interrupt to avoid double-counting on high signal 235 | pulseCount = 0; 236 | intPulseCount = 0; 237 | 238 | return pulses; 239 | } 240 | 241 | void IRAM_ATTR watchdogExpired() 242 | { 243 | esp_restart(); 244 | } 245 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | --------------------------------------------------------------------------------