The Shelly Plus H&T is a WiFi connected temperature and humidity sensor with a nice e-ink display and local MQTT connectivity which can be used without the involvement of any cloud service.
Unfortunately Shelly use a JSON MQTT structure, therefore it can’t be connected directly to emonPi / emonBase MQTT, I used a simple nodeRED flow to decode the MQTT and post to the emonPi / emonBase:
- Connect Shelly Plus H&T to local WiFi network, following Shelly user guide
- Put Shelly into WiFi AP mode by pressing the button on the back
- Connect to Shelly WiFi AP
- browse to http://192.168.33.1
- Enter in local WiFi details
- Configure Shelly MQTT to connect to emonPi / emonBase MQTT broker
- Wake up Shelly using button on the rear
- Connect to Shelly on local WiFi network using local IP
- Configure MQTT as follows:
– MQTT prefix:shelly
– hostname:emonpi
– username:emonpi
– password:emonpi2016
– Enable all status updates
e.g
At this point we can use MQTT explorer to connect to emonPi MQTT using the same credentials and see the data coming from the Shelly:
We’re interested in the temperature reading on topic shelly/status/temperature:0
, as you can see this temperature reading of 23.1C
is in JSON encoding, let’s use nodeRED to decode this and re-publish it to the correct MQTT structure of emonPi:
- Install NodeRED on emonPi / emonBase: Running on Raspberry Pi : Node-RED
Import this nodered flow which subscribes to MQTT topic shelly/status/temperature:0
, extracts the temperature value from the JSON and then publishes the numerical value to emon/shelly/indoorT
.
[{"id":"f3520e0179695c89","type":"mqtt out","z":"41627eb6fef015f6","name":"","topic":"emon/shelly/indoorT","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"440a5329ca832801","x":580,"y":200,"wires":[]},{"id":"440a5329ca832801","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]
The data will then appear in local Emoncms Inputs and can be logged to a Feed, I would recommend using ‘variable interval’ Emoncms feed type since the Shelly only posts data when there is a change in temperature rather than periodically ever x seconds.
The update rate seems good enough for indoorT monitoring, I’m currently powering the unit via USB-C, I’m not sure if the update rate will be slower if running on batteries: