arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.12k stars 4.79k forks source link

Use rule on analog0 to dimm 37 PWM1 #4090

Closed Wifiunterputzdose closed 6 years ago

Wifiunterputzdose commented 6 years ago

Hey folks,

I'm trying to dimm the pwm signal on D5 GPIO14 Sensor (37 PWM1) through a potentiometer whos connected to ADC input of the ESP-12e

Here's a picture of the device configuration in the web interface https://imgur.com/a/GwpjXvi

I tried the example from the wiki

rule on analog#a0div10 do dimmer %value% endon

But it dont change anything on GPIO14. My idea was that is stored in the variable %value% and than I have to use the variable to dimm PWM singal on GPIO14?

If I try manually to dimm the PWM1 output with "dimmer 10" it works.

arendst commented 6 years ago

I guess your ADC is not enabled as that's the default in the provided binaries.

Enable ADC in user_config.h and re-compile.

Wifiunterputzdose commented 6 years ago

Hello Theo thanks for the fast Response.

What I did before is to comment out the #define USE_ADC_VCC line with // at the beginning in the user_config.h. Than made a recompile and generating a bin file.

To comment out like //#define USE_ADC , means enabling the ADC?

Ok, how can i check btw verify that I enabled ADC? Type "Status 10" in the console of the web Interface to get the readed value of ADC?

arendst commented 6 years ago

Yes, status 10 should reflect the ADC state:

10:40:51 CMD: status 10
10:40:51 MQT: stat/wemos8/STATUS10 = {"StatusSNS":{"Time":"2018-10-17T10:40:51","Switch1":"ON","Switch2":"ON","Switch3":"ON","ANALOG":{"A0":5}}}
Wifiunterputzdose commented 6 years ago

As I said before the ADC was enabled. Status 10 gives me the actual value of the adc input.

But the rule don't work >> rule on analog#a0div10 do dimmer %value% endon

I get the following response:

18:27:54 CMD: rule on analog#a0div10 do dimmer %value% endon 18:27:54 RSL: stat/WiFiUnterPutzdose/RESULT = {"Command":"Unknown"}

My target is to dimm the PWM1 output on D5 GPIO14 as a function of the adc input voltage

ascillato commented 6 years ago

If Tasmota said command unknown using the rule command means that you are using an old version. Please update your Tasmota to the latest from http://thehackbox.org/tasmota/

ascillato2 commented 6 years ago

If you need further assistant please complete the troubleshooting template.

Wifiunterputzdose commented 6 years ago

Thanks for your response. Its possible to read the version from the web interface?

This is the way I got the tasmota version >> I changed the branch to development on this site https://github.com/arendst/Sonoff-Tasmota than downloaded the zip file trough the "clone or download"-button and opend the folder in Atom IDE

I dont want to use pregenerated bin files from your link. I want to use my own generated bin files with ATOM because I need the possibility to define/undefine options.

EDIT://

I'm using the following version. This should be new enough or?

19:10:37 CMD: Status 2 19:10:37 RSL: stat/WiFiUnterPutzdose/STATUS2 = {"StatusFWR":{"Version":"6.2.1.15","BuildDateTime":"2018.10.17 18:59:47","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}

ascillato commented 6 years ago

If you need further assistant please complete the troubleshooting template

Wifiunterputzdose commented 6 years ago
ascillato2 commented 6 years ago

Hi,

Thanks for completing the template. :+1: It gaves us a lot of information and that saves us a lot of time.

From your status 0:

{"Status":{"Module":18,"FriendlyName":["Sonoff"],"Topic":"WiFiUnterPutzdose","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0},"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"Software/System restart","Uptime":"0T00:55:29","StartupUTC":"2018-10-17T17:23:51","Sleep":0,"BootCount":3,"SaveCount":13,"SaveAddress":"F7000"},"StatusFWR":{"Version":"6.2.1.15","BuildDateTime":"2018.10.17 18:59:47","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"},"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Chillas",""],"TelePeriod":300,"SetOption":["00008009","55818000","00000000"]},"StatusMEM":{"ProgramSize":487,"Free":516,"Heap":20,"ProgramFlashSize":4096,"FlashSize":4096,"FlashMode":2,"Features":["00000407","6050A790","248003A8","000007C4","000005C0"]},"StatusNET":{"Hostname":"WiFiUnterPutzdose-4073","IPAddress":"192.168.8.127","Gateway":"192.168.8.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.8.1","Mac":"68:C6:3A:97:AF:E9","Webserver":2,"WifiConfig":5},"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_97AFE9","MqttUser":"DVES_USER","MqttType":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15},"StatusTIM":{"UTC":"Wed Oct 17 18:19:20 2018","Local":"Wed Oct 17 19:19:20 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":1},"StatusSNS":{"Time":"2018-10-17T19:19:20","ANALOG":{"A0":552}},"StatusSTS":{"Time":"2018-10-17T19:19:20","Uptime":"0T00:55:29","POWER":"ON","Dimmer":84,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"Chillas","BSSId":"C8:14:51:05:CA:4A","Channel":4,"RSSI":54}}}

