Jump to content

MQTT analog request...


EWhite

Recommended Posts

im using the analog pin on a Wemos d1 ex with tasmota to monitor the voltage of a battery.

In order to do this, the analog output in MQTT is like this:

20:34:45.457 MQT: tele/Temp1/SENSOR = {"Time":"2023-04-10T20:34:45","ANALOG":{"Range":100},"AM2301":{"Temperature":79.2,"Humidity":51.2,"DewPoint":59.6},"TempUnit":"F"}

 

in your code you only have analog to read A0: only...

there are several analog options :

 

# Option WebUI display MQTT message
0 None none none
1 Analog Analog0 %value% {"A0":%value%}
2 Temperature Temperature %value% °C (°F) {"Temperature":%value%},"TempUnit":"C"}
3 Light Illuminance %value% lux {"Illuminance":%value%}
4 Button none none
5 Buttoni none none
6 Range Range %value% {"Range":%value%}
7 CT Power Voltage 230 V
Current %value A
Power %value W
Energy Total %value kWh
{"Energy":%value,"Power":%value,"Voltage":230,"Current":%value}
9 pH ph %value {"pH":%value}
10 MQ-X MQ-X %value ppm

{"MQX":%value}

 

 

 

Im gonna be selfish and just ask for the range to be added :)

but i can see a possibility of other being used also..the options are endless

thanks!

Link to comment
  • 2 weeks later...
  • 2 weeks later...
  • 4 weeks later...
On 5/3/2023 at 11:12 AM, xKing said:

Analog was a community contribution so I have no idea what that does. MQTT is mostly for people who are willing to mess with the code :) 

can you change MAX analog from 1024 to 2048?

that might just do the trick without a bunch of coding.....

Link to comment
  • 1 month later...
On 6/3/2023 at 9:11 PM, EWhite said:

would gladly pay to be able to get analog "range" to work....so i can monitor batteries..

Hi @EWhite,

I'm just starting into adding to the MQTT Node Server with dimmer functionality. I'm a newbie, but have it almost working. I also have a need for analog, but am fine with it's current set up... If you specify exactly what you need (start with which device you are using!), and don't mind waiting until I figure things out... I'll be glad to help.

 

Link to comment
36 minutes ago, TriLife said:

Hi @EWhite,

I'm just starting into adding to the MQTT Node Server with dimmer functionality. I'm a newbie, but have it almost working. I also have a need for analog, but am fine with it's current set up... If you specify exactly what you need (start with which device you are using!), and don't mind waiting until I figure things out... I'll be glad to help.

 

@EWhiteI see in your first post that you use a WeMos D1 EX... Not sure about the EX though. Please send me a link. I got the WeMos D1 mini running just fine ...

Are you trying to monitor the WeMos supply voltage or an external battery?

 

Link to comment

Hi @EWhite,

So, if you look at this link, https://tasmota.github.io/docs/ADC/ 

You can set the output format you want. Select the "Range" option and stat/topic/Analog will give you the reading formatted that way. The MQTT NS will read it as per normal... No mods required.

In configuring your MQTT devlist, All you need to do is change your cmd_topic to cmnd/topic/RANGE and status_topic to stat/topic/range. Or do it in the devfile, which I find a lot easier to write...

If that doesn't work, let me know, I'll run some tests.

Edited by TriLife
added missing information
Link to comment

no workie...in code it is only looking for A0: and mqtt is sending Range:

i tried above no joy..code needs to be added for each sub under analog...

here is my example :

21:20:57.150 MQT: tele/Temp1/STATE = {"Time":"2023-07-18T21:20:57","Uptime":"1T03:41:00","UptimeSec":99660,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":3,"POWER":"OFF","Wifi":{"AP":1,"SSId":"nsa_surveillance_32","BSSId":"1E:21:B4:48:8C:E6","Channel":10,"Mode":"11n","RSSI":74,"Signal":-63,"LinkCount":6,"Downtime":"0T00:01:11"}}
21:20:57.164 MQT: tele/Temp1/SENSOR = {"Time":"2023-07-18T21:20:57","ANALOG":{"Range":1238},"AM2301":{"Temperature":81.0,"Humidity":77.1,"DewPoint":73.1},"TempUnit":"F"}

range on this example is 12.38 volts...but code only allows for a max of 1028.

does this help?

Link to comment

Good morning @EWhite

I was able to replicate your findings on my local Wemos. 

3 hours ago, TriLife said:

Which template are you using for your WeMos D1?

Do you need all the environmental data T/H/dew etc, or are you after just the analog input?

Still would be good to get these answers.

Here are my STATE and SENSOR outputs:

16:05:26.370 MQT: tele/Creek/STATE = {"Time":"2023-07-19T16:05:26","Uptime":"0T00:00:09","UptimeSec":9,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":XXXX}
16:05:26.435 MQT: tele/Creek/SENSOR = {"Time":"2023-07-19T16:05:26","ANALOG":{"Range":8}}

note MqttCount: 1 in STATE and only Range in SENSOR...

Link to comment

im using the generic template...and i am using the enviro data also

Module type (Sonoff Basic)

Generic (18)


D3 GPIO0	
None
TX GPIO1	
None
D4 GPIO2	
None
RX GPIO3	
None
D2 GPIO4	
AM2301
D1 GPIO5	
Relay

1
D6 GPIO12	
None
D7 GPIO13	
None
D5 GPIO14	
None
D8 GPIO15	
None
D0 GPIO16	
None
A0 GPIO17	
ADC Range

 

Edited by EWhite
Link to comment

Hello @EWhite;

I put a Beta version of MQTT on the Non-Production Store (Beta-Store), which will give you Range etc and also has a dimmer function. It should be the second 0.0.11 in there (sorry)

If you can't access that store, have a look at https://github.com/Trilife/udi-mqtt-pg3x

This should get you going, provided you have a pure Analog set up. The reason I am saying this, is because you seem to have 3 MqttCounts in your set up:

On 7/18/2023 at 9:25 PM, EWhite said:
21:20:57.150 MQT: tele/Temp1/STATE = {"Time":"2023-07-18T21:20:57","Uptime":"1T03:41:00","UptimeSec":99660,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":3,"POWER":"OFF","Wifi":{"AP":1,"SSId":"nsa_surveillance_32","BSSId":"1E:21:B4:48:8C:E6","Channel":10,"Mode":"11n","RSSI":74,"Signal":-63,"LinkCount":6,"Downtime":"0T00:01:11"}}

which produces additional data like AM2301:

On 7/18/2023 at 9:25 PM, EWhite said:
21:20:57.164 MQT: tele/Temp1/SENSOR = {"Time":"2023-07-18T21:20:57","ANALOG":{"Range":1238},"AM2301":{"Temperature":81.0,"Humidity":77.1,"DewPoint":73.1},"TempUnit":"F"}

I tested the stet up on my Wemos D1, which only gives you one analog output:

17:41:06.501 MQT: tele/Creek/SENSOR = {"Time":"2023-07-26T17:41:06","ANALOG":{"Range":7}}

 

Beware, as of now it only displays what it finds in RANGE, , TEMPERATURE, ILLUMINANCE, pH, and MQX. No units!

Please let me know, if this works or not. Any and all feedback is welcome. This is my first node server (more of a modification, really).

I'll be gone on vacation for a couple of weeks, so no updates until then.

Cheers;

 

  • Like 1
Link to comment
1 hour ago, Michel Kohanim said:

@TriLife

I am very impressed. Bravo!!!!

With kind regards,
Michel

Thanks @Michel Kohanim,

We have yet to see, if it works on other set ups. Eagerly looking forward to feedback.

The hardest part was dealing with Git! Thanks to @bpwwer and @bmercier for their infinite patience.

Edited by TriLife
added missing information
Link to comment

ok.. got it installed and it is running.. but...

it still only show a max of 1024 in AC....

Looking at the node server nodes it also only show 1024...

going to look at logs and see what it shows...

 

Link to comment

also.. i dunno what MqttCounts is.. i have 3 different devices....but only need the analog on one of them...

2023-07-27 22:21:26,664 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING shortPoll
2023-07-27 22:21:29,612 Thread-5   udi_interface      DEBUG    mqtt-poly:_on_message: Received {"Time":"2023-07-27T22:21:28","ANALOG":{"Range":1248},"AM2301":{"Temperature":90.3,"Humidity":56.9,"DewPoint":72.9},"TempUnit":"F"} from tele/Temp1/SENSOR
2023-07-27 22:21:29,614 Thread-5   udi_interface.node DEBUG    node:setDriver: temp1:Temp1 Reporting set ST to 1 to Polyglot
2023-07-27 22:21:29,615 Thread-5   udi_interface.node DEBUG    node:reportDriver: Updating value to 1
2023-07-27 22:21:29,616 Thread-5   udi_interface.interface DEBUG    interface:send: PUBLISHING {'set': [{'address': 'temp1', 'driver': 'ST', 'value': '1', 'uom': 2, 'text': None}]}
2023-07-27 22:21:29,618 Thread-5   udi_interface.node DEBUG    node:setDriver: temp1:Temp1 Reporting set CLITEMP to 90.3 to Polyglot
2023-07-27 22:21:29,620 Thread-5   udi_interface.node DEBUG    node:reportDriver: Updating value to 90.3
2023-07-27 22:21:29,621 Thread-5   udi_interface.interface DEBUG    interface:send: PUBLISHING {'set': [{'address': 'temp1', 'driver': 'CLITEMP', 'value': '90.3', 'uom': 17, 'text': None}]}
2023-07-27 22:21:29,622 Thread-5   udi_interface.node DEBUG    node:setDriver: temp1:Temp1 Reporting set CLIHUM to 56.9 to Polyglot
2023-07-27 22:21:29,623 Thread-5   udi_interface.node DEBUG    node:reportDriver: Updating value to 56.9
2023-07-27 22:21:29,625 Thread-5   udi_interface.interface DEBUG    interface:send: PUBLISHING {'set': [{'address': 'temp1', 'driver': 'CLIHUM', 'value': '56.9', 'uom': 22, 'text': None}]}
2023-07-27 22:21:29,803 MQTT       udi_interface.interface INFO     interface:_message: Successfully set temp1 :: ST to 1 UOM 2
2023-07-27 22:21:29,873 MQTT       udi_interface.interface INFO     interface:_message: Successfully set temp1 :: CLITEMP to 90.3 UOM 17
2023-07-27 22:21:29,912 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message command
2023-07-27 22:21:29,914 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING command
2023-07-27 22:21:29,993 MQTT       udi_interface.interface INFO     interface:_message: Successfully set temp1 :: CLIHUM to 56.9 UOM 22
2023-07-27 22:21:30,014 Thread-5   udi_interface      DEBUG    mqtt-poly:_on_message: Received ON from stat/Temp1/POWER
2023-07-27 22:21:30,015 Thread-5   udi_interface.node DEBUG    node:setDriver: temp2:Temp2 No change in ST's value

and then i did a query on it and it posted this in the log

2023-07-27 22:22:26,668 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message shortPoll
2023-07-27 22:22:26,669 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING shortPoll
2023-07-27 22:23:26,686 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message shortPoll
2023-07-27 22:23:26,688 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING shortPoll
2023-07-27 22:24:17,761 MQTT       udi_interface.interface DEBUG    interface:_message: QUEUING incoming message query
2023-07-27 22:24:17,763 Command    udi_interface.interface DEBUG    interface:_parseInput: DEQUEING query
2023-07-27 22:24:17,764 Command    udi_interface.node INFO     node:reportDrivers: Updating All Drivers to ISY for Temp3(temp3)
2023-07-27 22:24:17,765 Command    udi_interface.interface DEBUG    interface:send: PUBLISHING {'set': [{'address': 'temp3', 'driver': 'ST', 'value': '1', 'uom': 2, 'text': None}, {'address': 'temp3', 'driver': 'GPV', 'value': '1024', 'uom': 56, 'text': None}]}
2023-07-27 22:24:17,998 MQTT       udi_interface.interface INFO     interface:_message: Successfully set temp3 :: ST to 1 UOM 2
2023-07-27 22:24:17,999 MQTT       udi_interface.interface INFO     interface:_message: Successfully set temp3 :: GPV to 1024 UOM 56

so i dont think it parsed the info....

Link to comment

Good Catch @EWhite,

8 hours ago, EWhite said:

found this in editor.xml

 

 <editor id="ANALOG">
            <range uom="56" min="0" max="1024" prec="0" />
    </editor>

 

I'll fix that when I get back home. It'll be a couple of weeks.

As for the MqttCount, that comes from the way you configured the WeMos.

Somehow it thinks you want it to act like a temp/humidity sensor, not just an ADC...

9 hours ago, EWhite said:
Received {"Time":"2023-07-27T22:21:28","ANALOG":{"Range":1248},"AM2301":{"Temperature":90.3,"Humidity":56.9,"DewPoint":72.9},"TempUnit":"F"} from tele/Temp1/SENSOR

You need to check with Tasmota. They have a pretty good user group on

TasmotaUsers • sonoffusers@googlegroups.com

Cheers

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.3k
×
×
  • Create New...