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.2k stars 4.81k forks source link

INA219 on Wemos D1 Mini #3243

Closed kajmaj closed 6 years ago

kajmaj commented 6 years ago

Hi, I am trying to configure Wemos and INA219 work together, but no success yet :( Wemos is on 6.1 with #define USE_INA219 allowed while compilling GPIO5 > SCL and GPIO6 >SDA

14:29:22 CMD: gpios
14:29:22 MQT: stat/wemos_1/RESULT = {"GPIOs1":["0 (None)","1 (DHT11)","2 (AM2301)","3 (SI7021)","4 (DS18x20)","5 (I2C SCL)","6 (I2C SDA)",,,"9 (Switch1)","10 (Switch2)","11 (Switch3)","12 (Switch4)","13 (Switch5)","14 (Switch6)","15 (Switch7)","16 (Switch8)","17 (Button1)","18 (Button2)","19 (Button3)","20 (Button4)","21 (Relay1)","22 (Relay2)","23 (Relay3)","24 (Relay4)","25 (Relay5)","26 (Relay6)","27 (Relay7)","28 (Relay8)","29 (Relay1i)","30 (Relay2i)"]

Status 0:

14:26:10 CMD: status 0
14:26:10 MQT: stat/wemos_1/STATUS = {"Status":{"Module":18,"FriendlyName":["wemos_1"],"Topic":"wemos_1","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}
14:26:10 MQT: stat/wemos_1/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"External System","Uptime":"0T00:00:17","StartupUTC":"2018-07-17T13:25:53","Sleep":0,"BootCount":59,"SaveCount":125,"SaveAddress":"FA000"}}
14:26:10 MQT: stat/wemos_1/STATUS2 = {"StatusFWR":{"Version":"6.1.0","BuildDateTime":"2018-07-17T15:02:22","Boot":31,"Core":"2_4_1","SDK":"2.2.1(cfd48f3)"}}
14:26:10 MQT: stat/wemos_1/STATUS3 = {"StatusLOG":{"SerialLog":0,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["HugoNET",""],"TelePeriod":10,"SetOption":["00008009","55818000"]}}
14:26:10 MQT: stat/wemos_1/STATUS4 = {"StatusMEM":{"ProgramSize":496,"Free":504,"Heap":19,"ProgramFlashSize":1024,"FlashSize":4096,"FlashMode":3,"Features":["00000809","0D402B94","00000000","01011496","00000000"]}}
14:26:10 MQT: stat/wemos_1/STATUS5 = {"StatusNET":{"Hostname":"wemos_1-4318","IPAddress":"192.168.1.70","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"84:F3:EB:0E:30:DE","Webserver":2,"WifiConfig":1}}
14:26:10 MQT: stat/wemos_1/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.107","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_0E30DE","MqttUser":"admin","MqttType":2,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}}
14:26:10 MQT: stat/wemos_1/STATUS7 = {"StatusTIM":{"UTC":"Tue Jul 17 13:26:10 2018","Local":"Tue Jul 17 14:26:10 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":1}}
14:26:10 MQT: stat/wemos_1/STATUS10 = {"StatusSNS":{"Time":"2018-07-17T14:26:10","Switch1":"ON","Switch2":"ON"}}
14:26:10 MQT: stat/wemos_1/STATUS11 = {"StatusSTS":{"Time":"2018-07-17T14:26:10","Uptime":"0T00:00:17","Vcc":2.960,"Wifi":{"AP":1,"SSId":"HugoNET","RSSI":100,"APMac":"F4:F2:6D:9B:94:A2"}}}
Jason2866 commented 6 years ago

Please post result of command: gpio
(without a 's')

kajmaj commented 6 years ago
15:09:04 CMD: gpio
15:09:04 MQT: stat/wemos_1/RESULT = {"GPIO0":"0 (None)","GPIO1":"0 (None)","GPIO2":"6 (I2C SDA)","GPIO3":"0 (None)","GPIO4":"10 (Switch2)","GPIO5":"9 (Switch1)","GPIO12":"0 (None)","GPIO13":"0 (None)","GPIO14":"5 (I2C SCL)","GPIO15":"0 (None)","GPIO16":"0 (None)"}
Jason2866 commented 6 years ago

You have on Gpio14 SCL and on Gpio2 SDA Not the config you wrote. Use web frontend for configuration it is easy.

arendst commented 6 years ago

Try command I2Cscan and see if finds the address of the INA219

kajmaj commented 6 years ago

Hm, changed back as described,

15:23:22 CMD: gpio
15:23:22 MQT: stat/wemos_1/RESULT = {"GPIO0":"0 (None)","GPIO1":"0 (None)","GPIO2":"0 (None)","GPIO3":"0 (None)","GPIO4":"0 (None)","GPIO5":"5 (I2C SCL)","GPIO12":"6 (I2C SDA)","GPIO13":"0 (None)","GPIO14":"0 (None)","GPIO15":"0 (None)","GPIO16":"0 (None)"}

and


15:21:47 CMD: I2Cscan
15:21:47 MQT: stat/wemos_1/RESULT = {"I2CScan":"No devices found"}
```¨
What can be wrong?
kajmaj commented 6 years ago

I will do some soldering and try different I2C for the case that INA219 is faulty

Jason2866 commented 6 years ago

Now you have on Gpio12 SDA For example take a look here https://github.com/arendst/Sonoff-Tasmota/wiki/Wemos-D1-Mini-and-TSL2561-Luminosity-Sensor The Ina219 can be connect the same way as the TSL2561

kajmaj commented 6 years ago

Jason, there was my typo error (sorry), wemos has no GPIO 6 available in configuration I´ve tried several combinations and :( Itś a bit confusing, as there are "GPIOs" and "Ds"

Jason2866 commented 6 years ago

Ok. You have connected Gpio 5 SCL and Gpio 12 SDA?

kajmaj commented 6 years ago

Yes.

15:46:49 CMD: gpio
15:46:49 MQT: stat/wemos_1/RESULT = {"GPIO0":"0 (None)","GPIO1":"0 (None)","GPIO2":"0 (None)","GPIO3":"0 (None)","GPIO4":"0 (None)","GPIO5":"5 (I2C SCL)","GPIO12":"6 (I2C SDA)","GPIO13":"0 (None)","GPIO14":"0 (None)","GPIO15":"0 (None)","GPIO16":"0 (None)"}
15:46:51 MQT: tele/wemos_1/STATE = {"Time":"2018-07-17T15:46:51","Uptime":"0T00:00:24","Vcc":2.956,"Wifi":{"AP":1,"SSId":"HugoNET","RSSI":100,"APMac":"F4:F2:6D:9B:94:A2"}}
Jason2866 commented 6 years ago

Direct connected or via breadboard? Breadboard do often make problems if used for devices with I2C bus... Try to use wires. Soldered or Dupont cables on pin headers

kajmaj commented 6 years ago

Connected directly i.e. INA to Wemos (pin to pin - dupont cables)

Jason2866 commented 6 years ago

Maybe the pullups resistors are too high (SCL SDA). If 10k installed change to 4k7 https://learn.sparkfun.com/tutorials/i2c

ascillato2 commented 6 years ago

Hi,

Have you manage to solve your issue?

kajmaj commented 6 years ago

Hello, not solved yet.

kajmaj commented 6 years ago

I was convinced that sensor is faulty, just for a case I bought a new wemos as well. So connected together iaw https://www.letscontrolit.com/wiki/images/a/a4/INA219_S.jpg SDA to D4/GPIO2 and SCL to D5/GPIO14. Nothing else is connected to wemos except powerplug. I2CScan - no device found. Tested 2 INAs and 2 Wemos D1. Almost sure, that it is not hardware issue, it must be (moreless) "operators" fault. I am not able to find this fault, Mr. Google is not helpful this time at all. 10k pull ups did not work, must buy 4k7 to try last possibility. Well, measured cirquit is not connected but it should not influence it. Update: 4k7 pull up (connected between Ucc and SCL Ucc and SDA pins do not work as well.

arendst commented 6 years ago

Did you connect Gnd and Vcc of Ina219 to Gnd and 3V3 of Wemos too?

kajmaj commented 6 years ago

I have connected Ucc (3,3V) Wemos to INA, GND to GND, Wemos is powered through micro USB, power plug gives 1A. The only unplugged pins on INA are V in+ and V in-

arendst commented 6 years ago

Strange. Did you enable the INA219 in the source? What firmware version do you run? Pls provide output of command status 0.

arendst commented 6 years ago

Just checked your initial status 0 output and it looks fine regarding INA219 enablement....

PS C:\Users\Theo\OneDrive\Documenten\VS\esp8266\Tasmota\Dev\od-dev-v6> .\tools\decode-status.py -f .\tools/status.json

*** decode-status.py v20180730 by Theo Arends ***

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

Features
  Language LCID = 2057
  MQTT_HOST_DISCOVERY
  MQTT_TASMOTAMQTT
  USE_ADC_VCC
  USE_BH1750
  USE_BMP
  USE_DHT
  USE_DISCOVERY
  USE_DS18B20
  USE_EMULATION
  USE_ENERGY_SENSOR
  USE_HOME_ASSISTANT
  USE_I2C
  USE_INA219
  USE_RULES
  USE_SGP30
  USE_TIMERS
  USE_TIMERS_WEB
  USE_WEBSERVER
  WEBSERVER_ADVERTISE
kajmaj commented 6 years ago

INA219 is enabled in the source, I´ve checked it several times.

Status 0:

15:05:27 CMD: status 0
15:05:29 MQT: stat/wemos_2/STATUS = {"Status":{"Module":18,"FriendlyName":["wemos_2"],"Topic":"wemos_2","ButtonTopic":"0","Power":0,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"ButtonRetain":0,"PowerRetain":0}}
15:05:32 MQT: stat/wemos_2/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://sonoff.maddox.co.uk/tasmota/sonoff.bin","RestartReason":"External System","Uptime":"0T00:04:01","StartupUTC":"2018-08-13T13:01:28","Sleep":50,"BootCount":34,"SaveCount":55,"SaveAddress":"F5000"}}
15:05:32 MQT: stat/wemos_2/STATUS2 = {"StatusFWR":{"Version":"6.1.1","BuildDateTime":"2018-07-31T17:59:09","Boot":31,"Core":"2_3_0","SDK":"1.5.3(aec24ac9)"}}
15:05:32 MQT: stat/wemos_2/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["HugoNET",""],"TelePeriod":30,"SetOption":["00008009","55818000"]}}
15:05:32 MQT: stat/wemos_2/STATUS4 = {"StatusMEM":{"ProgramSize":536,"Free":464,"Heap":13,"ProgramFlashSize":1024,"FlashSize":4096,"FlashMode":3,"Features":["00000809","0FDAE794","0C000000","03B6179E","00000000"]}}
15:05:32 MQT: stat/wemos_2/STATUS5 = {"StatusNET":{"Hostname":"wemos_2-0158","IPAddress":"192.168.1.71","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"DC:4F:22:3B:00:9E","Webserver":2,"WifiConfig":1}}
15:05:35 MQT: stat/wemos_2/STATUS6 = {"StatusMQT":{"MqttHost":"192.168.1.107","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_3B009E","MqttUser":"admin","MqttType":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}}
15:05:35 MQT: stat/wemos_2/STATUS7 = {"StatusTIM":{"UTC":"Mon Aug 13 13:05:35 2018","Local":"Mon Aug 13 15:05:35 2018","StartDST":"Sun Mar 25 02:00:00 2018","EndDST":"Sun Oct 28 03:00:00 2018","Timezone":2,"Sunrise":"05:39","Sunset":"20:12"}}
15:05:35 MQT: stat/wemos_2/STATUS10 = {"StatusSNS":{"Time":"2018-08-13T15:05:35"}}
15:05:35 MQT: stat/wemos_2/STATUS11 = {"StatusSTS":{"Time":"2018-08-13T15:05:35","Uptime":"0T00:04:07","Vcc":2.718,"Wifi":{"AP":1,"SSId":"HugoNET","RSSI":100,"APMac":"F4:F2:6D:9B:94:A2"}}}

I really do not know what else I could do to have it working.

ascillato commented 6 years ago

Hi,

Have you managed to solve your issue?

kajmaj commented 6 years ago

Hi, I wish I did. I've tested 2 WeMos D1 R2 UNO, 1 Wemos D1 Mini, 2 INA 219, various pins combinations but no success. Waiting for one more version of Wemos, I will test it and close the issue afterwards.

ascillato2 commented 6 years ago

May your sensor is faulty. Do you have another?

kajmaj commented 6 years ago

As I said, I have 2 INAs, different seller, the same result. If I connect other I2C, it works as expected.

ascillato commented 6 years ago

Hi, any news on this?

kajmaj commented 6 years ago

Apparently, at least in my case, none of Wemos (tested 4) do not work with INA219 and further experiments are wasting of time.

fast-potat0 commented 2 years ago

There is little info about INA219 and tasmota and this thread pops up quite high on google, so I'll comment here :)

I have managed to make INA219 work. I have NodeMCU v3. I tried make it work on tasmota.bin. There is no i2c driver 14 that is required there. Documentation about that: https://tasmota.github.io/docs/I2CDEVICES/ You can check what drivers you have available by entering command i2cdriver. There is only driver 7 in this build.

I flashed tasmota-sensors.bin and run command

11:44:16.160 CMD: i2cdriver 11:44:16.168 MQT: stat/tasmota_DAFCE1/RESULT = {"I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48"}

much better. Driver is here. Configure module to have i2c SDA on D2 and i2c SCL on D1

11:46:16.020 CMD: gpio 11:46:16.029 MQT: stat/tasmota_DAFCE1/RESULT = {"GPIO0":{"224":"Relay1"},"GPIO1":{"0":"None"},"GPIO2":{"0":"None"},"GPIO3":{"0":"None"},"GPIO4":{"640":"I2C SDA"},"GPIO5":{"608":"I2C SCL"},"GPIO12":{"0":"None"},"GPIO13":{"0":"None"},"GPIO14":{"225":"Relay2"},"GPIO15":{"0":"None"},"GPIO16":{"0":"None"},"GPIO17":{"0":"None"}}

INA219 should be automatically found and you should see voltage current and power on main screen.

Jason2866 commented 2 years ago

There is a low change to get a answer in a closed issue. For questions there is Tasmota Discussions. Please ask there