mirror of
https://github.com/schinken/esp8266-geigercounter.git
synced 2024-11-24 01:20:21 +01:00
Add optional pulse mqtt event
This commit is contained in:
parent
6b361a813b
commit
170ebe13af
4 changed files with 16 additions and 1 deletions
|
@ -14,9 +14,11 @@ Here's some code and schematic to connect your mightyohm.com geiger counter to t
|
|||
|
||||
![Schematic](https://raw.githubusercontent.com/schinken/esp8266-geigercounter/master/images/schematic.png "How to connect")
|
||||
|
||||
*You can optionally connect PULSE to D2 of the Wemos D1 and enable PIN_PULSE to receive a mqtt event each count!*
|
||||
|
||||
## images
|
||||
|
||||
<p float="left">
|
||||
<p align="middle">
|
||||
<img src="https://raw.githubusercontent.com/schinken/esp8266-geigercounter/master/images/img-1.jpg" width="32%">
|
||||
<img src="https://raw.githubusercontent.com/schinken/esp8266-geigercounter/master/images/img-2.jpg" width="32%">
|
||||
<img src="https://raw.githubusercontent.com/schinken/esp8266-geigercounter/master/images/img-3.jpg" width="32%">
|
||||
|
|
|
@ -45,6 +45,7 @@ void setup() {
|
|||
|
||||
mqttClient.setClient(wifiClient);
|
||||
mqttClient.setServer(MQTT_HOST, 1883);
|
||||
connectMqtt();
|
||||
|
||||
#ifdef OTA_PASSWORD
|
||||
ArduinoOTA.setHostname(hostname);
|
||||
|
@ -52,8 +53,18 @@ void setup() {
|
|||
ArduinoOTA.begin();
|
||||
#endif
|
||||
|
||||
#ifdef PIN_PULSE
|
||||
pinMode(PIN_PULSE, INPUT);
|
||||
attachInterrupt(PIN_PULSE, onPulse, RISING);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PIN_PULSE
|
||||
ICACHE_RAM_ATTR void onPulse() {
|
||||
mqttClient.publish(MQTT_TOPIC_PULSE, "true");
|
||||
}
|
||||
#endif
|
||||
|
||||
void publishValues() {
|
||||
char tmp[8];
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 142 KiB |
|
@ -8,6 +8,7 @@
|
|||
|
||||
#define PIN_UART_RX D1 // 4
|
||||
#define PIN_UART_TX 13 // UNUSED
|
||||
//#define PIN_PULSE D2
|
||||
|
||||
#define BAUD_GEIGERCOUNTER 9600
|
||||
|
||||
|
@ -22,6 +23,7 @@
|
|||
#define MQTT_TOPIC_CPM "sensor/geigercounter/cpm"
|
||||
#define MQTT_TOPIC_USV "sensor/geigercounter/uSv"
|
||||
#define MQTT_TOPIC_LAST_WILL "sensor/geigercounter/status"
|
||||
#define MQTT_TOPIC_PULSE "sensor/geigercounter/pulse"
|
||||
|
||||
// Only publishes values if changed since last publish
|
||||
#define MQTT_PUBLISH_INTERVAL_MS (10 * 1000)
|
Loading…
Reference in a new issue