using decode-status.py, we obtain:

*** decode-status.py v20180730 by Theo Arends ***
Decoding information for device Sonoff from status report taken at 2018-10-17T19
:19:20

Options
   0 (ON ) Save power state and use after restart
   1 (OFF) Restrict button actions to single, double and hold
   2 (OFF) Show value units in JSON messages
   3 (ON ) MQTT enabled
   4 (OFF) Respond as Command topic instead of RESULT
   5 (OFF) MQTT retain on Power
   6 (OFF) MQTT retain on Button
   7 (OFF) MQTT retain on Switch
   8 (OFF) Convert temperature to Fahrenheit
   9 (OFF) MQTT retain on Sensor
  10 (OFF) MQTT retained LWT to OFFLINE when topic changes
  11 (OFF) Swap Single and Double press Button
  12 (OFF) Do not use flash page rotate
  13 (OFF) Button single press only
  14 (OFF) Power interlock mode
  15 (ON ) Do not allow PWM control
  16 (OFF) Reverse clock
  17 (OFF) Allow entry of decimal color values
  18 (OFF) CO2 color to light signal
  19 (OFF) HASS discovery
  20 (OFF) Do not control Power with Dimmer
  21 (OFF) Energy monitoring while powered off
  22 (OFF) MQTT serial
  23 (OFF) MQTT serial binary
  24 (OFF) Rules once mode until 5.14.0b
  25 (OFF) KNX enabled
  26 (OFF) Use Power device index on single relay devices
  27 (OFF) KNX enhancement
  28 (OFF) RF receive decimal
  29 (OFF) IR receive decimal
  30 (OFF) Enforce HASS light group
  31 (OFF) Do not show Wifi and Mqtt state using Led
  50 (OFF) Timers enabled
  51 (OFF) Generic ESP8285 GPIO enabled
  52 (OFF) Add UTC time offset to JSON message

Features
  Language LCID = 1031
  MQTT_HOST_DISCOVERY
  MQTT_PUBSUBCLIENT
  NO_EXTRA_4K_HEAP
  PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
  USE_BMP
  USE_CLASSIC
  USE_CSE7766
  USE_DHT
  USE_DISCOVERY
  USE_DISPLAY_LCD
  USE_DISPLAY_MATRIX
  USE_DISPLAY_MODES1TO5
  USE_DISPLAY_SSD1306
  USE_DOMOTICZ
  USE_DS18x20
  USE_DS3231
  USE_EMULATION
  USE_ENERGY_SENSOR
  USE_HLW8012
  USE_HOME_ASSISTANT
  USE_HTU
  USE_MCP39F501
  USE_SHT
  USE_SMARTCONFIG
  USE_WEBSERVER
  USE_WPS
  USE_WS2812
  VTABLES_IN_FLASH
  WEBSERVER_ADVERTISE

So, we can see there that there is not USE_RULESso you have that disabled in your firmware.

That is why Tasmota does not recognice the RULEcommand.

Wifiunterputzdose commented 6 years ago

AH ok thanks. Sry was my first post. Ok these would make sense. But where is the line to enable the Rules?

Something goes wrong. But why? I deleted the // in the USE_RULES in user_config.h https://imgur.com/a/MKAWmsB

Should I have else to do?

Theres also an user_config_override_sample.h. Should I place there also the #define USE_RULES

ascillato2 commented 6 years ago

If you delete or comment the line #define USE_RULES you are not going to have the rules feature in your firmware.

I recommend to use Tasmota as default. At least up to you solve your issues. Then, from something that is working, you can start to modifying and experimenting things.

The precompiled bins are being made from the actual codebase. The latest is http://thehackbox.org/tasmota/ Those are recommended when starting with Tasmota

Wifiunterputzdose commented 6 years ago

Ok I tried to use the precompiled bin file -> sonoff-classsic.bin But I have the problem to get a connection to the web interface. I see the ESP_97AFE9 network. Can't connect to 192.168.4.1 because I have a private IP Adresse, so changed the IP adresse Gateway DNS etc for the ESP_97AFE9 network but cant connect.

Where can I find all the information to enable rules on tasmota? WHat do you mean by Tasmota as default?

ascillato commented 6 years ago

Sonoff classic does not have rules. Use the sonoff.bin please. For the features that are available on each file, please read the readme.

Wifiunterputzdose commented 6 years ago

I found the following file in the file directory : xdrv_10_rules.ino

ifdef USE_RULES checks if RUles are defined. Rules should be work.

ascillato commented 6 years ago

WHat do you mean by Tasmota as default?

To use the code without being modified. Please, just download again the code and compile. Rules are enabled by default.

For use rule you need to have the following line in _userconfig.h:

#define USE_RULES

ascillato commented 6 years ago

Remember that you can find us also in the chat (https://discord.gg/Ks2Kzd4)

Wifiunterputzdose commented 6 years ago

Hi now I flashed the sonoff.bin as you recommended from here http://thehackbox.org/tasmota/

But in this sonoff.bin file theres no ADC enabled. Status 10 in the console dont response with the actual analog value. The release said that ADC should be enabled. Whats wrong with this bin file?

15:26:58 CMD: Status 0 15:26:58 RSL: stat/sonoff/STATUS = {"Status":{"Module":18,"FriendlyName":["Sonoff"],"Topic":"sonoff","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}} 15:26:58 RSL: stat/sonoff/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"Software/System restart","Uptime":"0T00:06:51","StartupUTC":"2018-10-18T14:20:07","Sleep":0,"BootCount":4,"SaveCount":13,"SaveAddress":"F7000"}} 15:26:58 RSL: stat/sonoff/STATUS2 = {"StatusFWR":{"Version":"6.2.1.17","BuildDateTime":"2018-10-17T16:00:45","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}} 15:26:58 RSL: stat/sonoff/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["Chillas","Chillas"],"TelePeriod":300,"SetOption":["00008009","55818000","00000000"]}} 15:26:58 RSL: stat/sonoff/STATUS4 = {"StatusMEM":{"ProgramSize":484,"Free":516,"Heap":16,"ProgramFlashSize":4096,"FlashSize":4096,"FlashMode":2,"Features":["00000809","0FDAE794","000003A0","23B617CE","00001BC0"]}} 15:26:58 RSL: stat/sonoff/STATUS5 = {"StatusNET":{"Hostname":"WifiModul","IPAddress":"xx","Gateway":"xx","Subnetmask":"xxx","DNSServer":"xx","Mac":"xxx","Webserver":2,"WifiConfig":5}} 15:26:58 RSL: stat/sonoff/STATUS6 = {"StatusMQT":{"MqttHost":"","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_97AFE9","MqttUser":"DVES_USER","MqttType":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}} 15:26:58 RSL: stat/sonoff/STATUS7 = {"StatusTIM":{"UTC":"Thu Oct 18 14:26:58 2018","Local":"Thu Oct 18 15:26:58 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":1,"Sunrise":"07:15","Sunset":"17:55"}} 15:26:58 RSL: stat/sonoff/STATUS10 = {"StatusSNS":{"Time":"2018-10-18T15:26:58"}} 15:26:58 RSL: stat/sonoff/STATUS11 = {"StatusSTS":{"Time":"2018-10-18T15:26:58","Uptime":"0T00:06:51","Vcc":2.371,"POWER":"OFF","Dimmer":10,"Fade":"OFF","Speed":1,"LedTable":"OFF","Wifi":{"AP":1,"SSId":"xxx","BSSId":"xxx","Channel":4,"RSSI":78}}}

ascillato commented 6 years ago

No, There is nothing wrong.

In the releases said that ADC is disabled. USE_ADC_VCC is to use the Analog input to measure the Power supply voltage.

The only one that have ADC enabled for analog readings on the A0 pin is _sonoffsensors.bin

Please use that file instead.

Wifiunterputzdose commented 6 years ago

Ok now rules and adc works.

But I got still the same problem:

If I type in the console: rule on analog#a0div10 do dimmer %value%

I get the following response:

16:23:51 CMD: rule on analog#a0div10 do dimmer %value% endon 16:23:51 RSL: stat/sonoff/RESULT = {"Rule1":"OFF","Once":"OFF","StopOnError":"OFF","Free":470,"Rules":"on analog#a0div10 do dimmer %value% endon"}

My assumption is that the Rule1 has to turn on or?

Wifiunterputzdose commented 6 years ago

Hey I got it work :D

I didnt know that typing in "Rule 1" activate the rule

ascillato commented 6 years ago

Great!!! Glad to know that now it is working for you :+1: