Tasmota, mqtt, battery

Hi guys,

I’m making a battery powered temp sensor with a Huzzah and a battery with tasmota,

I’ve used these a lot and already have the temp readings from the dht11 on the huzzah, I’m trying to get the battery % read?


Thing mqtt:topic:snugtemp "Snug Temp" (mqtt:broker:mosquitto) @ "MQTT" {
        Type number : temperature "Temperature"          [stateTopic="tele/snugtemp/SENSOR", transformationPattern="JSONPATH:$.DHT11.Temperature"]
		Type number : battery 	  "Battery"				 [stateTopic="tele/snugtemp/battery", transformationPattern="JSONPATH:$.battery"]


Number snug_temp_batt     				 "Snug temp battery  [%d %%]"     			       { channel="mqtt:topic:mosquitto:snugtemp:battery" }

tasmota console

14:41:19 MQT: tele/snugtemp/STATE = {"Time":"2020-12-01T14:41:19","Uptime":"0T00:30:16","UptimeSec":1816,"Heap":28,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"Channel":1,"RSSI":58,"LinkCount":1,"Downtime":"0T00:00:05"}}
14:41:19 MQT: tele/snugtemp/SENSOR = {"Time":"2020-12-01T14:41:19","DHT11":{"Temperature":20.0,"Humidity":40.0},"TempUnit":"C"}

I’m using the generic (18) module type

do I need to configure it on the tasmota side? I can’t see battery readings in the console


Yes, you do.

Is it one of these? What happens when you use the template from there?

I didn’t know you had to do this?


Well, if Tasmota isn’t giving you battery data, and you want battery data, something has to change on the Tasmota side so it gives battery data!

No idea if it’s possible though.

Beware that WiFi devices in general are quite power hungry, so you may find yourself changing batteries often. If you want to keep to batteries, I’d suggest have a look at the MySensors project. I’m using one with a DHT22 at the moment.

1 Like

You’ll need to compile a speciale version of Tasmota that support reading Voltage off the analog pin.

You can find more details here: https://tasmota.github.io/docs/ADC/#adc_vcc

Warning: I’ve yet to try it. I’ve build my own d1 mini based temperature sensor and my own arduino “firmware” and I sooo want to move to Tasmota on them. I’ve been using Tasmota on my Sonoff devices for a very long time and I would like to standardize on it.

1 Like

Oh cool! Are these running on battery? How are you finding their life?

They are running on AA size rechargeable batteries. I believe they are 14500 batteries. I’ve programmed them to turn on every 20 minutes, report temperature and humidity, and then go back into deep sleep. They live around 1 - 1 1/2 months on a charge. I’ve actually programmed a “Low Battery” event into the device. Presently, I also calculate “charge level” based on the VCC they report back.

Personally, I’d loved to move them all over to Tasmota, but I’ve been holding out on building my own version of it :wink: I also have a number of Sonoff’s running an old (non-updatable) version on Tasmota. I’m in the process of testing what impact updating these will have on my OH/MQTT setup…

1 Like

Now with picture :slight_smile:

1 Like

Well look at you with your BME280 and your single battery! Do you have a boost circuit on the esp8266 board?

1 Like

Huh? A boost circuit?

Isn’t a 14500 battery 3.7V? Does your D1 run directly from 3.7V? I thought they needed 5V…

Gotcha! It runs just fine off of 3.7V :wink:

1 Like

I’ve read somewhere that the 8266 CPU actually runs off of 3.3v and there’s a converter between the 5v input and the CPU and it’s circuitry. I remember that the wemos run on betwen 3.3v and 6.something…

Yes, of course, you’re absolutely correct - I was having a senior moment!

1 Like

I know how that works and I’ve got the hair color to prove it :wink:

1 Like

I know this is a little bit of an older topic. Just curious if you had somewhere that you posted the code or options you used for the battery powered tasmota device. A buddy and I are looking to build some tasmota humidity/temp sensors with d1 minis and tasmota but the battery usage is for sure an issue. We were hoping to have them sleep most of the time and wake up roughly every 5 minutes to do readings.

1 or 2 18650s or similar batteries was our battery of choice but don’t want to have to swap them constantly.

Hey Jason,

you are probably better off buying sonoff zigbee devices, £10 for a battery powered temp sensor, i’m not sure if you can make one cheaper?