lemurss / st-meter

DTS6619-017 energy meter by SINOTIMER
MIT License
2 stars 1 forks source link

How to add and compile lib using VSCode Platformio #1

Open movcale opened 1 year ago

movcale commented 1 year ago

Could you please point or explain in short, where lib should be placed or included to yaml config file?

Trying with no success

  1. add to yaml

    esphome:
    name: st-meter
    libraries:
    - file:///full-path/st-meter/lib/st_meter
    esp8266:
    board: esp8285
  2. download whole esphome project and put lib into esphome\components\st_meter folder

  3. replacing files in esphome\components\sdm_meter require to modify source lib files and it`s complicated

lemurss commented 1 year ago

where lib should be placed or included to yaml config file?

hi, i placed lib to main place where all ESP's libs, path for me like this: ...\ESPHome\env\Lib\site-packages\esphome\components\

i'm using compile manualy, not used with VSCode and as result - i don't know libs storing path for VSCode

movcale commented 1 year ago

Thanks, will try your way. Surprisingly esphome compile works only in Linux (Windows WSL in my case) At least section "Setting Up Development Environment" https://esphome.io/guides/contributing.html leads to script/setup which has source venv/bin/activate but in windows it should be source venv/Scripts/activate

I have HW-0519 TTL to RS485 with have only RX/TX pins. I am manage to get Sinometer working with it and modified Tasmota.

Here is a russian instructions https://blog.sitefreeman.com/2020/04/03/%D1%82%D1%80%D0%B5%D1%85%D1%84%D0%B0%D0%B7%D0%BD%D1%8B%D0%B9-wi-fi-%D1%81%D1%87%D0%B5%D1%82%D1%87%D0%B8%D0%BA-dds6619-016-017-sinotimer-rs485-tx-rx-modbus-sonoff-basic-majordomo/

lemurss commented 1 year ago

source venv/bin/activate but in windows it should be source venv/Scripts/activate

the better way - look your own settings

movcale commented 1 year ago

Just for info: sonoff-basic-r2 config with HW-0519 and modbus_controller

logger:
  baud_rate: 0 #the same serial port for logging and the UART component
uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600
  parity: NONE
  stop_bits: 1
modbus:
  id: modbus1
modbus_controller:
  - id: st
    ## the Modbus device addr
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 15s
sensor:
  - platform: modbus_controller
    name: "A phase voltage"
    address: 0x0000
    register_count: 2
    unit_of_measurement: "V"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: voltage
  - platform: modbus_controller
    name: "B phase voltage"
    address: 0x0002
    register_count: 2
    unit_of_measurement: "V"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: voltage
  - platform: modbus_controller
    name: "C phase voltage"
    address: 0x0004
    register_count: 2
    unit_of_measurement: "V"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: voltage
  - platform: modbus_controller
    name: "A line current"
    address: 0x0008
    register_count: 2
    unit_of_measurement: "A"
    register_type: read
    value_type: FP32
    accuracy_decimals: 1
    device_class: Current
  - platform: modbus_controller
    name: "B line current"
    address: 0x000A
    register_count: 2
    unit_of_measurement: "A"
    register_type: read
    value_type: FP32
    accuracy_decimals: 1
    device_class: Current
  - platform: modbus_controller
    name: "C line current"
    address: 0x000C
    register_count: 2
    unit_of_measurement: "A"
    register_type: read
    value_type: FP32
    accuracy_decimals: 1
    device_class: Current
  - platform: modbus_controller
    name: "Total active power"
    address: 0x0010
    register_count: 2
    unit_of_measurement: "W"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "A phase active power"
    address: 0x0012
    register_count: 2
    unit_of_measurement: "W"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "B phase active power"
    address: 0x0014
    register_count: 2
    unit_of_measurement: "W"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "C phase active power"
    address: 0x0016
    register_count: 2
    unit_of_measurement: "W"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "Total reactive power"
    address: 0x0018
    register_count: 2
    unit_of_measurement: "W"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "A phase reactive power"
    address: 0x001A
    register_count: 2
    unit_of_measurement: "var"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Reactive power
  - platform: modbus_controller
    name: "B phase reactive power"
    address: 0x001C
    register_count: 2
    unit_of_measurement: "var"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Reactive power
  - platform: modbus_controller
    name: "C phase reactive power"
    address: 0x001E
    register_count: 2
    unit_of_measurement: "var"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Reactive power
  - platform: modbus_controller
    name: "A phase power factor"
    address: 0x002A
    register_count: 2
    unit_of_measurement: "None"
    register_type: read
    value_type: FP32
    accuracy_decimals: 2
    device_class: Power Factor
  - platform: modbus_controller
    name: "B phase power factor"
    address: 0x002C
    register_count: 2
    unit_of_measurement: "None"
    register_type: read
    value_type: FP32
    accuracy_decimals: 2
    device_class: Power Factor
  - platform: modbus_controller
    name: "C phase power factor"
    address: 0x002E
    register_count: 2
    unit_of_measurement: "None"
    register_type: read
    value_type: FP32
    accuracy_decimals: 2
    device_class: Power Factor
  - platform: modbus_controller
    name: "Frequency"
    address: 0x0036
    register_count: 2
    unit_of_measurement: "Hz"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: frequency
  - platform: modbus_controller
    name: "Total active electricity power "
    address: 0x0100
    register_count: 2
    unit_of_measurement: "kWh"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
  - platform: modbus_controller
    name: "Total reactive electricity power"
    address: 0x0400
    register_count: 2
    unit_of_measurement: "kWh"
    register_type: read
    value_type: FP32
    accuracy_decimals: 0
    device_class: Power
lemurss commented 1 year ago

thank you very much for ModBus way but i can't undersand - for what sonoff basic? ) oh... maybe it if using sonoff basic as ESP32 shield?

bepluy commented 1 year ago

Подскажите плиз - скомпилил прошивку с компонентом st_meter через ESPHOME дашборд из HA. Сенсоры появились, но есть проблема с отображением некоторых параметров именно через modbus. На самом счетчике показания правильные - и вольтаж и потребление. А вот скрин photo_2023-11-18_19-19-01

В настройках счетчика - пароль 0000, адрес 001. TTL как у вас на фотке - подключен идентично к Wemos D1 mini

В чем может быть проблема?

P.S. Причем самое интересное - прошился на Тасмоту (с заменой разбора sdm630 на dds6619) - все показывает правильно.. адреса вроде одинаковые. photo_2023-11-20_01-14-37