Shelly Uni Problems

I have a greenhouse (actually, a hoophouse) with a solar power system (solar panels, controller/charger, batteries) that power a fan on thermostat as well as a Sonoff THR316 to report temperature/humidity. I wanted to monitor battery voltage level also, so I got a Shelly Uni.

Turns out the Uni will reset to factory default config (at least it will lose it’s wifi credential info) if the power cycles 5 times (which, I think, means if the voltage drops below a strict 12v), and my solar system is appears to be doing that.

So I flashed Tasmota onto it using:

Now I have 13.1.0 running and looks good to me.

But, I just can’t get the ADC template right.

I’m using this template:

{"NAME":"Shelly Uni new","GPIO":[320,0,0,0,225,1216,0,0,192,193,194,224,0,4704],"FLAG":0,"BASE":18}

I tried setting GPIO to ADC RANGE as well as ADC INPUT.

Using ADC INPUT, the Uni reports a value around 700 (697-748 is the range it has stayed in) for DC voltage across the white and green wires when the voltage ranges from ~10.5 to 12vdc.

I tried messing with the adcparam 6,x,x,x,x remapping and that changed the values but I can’t figure out how to get it reflect the actual voltage.

I tried to follow the instructions here, but got no where:

https://tasmota.github.io/docs/ADC/#commands

Here is a status0 output:

08:20:19.428 MQT: stat/tasmota_E20EC0/STATUS0 = {"Status":{"Module":0,"DeviceName":"Hoophouse Shelly Uni Tasmota 1","FriendlyName":["Hoophouse Shelly Uni Tasmota 1",""],"Topic":"tasmota_E20EC0","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0},"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":" http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"Exception","Uptime":"0T05:29:04","StartupUTC":"2023-08-31T01:51:15","Sleep":50,"CfgHolder":4617,"BootCount":32,"BCResetTime":"2023-08-30T09:54:56","SaveCount":119,"SaveAddress":"F7000"},"StatusFWR":{"Version":"13.1.0(tasmota)","BuildDateTime":"2023-08-15T07:58:36","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8266EX","CR":"420/699"},"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["2point4",""],"TelePeriod":300,"Resolution":"558180C0","SetOption":["00008009","2805C80001000600003C5A0A192800000000","00008080","00006000","00004000","00000000"]},"StatusMEM":{"ProgramSize":634,"Free":368,"Heap":23,"ProgramFlashSize":1024,"FlashSize":2048,"FlashChipId":"15400B","FlashFrequency":40,"FlashMode":"DOUT","Features":["00000809","8F9AC787","04368001","000000CF","010013C0","C000F981","00004004","00001000","54000020","00000080"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45,62,68","Sensors":"1,2,3,4,5,6","I2CDriver":"7"},"StatusNET":{"Hostname":"tasmota-E20EC0-3776","IPAddress":"192.168.0.243","Gateway":"192.168.0.1","Subnetmask":"255.255.255.0","DNSServer1":"1.1.1.1","DNSServer2":"8.8.8.8","Mac":"C4:5B:BE:E2:0E:C0","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0},"StatusMQT":{"MqttHost":"192.168.0.103","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_E20EC0","MqttUser":"tasmota","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4},"StatusTIM":{"UTC":"2023-08-31T07:20:19","Local":"2023-08-31T08:20:19","StartDST":"2023-03-26T02:00:00","EndDST":"2023-10-29T03:00:00","Timezone":"+01:00","Sunrise":"06:05","Sunset":"19:35"},"StatusSNS":{"Time":"2023-08-31T08:20:19","Switch1":"ON","Switch2":"ON","Switch3":"OFF","ANALOG":{"A0":696},"AM2301":{"Temperature":null,"Humidity":null,"DewPoint":null},"TempUnit":"C"},"StatusSTS":{"Time":"2023-08-31T08:20:19","Uptime":"0T05:29:04","UptimeSec":19744,"Heap":22,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":33,"MqttCount":1,"POWER1":"OFF","POWER2":"OFF","Wifi":{"AP":1,"SSId":"2point4","BSSId":"1A:FD:74:50:0F:CC","Channel":3,"Mode":"11n","RSSI":40,"Signal":-80,"LinkCount":1,"Downtime":"0T00:00:17"}},"StatusSTK":{"Exception":29,"Reason":"Exception","EPC":["4000df64","00000000","00000000"],"EXCVADDR":"00000000","DEPC":"00000000","CallChain":["40101584","4026ba6f","4026ba04","4026b9ab","4026ab04","4026ab2d","40268551","40268546","401039e6","40264905","40100b38","4026928f","40000f58","40268d02","40272467","40271d27","4024fc98","40000f49","40000f49","40000e19","40105b65","40105b6b","4010000d","40270c08","40270bb9","40105a5f","40103343","40103524","40100b38","40102bdd","401027ac"]}}

This is a comparison of a Uni with the original OS (Mongoose, I believe) vs. Tasmota:

Can someone please help?

Thank you!

Can you do something like calibrate_linear? So actually measuring (and supplying) voltages and map the adc values, in esphome it can be as simple as:

sensor:
  - platform: adc
    pin: A0
    unit_of_measurement: V
    name: "Battery Voltage"
    filters:
      - calibrate_linear:
         method: least_squares
         datapoints:
          # Map 0.0 (from sensor) to 1.0 (true value)
          - 0.0 -> 0.0
          - 600.0 -> 7.8
          - 650.0 -> 9.1
          - 700.0 -> 10.5
          - 750.0 -> 12.0
          - 800.0 -> 13.4

Wow!

I have no idea, but that looks wonderful interesting and powerful.

Is “calibrate_linear” an ESPhome feature or an HA feature?

It’s from esphome. Part of the filter set available for all sensor components :muscle:

You can migrate ota from tasmota to esphome (and probably vice versa too) :point_down:

1 Like

Thank you very much for the info on ESPhome.

It appears there are certainly many people who greatly prefer ESPhome to Tasmota.

Always (so much) more to learn!

Such a column was suitable for shelly_uni
sensor:

  • platform: adc
    pin: GPIO17
    unit_of_measurement: V
    name: “Battery Voltage”
    filters:
    • multiply: 30.8

hey @josephny
Did you get this working right, & did your Uni stop self-resetting? Are you sure it was the ESPhome firmware that solved it for you?

I first found your post on Reddit, then here. I was surprised you weren’t able to turn off the self-reset with 5 power-cycles option under the Factory Reset part of the Settings menu on the original Uni firmware? That, and disabling reset-via-onboard-button are both options, at least on more recent versions of Shelly Gen1 devices (i.e. 1.40).

I have 2 Unis, and both were fine for a few months, but in the last few weeks both are factory-resetting themselves frequently, and I can’t work out what the trigger is, especially given that I’ve disabled those 2 self-reset options…