Interfacing Geiger-Müller counter for house monitoring with ESP8266 and MQTT
Arduino IDE sketch. Requires ArduinoJSON, ArduinoOTA and PubSubClient libraries.
ino - 6.58 kB - 07/07/2019 at 15:10
Here is the list of connections between parts.
The RadiationD module power and cpm output is on the P3 connector. You might also want to remove J1 jumper to make the module silent.
Between P3 connector on RadiationD module and other parts:
P3.VCC -> POWER.+5V P3.GND -> POWER.GND P3.VIN -> ESP01.GPIO2
Between ESP-01 and other parts:
ESP01.VCC -> POWER.+3.3V ESP01.CHPD -> ESP01.VCC ESP01.GND -> POWER.GND EPS01.GPIO02 -> P3.VIN
Between CJMCU power supply module and other parts:
POWER.+5V -> P3.VCC POWER.GND -> P3.GND POWER.GND -> ESP01.GND POWER.+3.3V -> ESP01.VCC
The code that I provided simply counts clicks from the GPIO2 and once per minute sends JSON message to predefined MQTT broker.
/// Geiger counter /// Geiger tube parameters ///
TUBE_NAME will appear in the message topic.
TUBE_FACTOR is necessary to convert CPM into uSv/h. This depends on actual tube used. My module had Chinese J305 tube and for that model value 0.00812 is the conversion factor.
//#define WIFIPASSWORD "12345secret" const char* myhostname = "esp01geiger"; const char* ssid = "Springfield"; const char* password = WIFIPASSWORD; const char* mqttServer = "iotlocal.lan"; const uint32_t mqttPort = 1883;
"Springfield" and password defined in WIFIPASSWORD are my WiFi network parameters.
I'm using broker running in my LAN available at iotlocal.lan address, listening on port 1883.
"esp01geiger" is a friendly hostname to make it easier to recognize the device in Arduino IDE OTA (over-the-air) update and on my router summary page.
For debug purposes there are some messages sent over the serial port.
const char* mqttPrefix = "esphome";
This is topic prefix under which all messages coming from sensors in my setup appear.
You need Arduino IDE with following libraries installed: