Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to analogue pin #137

Closed
jaysuk opened this issue Mar 2, 2017 · 18 comments
Closed

Access to analogue pin #137

jaysuk opened this issue Mar 2, 2017 · 18 comments
Labels
enhancement Type - Enhancement that will be worked on

Comments

@jaysuk
Copy link

jaysuk commented Mar 2, 2017

On the wemos d1 mini etc, as well as digital pins, there is 1 analogue pin.
Would it be possible to be able to configure this as report the value back?
This value would be between 0 and 1023.

@arendst arendst added the enhancement Type - Enhancement that will be worked on label Mar 3, 2017
@khcnz
Copy link

khcnz commented Mar 12, 2017

I was looking into this - the adc is also available on the sonoff dev and accessing the value from firmware is trivial but integrating it into everything else a little harder

How do you propose we would report the data? Using the tele command with the same tele-period? How would you enable/disable the value - perhaps an enable/disable flag on the module selection/gpio configuration page? The ADC can also be configured to report the input voltage to the esp -so perhaps a drop down of ADC Enabled field with the following options "Off", "A0", "VCC"

@arendst
Copy link
Owner

arendst commented Mar 13, 2017

@khcnz now that is seriously usefull. How does anyone want to receive the information?

@davidelang
Copy link
Collaborator

davidelang commented Mar 13, 2017 via email

@khcnz
Copy link

khcnz commented Mar 13, 2017

As A0 repor will be 0-1024 from memory. VCC reports the voltage in mv (so approx 3300). I am still thinking something in the tele command will be most useful - I will have a PR in the next couple of hours to review.

@khcnz
Copy link

khcnz commented Mar 13, 2017

Well I got this mostly implemented so it can be configured on the GPIO page.... only to (rediscover) that you can't configure the VCC/A0 dynamically; You can only set ADC_MODE(ADC_VCC) outside of a function. So we are left with a preprocessor to select between VCC and A0 - which makes the point of dynamically selecting it within the module configuration GPIO PINS page a little pointless...

It also looks like we would likely need a correction factor esp8266/Arduino#721

@khcnz
Copy link

khcnz commented Mar 14, 2017

More useful info http://www.esp8266.com/wiki/doku.php?id=esp8266_gpio_pin_allocations

I propose

  1. PWM1-4 user programmable (so the GPIO pins can be configured to out a PWM signal via analogwrite)
  2. A0 to be configurable to on/off so it can be read with analogRead. When configured on will return result on status 10 command.
  3. Allow a new command PWM1..4 that can set duty with PWM1..4 0..1024
  4. A complile time #define to allow VCC to be read rather than A0 - possibly this could returned on status 1?

arendst added a commit that referenced this issue Mar 14, 2017
4.0.5 20170314
* Add command Status 11 to show power status with Vcc if define
USE_ADC_VCC is enabled (default)
* Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with
define USE_ADC_VCC disabled (#137)
* Add MQTT host:port to timeout message (#199)
arendst added a commit that referenced this issue Mar 14, 2017
4.0.5 20170314
* Add command Status 11 to show power status with Vcc if define
USE_ADC_VCC is enabled (default)
* Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with
define USE_ADC_VCC disabled (#137)
* Add MQTT host:port to timeout message (#199)
@khcnz
Copy link

khcnz commented Mar 16, 2017

@jaysuk I think this one can be closed now?

@jaysuk
Copy link
Author

jaysuk commented Mar 16, 2017 via email

@jaysuk jaysuk closed this as completed Mar 16, 2017
@fttx
Copy link

fttx commented Aug 4, 2017

Hi,

is it possible to publish the analog value of pin A0 as telemetry data? Something like this: tele/sonoff/A0 -> 0.99
If yes is it possible to redefine the range of the value? Like map?

@davidelang
Copy link
Collaborator

davidelang commented Aug 4, 2017 via email

@fttx
Copy link

fttx commented Aug 4, 2017

Ok, thanks, but what is the topic where it gets published?

@davidelang
Copy link
Collaborator

davidelang commented Aug 4, 2017 via email

@roesl
Copy link

roesl commented Dec 21, 2017

How I can activate the Analog pin for Wemos D1 mini pro ? - I dont find the pin in configuration menu

curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
4.0.5 20170314
* Add command Status 11 to show power status with Vcc if define
USE_ADC_VCC is enabled (default)
* Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with
define USE_ADC_VCC disabled (arendst#137)
* Add MQTT host:port to timeout message (arendst#199)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
4.0.5 20170314
* Add command Status 11 to show power status with Vcc if define
USE_ADC_VCC is enabled (default)
* Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with
define USE_ADC_VCC disabled (arendst#137)
* Add MQTT host:port to timeout message (arendst#199)
@K1WIZ
Copy link

K1WIZ commented Jan 14, 2019

Hi, I enabled the ADC pin on compile, and I can see the raw value now displayed on the main web UI. I want t o send this value as a "custom sensor" value to Domoticz. I have a Custom Sensor configured on Domoticz ready to receive the data, and I would think I would find a way to establish the IDX destination for the A0 pin value to be sent to that Domoticz device - but I can't find any selection for the A0 pin on the Module Parameters page on Module Config. It would be really useful to be able to send a raw analog value to Domoticz. My use case is monitoring a water level that uses a simple conduction probe connected to A0. I could then use this raw data to create actionable results via Domoticz. How can I achieve this in Tasmota? I am running version 6.4.1.8

@arendst
Copy link
Owner

arendst commented Jan 14, 2019

Sending every change to MQTT and/or domoticz would flush bothservers.

There is a feature I use to control the dimmer of led by using the ADC input of another device. To use this you will have to define a rule. This rule can also be used not to send the ADC info to the led but to Domoticz.

This is my led rule:

on analog#a0div10 do publish cmnd/ailight/dimmer %value% endon

As you can see there is a trigger that activates with every tenth change in the analog input.

Using the rule examples from the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Rules#examples) you must be easily able to send these changes to domoticz with something like:

on analog#a0div10 do publish domoticz/in {"idx":134,"svalue":"%value%"} endon

You'll have to find the correct domoticz sensor svalue syntax depending on the type of custom sensor you defined. The idx is the idx of the sensor in Domoticz.

@K1WIZ
Copy link

K1WIZ commented Jan 14, 2019

Theo, Thank you for your assistance. Your suggestion helped me to successfully report the values to a custom sensor object in Domoticz. I can see the value sent whenever it changes on A0. I would like to be able to send the value whenever the telemetry period fires. Currently, in the console, I see the value returned every few minutes. The way it is now, Domoticz only gets a new value when there is a delta. Here's what I have in the console:

19:31:51 MQT: tele/sonoff/STATE = {"Time":"2019-01-14T19:31:51","Uptime":"0T00:00:18","SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"MIND CONTROL BG","BSSId":"0E:EC:DA:38:D5:8A","Channel":1,"RSSI":98}}
19:31:51 MQT: tele/sonoff/SENSOR = {"Time":"2019-01-14T19:31:51","ANALOG":{"A0":1024}}
19:36:51 MQT: tele/sonoff/STATE = {"Time":"2019-01-14T19:36:51","Uptime":"0T00:05:18","SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"MIND CONTROL BG","BSSId":"0E:EC:DA:38:D5:8A","Channel":1,"RSSI":98}}
19:36:51 MQT: tele/sonoff/SENSOR = {"Time":"2019-01-14T19:36:51","ANALOG":{"A0":1024}}

Here's what my rule1 looks like:

19:38:42 CMD: rule1
19:38:42 MQT: stat/sonoff/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":423,"Rules":"on analog#a0div10 do publish domoticz/in {"idx":421,"nvalue":0,"svalue":"%value%"} endon"}

Can you suggest how I send this to Domoticz when the telemetry runs? Thanks a lot and thank you for the Tasmota project! I love it.

@arendst
Copy link
Owner

arendst commented Jan 14, 2019

Hint: on tele-analog#a0 do publish ...

@K1WIZ
Copy link

K1WIZ commented Jan 14, 2019

Theo,
That worked. I setup the rule to be:

on tele-analog#a0 do publish domoticz/in {"idx":421,"nvalue":0,"svalue":"%value%"} endon

That did send up the data for A0 on every telemetry, but the value presented is not the value div by 10. (I was seeing 100, but now am seeing 1024).

I tried to add the divider in as follows but then the rule did not work:

on tele-analog#a0div10 do publish domoticz/in {"idx":421,"nvalue":0,"svalue":"%value%"} endon

Perhaps I erred on the syntax or maybe the div10 does not apply correctly? Could I do %value%div10 in the latter part of the rule or would it not scale the value on the fly?

vicfergar pushed a commit to vicfergar/Sonoff-Tasmota that referenced this issue Apr 27, 2019
Due to changes in interlock the right operation mode was not detected correctly. Fixed. As soon as one of the shutterrelay is in interlock configuration is normal or pulse.
ascillato2 pushed a commit that referenced this issue May 4, 2020
Merge pull request #137 from IVI053/patch-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on
Projects
None yet
Development

No branches or pull requests

7 participants