# EmonHub MQTT to GPIO

**URL:** <https://community.openenergymonitor.org/t/emonhub-mqtt-to-gpio/12755>\
**Category:** emonHub\
**Tags:** mqtt\
**Created:** [16 December 2019 13:30 UTC](https://community.openenergymonitor.org/t/emonhub-mqtt-to-gpio/12755 "2019-12-16T13:30:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![P49](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/58f4c7/32.png) [@P49](https://community.openenergymonitor.org/u/P49)\
**Post date:** [16 December 2019 13:30 UTC](https://community.openenergymonitor.org/t/emonhub-mqtt-to-gpio/12755/1 "2019-12-16T13:30:25Z")

</div>

**GPIO port control by threshold in temperature**

As I understand it, the signal from the temperature sensor goes via the EmonTX to the EmonHub via MQTT (at least that’s what I see in the log) and is sent by the EmonHub to EmonCMS.

It is also possible to have the RaspberryPi switch a GPIO, that is well known.

Now I would like to have GPIO 17 switched on using the MQTT of the temperature. I’ve read a lot but I’m not out yet.

It is my intention to set off a buzzer (GPIO 17) for 30 seconds if the temperature exceeds a certain value (TempH).

It looks like this.

- GPIO 17 gets voltage at a fixed temperature (TempH = 60ºC) and after 5 seconds automatically becomes powerless.

- GPIO 17 may only become active again after the sensor has dropped 10ºC in relation to the set temperature (TempL = TempH - 10).

- I connect an Optocoupler to GPIO 17

- Optocoupler switches on a delay relay when live

- Delay relay switches buzzer on and switches off after 30 seconds.

I would like the actions that are done to be visible in EmonCMS as well and to be stored in a CSV.

Who can help me with this?

Translated with [DeepL Translate: The world's most accurate translator](http://www.DeepL.com/Translator) (free version)

---

<div class="post-metadata">

**Author:** ![TrystanLea](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/trystanlea/32/31_2.png) [@TrystanLea](https://community.openenergymonitor.org/u/TrystanLea)\
**Post date:** [17 December 2019 20:02 UTC](https://community.openenergymonitor.org/t/emonhub-mqtt-to-gpio/12755/2 "2019-12-17T20:02:23Z")

</div>

Hello @P49 sorry it’s not something I have done before, you might be able to do the logic control side of things with NodeRed. See:

[Node-RED - Guide | OpenEnergyMonitor](https://guide.openenergymonitor.org/integrations/nodered/)

and perhaps:

[Control Raspberry Pi GPIO using node-RED – E-Tinkers](https://www.e-tinkers.com/2019/02/control-raspberry-pi-gpio-using-node-red/)
