-
1Make connections
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
-
2Customize firmware
The code that I provided simply counts clicks from the GPIO2 and once per minute sends JSON message to predefined MQTT broker.
/// Geiger counter #define RECEIVER_PIN 2 // 4=GPIO4=D2 any interrupt able pin (Wemos) // 2=GPIO2 on ESP-01 /// Geiger tube parameters #define TUBE_NAME "j305" #define TUBE_FACTOR 0.00812 ///
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.
#include "wifipassword.h" //#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.
-
3Compile and flash ESP-01
You need Arduino IDE with following libraries installed:
- ArduinoOTA - for updating firmware over-the-air
- ArduinoJSON - for easy and reliable formatting of JSON objects
- PubSubClient - for MQTT connectivity
-
4Check MQTT messages
After powerup the module will announce that it works:
# mosquitto_sub -t '#' -h iotlocal.lan -v esphome/sensor/f4f8e5/connection online
"esphome" is my topic prefix, "f4f8e5" is the ESP8266 ID, this is also part of the device's MAC address
Then each minute an update will be posted:
esphome/sensor/j305/state {"receiver":"f4f8e5","cpm":22,"usv_per_h":0.17864}
"j305" is the TUBE_NAME predefined in the code. The message is a single JSON document with following fields:
- receiver - id of receiver, you may have several devices with different tubes
- cpm - raw number of clicks per minute
- usv_per_h - cpm recalculated into µSv/h so that different tubes can be compared and you can monitor safety in your environment
-
5Configure a new sensor in Home Assistant
Here is a snippet from Home Assistant configuration file that integrates radiation sensor into home automation:
sensor: - platform: mqtt name: Promieniowanie state_topic: "esphome/sensor/j305/state" unit_of_measurement: 'µSv/h' expire_after: 120 availability_topic: "esphome/sensor/f4f8e5/connection" value_template: "{{ value_json.usv_per_h }}"
Values from the sensor will be recorded and shown in Home Assistant interface:
This can be used as input to HA scripts and automations.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Świetny pomysł . Gratulacje . Chciałbym wykorzystać tę ideę i zrobić swój odczyt z Radalert 50. Ten licznik ma na wyjściu cyfrowym stałe 5v i gdy pojawia się impuls wyjście spada do GND . Czy to by działało u mnie ? Oczywiście zrobił bym dzielnik wejściowy dostosowujący do max napięcia wejściowego w esp .
Are you sure? yes | no
Witam po roku i dziękuję! Mam nadzieję, że już zrobiłeś swój projekt i działa, bo wydaje mi się, że nie powinno być problemu z odwróconym sygnałem. ESP8266 może generować przerwania na oba zbocza sygnału - albo rosnące albo malejące. Podobno nawet dzielnik napięcia nie jest potrzebny ;)
Are you sure? yes | no