Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,785
» Latest member: rozyjuise
» Forum threads: 3,846
» Forum posts: 19,668

Full Statistics

Online Users
There are currently 161 online users.
» 0 Member(s) | 145 Guest(s)
AhrefsBot, Amazonbot, Applebot, Bytespider, Google, PetalBot, bot

Latest Threads
AS-ESP32-S3 won't initial...
Forum: Getting Started with ESPHome and Home Assistant
Last Post: scottq
2 minutes ago
» Replies: 2
» Views: 18
A24 configure yaml for ES...
Forum: KinCony A24
Last Post: kiloptero
9 minutes ago
» Replies: 20
» Views: 6,604
Kincony KC868-A16 (ESP32)...
Forum: KC868-A16
Last Post: admin
1 hour ago
» Replies: 3
» Views: 20
Advice for DIY underfloor...
Forum: DIY Project
Last Post: admin
1 hour ago
» Replies: 3
» Views: 20
SHT30 temp/humidity i2c s...
Forum: B8
Last Post: admin
4 hours ago
» Replies: 1
» Views: 5
E16V3 - Dimensions compat...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
4 hours ago
» Replies: 3
» Views: 12
ESP32 Smart Controller – ...
Forum: Schematic & diagram & Dimensions of KinCony PCB layout CAD file
Last Post: admin
4 hours ago
» Replies: 3
» Views: 10
E16v3 - CE
Forum: Suggestions and feedback on KinCony's products
Last Post: ldebacker
5 hours ago
» Replies: 6
» Views: 213
E16V3 - Cover electrical ...
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
6 hours ago
» Replies: 1
» Views: 8
Github ... finally?
Forum: Suggestions and feedback on KinCony's products
Last Post: admin
6 hours ago
» Replies: 1
» Views: 9

  [Arduino source code for M30]-02 read all energy meter data
Posted by: admin - 01-05-2024, 11:25 AM - Forum: KC868-M16 / M1 / MB / M30 - No Replies

Code:
#include <ModbusMaster.h>
#include <arduino.h>
#include "HardwareSerial.h"
ModbusMaster node;
HardwareSerial my485Serial(2);

#define CHANNEL     0

String temp="";
void read_485(){
  while(my485Serial.available()>0)
  {
    temp = my485Serial.readString();   //read one data then delete it from buffer
     Serial.println(temp);
     //delay(100);
  }
  temp="";
}

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);
  my485Serial.begin(115200,SERIAL_8N1,32,33);///rx:32  tx:33
  while(my485Serial.read()>0){}
  node.begin(1,my485Serial);
 
}

void loop() {
  // put your main code here, to run repeatedly:
  //first chip BL0910 address:100  second chip BL0910 address:200  third chip BL0910 address:300  every address have 35 bytes data
  if(0 == node.readHoldingRegisters(100,35))
  {
      Serial.print("register value: ");
      for(int i=0;i<35;i++)
      {
        Serial.print(node.getResponseBuffer(i));
        Serial.print(" ");
      }
  }
  Serial.println(" ");
  Serial.println("next circle!");
  delay(500);
}

Print this item

  [Arduino source code for M30]-01 debug 4G module AT command
Posted by: admin - 01-05-2024, 11:23 AM - Forum: KC868-M16 / M1 / MB / M30 - No Replies

   

Code:
void setup() {
  Serial.begin(115200);
  Serial2.begin(115200);
}

void loop() {
  while (Serial.available()) {
    //  delay(1);
      Serial2.write(Serial.read());
  }
  while (Serial2.available()) {
       Serial.write(Serial2.read());
  }
}

[Image: attachment.php?aid=1056]

Print this item

  M30 RS485 and Serial port development guide
Posted by: admin - 01-05-2024, 11:20 AM - Forum: KC868-M16 / M1 / MB / M30 - Replies (12)

M30 have one ARM cpu on board. the ARM CPU have one RS485 modbus interface for user. another ARM CPU's serial port connect to ESP32's GPIO.

RS485 communication settings: 38400bps,8,N,1
ESP32 serial port communication settings: 115200bps,8,N,1

they have some modbus protocol, just use by different baud rate.

first  BL0910 chip read CT 1-10 channel current.  modbus address is 100.
second BL0910 chip read CT 11-20 channel current. modbus address is 200.
third  BL0910 chip read CT 21-30 channel current. modbus address is 300.

every BL0910 have 35 bytes data, here are data structure:
   
this use by modbus pull tool:
   

Print this item

  M30 configure yaml for ESPhome
Posted by: admin - 01-05-2024, 11:11 AM - Forum: KC868-M16 / M1 / MB / M30 - Replies (81)

   
   
yaml download: 
.txt   M30_HA_LEDs.txt (Size: 49.87 KB / Downloads: 785)
modbus pull screen setting:    

substitutions:
  max_current_range1: "10"
  max_current_range2: "10"
  max_current_range3: "10"
  max_current_range4: "10"
  max_current_range5: "10"
  max_current_range6: "10"
  max_current_range7: "10"
  max_current_range8: "10"
  max_current_range9: "10"
  max_current_range10: "10"
  max_current_range11: "10"
  max_current_range12: "10"
  max_current_range13: "10"
  max_current_range14: "10"
  max_current_range15: "10"
  max_current_range16: "10"
  max_current_range17: "10"
  max_current_range18: "10"
  max_current_range19: "10"
  max_current_range20: "10"
  max_current_range21: "10"
  max_current_range22: "10"
  max_current_range23: "10"
  max_current_range24: "10"
  max_current_range25: "10"
  max_current_range26: "10"
  max_current_range27: "10"
  max_current_range28: "10"
  max_current_range29: "10"
  max_current_range30: "10"

esphome:
  name: m30
  friendly_name: m30

esp32:
  board: esp32dev
  framework:
    type: arduino


# Enable logging
logger:
  # baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "8G0kVEA0/DqgAavgKNyy9EYUrWo6pEZM38JVMAryJv8="

ota:
  password: "2a26484203d80a83798414c879541760"

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0

uart:
  id: modbus_uart
  rx_pin: 32
  tx_pin: 33
  baud_rate: 115200
  stop_bits: 1
  data_bits: 8
  parity: NONE
 

modbus:
  id: modbus_hub
  uart_id: modbus_uart
 

modbus_controller:
  - id: modbus_hub_m30
    address: 1
    modbus_id: modbus_hub
    update_interval: 5s

sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 100
    register_type: holding
    name: m30_1_current_1
    id: m30_1_current_1
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_1).state;
              float red = (current - 0.0) / ${max_current_range1};
              float green = (${max_current_range1} - current) / ${max_current_range1};
              float blue = 0.0;
             
              auto call = id(M30_LED1).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 101
    register_type: holding
    name: m30_1_current_2
    id: m30_1_current_2
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_2).state;
              float red = (current - 0.0) / ${max_current_range2};
              float green = (${max_current_range2} - current) / ${max_current_range2};
              float blue = 0.0;
             
              auto call = id(M30_LED2).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();   
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 102
    register_type: holding
    name: m30_1_current_3
    id: m30_1_current_3
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_3).state;
              float red = (current - 0.0) / ${max_current_range3};
              float green = (${max_current_range3} - current) / ${max_current_range3};
              float blue = 0.0;
             
              auto call = id(M30_LED3).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 103
    register_type: holding
    name: m30_1_current_4
    id: m30_1_current_4
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_4).state;
              float red = (current - 0.0) / ${max_current_range4};
              float green = (${max_current_range4} - current) / ${max_current_range4};
              float blue = 0.0;
             
              auto call = id(M30_LED4).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 104
    register_type: holding
    name: m30_1_current_5
    id: m30_1_current_5
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_5).state;
              float red = (current - 0.0) / ${max_current_range5};
              float green = (${max_current_range5} - current) / ${max_current_range5};
              float blue = 0.0;
             
              auto call = id(M30_LED5).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 105
    register_type: holding
    name: m30_1_current_6
    id: m30_1_current_6
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_6).state;
              float red = (current - 0.0) / ${max_current_range6};
              float green = (${max_current_range6} - current) / ${max_current_range6};
              float blue = 0.0;
             
              auto call = id(M30_LED6).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 106
    register_type: holding
    name: m30_1_current_7
    id: m30_1_current_7
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_7).state;
              float red = (current - 0.0) / ${max_current_range7};
              float green = (${max_current_range7} - current) / ${max_current_range7};
              float blue = 0.0;
             
              auto call = id(M30_LED7).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 107
    register_type: holding
    name: m30_1_current_8
    id: m30_1_current_8
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_8).state;
              float red = (current - 0.0) / ${max_current_range8};
              float green = (${max_current_range8} - current) / ${max_current_range8};
              float blue = 0.0;
             
              auto call = id(M30_LED8).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 108
    register_type: holding
    name: m30_1_current_9
    id: m30_1_current_9
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_9).state;
              float red = (current - 0.0) / ${max_current_range9};
              float green = (${max_current_range9} - current) / ${max_current_range9};
              float blue = 0.0;
             
              auto call = id(M30_LED9).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 109
    register_type: holding
    name: m30_1_current_10
    id: m30_1_current_10
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_1_current_10).state;
              float red = (current - 0.0) / ${max_current_range10};
              float green = (${max_current_range10} - current) / ${max_current_range10};
              float blue = 0.0;
             
              auto call = id(M30_LED10).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 110
    register_type: holding
    name: m30_1_voltage
    id: m30_1_voltage
    unit_of_measurement: V
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 111
    register_type: holding
    name: m30_1_watt_1
    id: m30_1_watt_1
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 112
    register_type: holding
    name: m30_1_watt_2
    id: m30_1_watt_2
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 113
    register_type: holding
    name: m30_1_watt_3
    id: m30_1_watt_3
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 114
    register_type: holding
    name: m30_1_watt_4
    id: m30_1_watt_4
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 115
    register_type: holding
    name: m30_1_watt_5
    id: m30_1_watt_5
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 116
    register_type: holding
    name: m30_1_watt_6
    id: m30_1_watt_6
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 117
    register_type: holding
    name: m30_1_watt_7
    id: m30_1_watt_7
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 118
    register_type: holding
    name: m30_1_watt_8
    id: m30_1_watt_8
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 119
    register_type: holding
    name: m30_1_watt_9
    id: m30_1_watt_9
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 120
    register_type: holding
    name: m30_1_watt_10
    id: m30_1_watt_10
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 121
    register_type: holding
    name: m30_1_energy_1
    id: m30_1_energy_1
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 122
    register_type: holding
    name: m30_1_energy_2
    id: m30_1_energy_2
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 123
    register_type: holding
    name: m30_1_energy_3
    id: m30_1_energy_3
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 124
    register_type: holding
    name: m30_1_energy_4
    id: m30_1_energy_4
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 125
    register_type: holding
    name: m30_1_energy_5
    id: m30_1_energy_5
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 126
    register_type: holding
    name: m30_1_energy_6
    id: m30_1_energy_6
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 127
    register_type: holding
    name: m30_1_energy_7
    id: m30_1_energy_7
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 128
    register_type: holding
    name: m30_1_energy_8
    id: m30_1_energy_8
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 129
    register_type: holding
    name: m30_1_energy_9
    id: m30_1_energy_9
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 130
    register_type: holding
    name: m30_1_energy_10
    id: m30_1_energy_10
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 131
    register_type: holding
    name: m30_1_energy_sum
    id: m30_1_energy_sum
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 132
    register_type: holding
    name: m30_1_period
    id: m30_1_period
    unit_of_measurement: Hz
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 133
    register_type: holding
    name: m30_1_tps_1
    id: m30_1_tps_1
    unit_of_measurement: °C
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  # - platform: modbus_controller
  #  modbus_controller_id: modbus_hub_m30
  #  address: 134
  #  register_type: holding
  #  name: m30_1_tps_2
  #  id: m30_1_tps_2
  #  unit_of_measurement: °C
  #  accuracy_decimals: 1
  #  value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 200
    register_type: holding
    name: m30_2_current_1
    id: m30_2_current_1
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_1).state;
              float red = (current - 0.0) / ${max_current_range11};
              float green = (${max_current_range11} - current) / ${max_current_range11};
              float blue = 0.0;
             
              auto call = id(M30_LED11).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 201
    register_type: holding
    name: m30_2_current_2
    id: m30_2_current_2
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_2).state;
              float red = (current - 0.0) / ${max_current_range12};
              float green = (${max_current_range12} - current) / ${max_current_range12};
              float blue = 0.0;
             
              auto call = id(M30_LED12).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 202
    register_type: holding
    name: m30_2_current_3
    id: m30_2_current_3
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_3).state;
              float red = (current - 0.0) / ${max_current_range13};
              float green = (${max_current_range13} - current) / ${max_current_range13};
              float blue = 0.0;
             
              auto call = id(M30_LED13).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 203
    register_type: holding
    name: m30_2_current_4
    id: m30_2_current_4
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_4).state;
              float red = (current - 0.0) / ${max_current_range14};
              float green = (${max_current_range14} - current) / ${max_current_range14};
              float blue = 0.0;
             
              auto call = id(M30_LED14).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 204
    register_type: holding
    name: m30_2_current_5
    id: m30_2_current_5
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_5).state;
              float red = (current - 0.0) / ${max_current_range15};
              float green = (${max_current_range15} - current) / ${max_current_range15};
              float blue = 0.0;
             
              auto call = id(M30_LED15).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 205
    register_type: holding
    name: m30_2_current_6
    id: m30_2_current_6
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_6).state;
              float red = (current - 0.0) / ${max_current_range16};
              float green = (${max_current_range16} - current) / ${max_current_range16};
              float blue = 0.0;
             
              auto call = id(M30_LED16).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 206
    register_type: holding
    name: m30_2_current_7
    id: m30_2_current_7
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_7).state;
              float red = (current - 0.0) / ${max_current_range17};
              float green = (${max_current_range17} - current) / ${max_current_range17};
              float blue = 0.0;
             
              auto call = id(M30_LED17).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 207
    register_type: holding
    name: m30_2_current_8
    id: m30_2_current_8
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_8).state;
              float red = (current - 0.0) / ${max_current_range18};
              float green = (${max_current_range18} - current) / ${max_current_range18};
              float blue = 0.0;
             
              auto call = id(M30_LED18).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 208
    register_type: holding
    name: m30_2_current_9
    id: m30_2_current_9
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_9).state;
              float red = (current - 0.0) / ${max_current_range19};
              float green = (${max_current_range19} - current) / ${max_current_range19};
              float blue = 0.0;
             
              auto call = id(M30_LED19).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 209
    register_type: holding
    name: m30_2_current_10
    id: m30_2_current_10
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_2_current_10).state;
              float red = (current - 0.0) / ${max_current_range20};
              float green = (${max_current_range20} - current) / ${max_current_range20};
              float blue = 0.0;
             
              auto call = id(M30_LED20).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 210
    register_type: holding
    name: m30_2_voltage
    id: m30_2_voltage
    unit_of_measurement: V
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 211
    register_type: holding
    name: m30_2_watt_1
    id: m30_2_watt_1
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 212
    register_type: holding
    name: m30_2_watt_2
    id: m30_2_watt_2
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 213
    register_type: holding
    name: m30_2_watt_3
    id: m30_2_watt_3
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 214
    register_type: holding
    name: m30_2_watt_4
    id: m30_2_watt_4
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 215
    register_type: holding
    name: m30_2_watt_5
    id: m30_2_watt_5
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 216
    register_type: holding
    name: m30_2_watt_6
    id: m30_2_watt_6
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 217
    register_type: holding
    name: m30_2_watt_7
    id: m30_2_watt_7
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 218
    register_type: holding
    name: m30_2_watt_8
    id: m30_2_watt_8
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 219
    register_type: holding
    name: m30_2_watt_9
    id: m30_2_watt_9
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 220
    register_type: holding
    name: m30_2_watt_10
    id: m30_2_watt_10
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 221
    register_type: holding
    name: m30_2_energy_1
    id: m30_2_energy_1
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 222
    register_type: holding
    name: m30_2_energy_2
    id: m30_2_energy_2
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 223
    register_type: holding
    name: m30_2_energy_3
    id: m30_2_energy_3
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 224
    register_type: holding
    name: m30_2_energy_4
    id: m30_2_energy_4
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 225
    register_type: holding
    name: m30_2_energy_5
    id: m30_2_energy_5
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 226
    register_type: holding
    name: m30_2_energy_6
    id: m30_2_energy_6
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 227
    register_type: holding
    name: m30_2_energy_7
    id: m30_2_energy_7
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 228
    register_type: holding
    name: m30_2_energy_8
    id: m30_2_energy_8
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 229
    register_type: holding
    name: m30_2_energy_9
    id: m30_2_energy_9
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 230
    register_type: holding
    name: m30_2_energy_10
    id: m30_2_energy_10
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 231
    register_type: holding
    name: m30_2_energy_sum
    id: m30_2_energy_sum
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 232
    register_type: holding
    name: m30_2_period
    id: m30_2_period
    unit_of_measurement: Hz
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 233
    register_type: holding
    name: m30_2_tps_1
    id: m30_2_tps_1
    unit_of_measurement: °C
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  # - platform: modbus_controller
  #  modbus_controller_id: modbus_hub_m30
  #  address: 234
  #  register_type: holding
  #  name: m30_2_tps_2
  #  id: m30_2_tps_2
  #  unit_of_measurement: °C
  #  accuracy_decimals: 1
  #  value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 300
    register_type: holding
    name: m30_3_current_1
    id: m30_3_current_1
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_1).state;
              float red = (current - 0.0) / ${max_current_range21};
              float green = (${max_current_range21} - current) / ${max_current_range21};
              float blue = 0.0;
             
              auto call = id(M30_LED21).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 301
    register_type: holding
    name: m30_3_current_2
    id: m30_3_current_2
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_2).state;
              float red = (current - 0.0) / ${max_current_range22};
              float green = (${max_current_range22} - current) / ${max_current_range22};
              float blue = 0.0;
             
              auto call = id(M30_LED22).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 302
    register_type: holding
    name: m30_3_current_3
    id: m30_3_current_3
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_3).state;
              float red = (current - 0.0) / ${max_current_range23};
              float green = (${max_current_range23} - current) / ${max_current_range23};
              float blue = 0.0;
             
              auto call = id(M30_LED23).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 303
    register_type: holding
    name: m30_3_current_4
    id: m30_3_current_4
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_4).state;
              float red = (current - 0.0) / ${max_current_range24};
              float green = (${max_current_range24} - current) / ${max_current_range24};
              float blue = 0.0;
             
              auto call = id(M30_LED24).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 304
    register_type: holding
    name: m30_3_current_5
    id: m30_3_current_5
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_5).state;
              float red = (current - 0.0) / ${max_current_range25};
              float green = (${max_current_range25} - current) / ${max_current_range25};
              float blue = 0.0;
             
              auto call = id(M30_LED25).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 305
    register_type: holding
    name: m30_3_current_6
    id: m30_3_current_6
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_6).state;
              float red = (current - 0.0) / ${max_current_range26};
              float green = (${max_current_range26} - current) / ${max_current_range26};
              float blue = 0.0;
             
              auto call = id(M30_LED26).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 306
    register_type: holding
    name: m30_3_current_7
    id: m30_3_current_7
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_7).state;
              float red = (current - 0.0) / ${max_current_range27};
              float green = (${max_current_range27} - current) / ${max_current_range27};
              float blue = 0.0;
             
              auto call = id(M30_LED27).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 307
    register_type: holding
    name: m30_3_current_8
    id: m30_3_current_8
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_8).state;
              float red = (current - 0.0) / ${max_current_range28};
              float green = (${max_current_range28} - current) / ${max_current_range28};
              float blue = 0.0;
             
              auto call = id(M30_LED28).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 308
    register_type: holding
    name: m30_3_current_9
    id: m30_3_current_9
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_9).state;
              float red = (current - 0.0) / ${max_current_range29};
              float green = (${max_current_range29} - current) / ${max_current_range29};
              float blue = 0.0;
             
              auto call = id(M30_LED29).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 309
    register_type: holding
    name: m30_3_current_10
    id: m30_3_current_10
    unit_of_measurement: A
    accuracy_decimals: 3
    value_type: U_WORD
    filters:
      - multiply: 0.00098
    on_value:
      - then:
          - lambda: |-
              float current = id(m30_3_current_10).state;
              float red = (current - 0.0) / ${max_current_range30};
              float green = (${max_current_range30} - current) / ${max_current_range30};
              float blue = 0.0;
             
              auto call = id(M30_LED30).turn_on();
              call.set_brightness(0.6);
              call.set_rgb(red, green, blue);
              call.set_color_mode(ColorMode::RGB);
              call.perform();
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 310
    register_type: holding
    name: m30_3_voltage
    id: m30_3_voltage
    unit_of_measurement: V
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 311
    register_type: holding
    name: m30_3_watt_1
    id: m30_3_watt_1
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 312
    register_type: holding
    name: m30_3_watt_2
    id: m30_3_watt_2
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 313
    register_type: holding
    name: m30_3_watt_3
    id: m30_3_watt_3
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 314
    register_type: holding
    name: m30_3_watt_4
    id: m30_3_watt_4
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 315
    register_type: holding
    name: m30_3_watt_5
    id: m30_3_watt_5
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 316
    register_type: holding
    name: m30_3_watt_6
    id: m30_3_watt_6
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 317
    register_type: holding
    name: m30_3_watt_7
    id: m30_3_watt_7
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 318
    register_type: holding
    name: m30_3_watt_8
    id: m30_3_watt_8
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 319
    register_type: holding
    name: m30_3_watt_9
    id: m30_3_watt_9
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 320
    register_type: holding
    name: m30_3_watt_10
    id: m30_3_watt_10
    unit_of_measurement: W
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 321
    register_type: holding
    name: m30_3_energy_1
    id: m30_3_energy_1
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 322
    register_type: holding
    name: m30_3_energy_2
    id: m30_3_energy_2
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 323
    register_type: holding
    name: m30_3_energy_3
    id: m30_3_energy_3
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 324
    register_type: holding
    name: m30_3_energy_4
    id: m30_3_energy_4
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 325
    register_type: holding
    name: m30_3_energy_5
    id: m30_3_energy_5
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 326
    register_type: holding
    name: m30_3_energy_6
    id: m30_3_energy_6
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 327
    register_type: holding
    name: m30_3_energy_7
    id: m30_3_energy_7
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 328
    register_type: holding
    name: m30_3_energy_8
    id: m30_3_energy_8
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 329
    register_type: holding
    name: m30_3_energy_9
    id: m30_3_energy_9
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 330
    register_type: holding
    name: m30_3_energy_10
    id: m30_3_energy_10
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 331
    register_type: holding
    name: m30_3_energy_sum
    id: m30_3_energy_sum
    unit_of_measurement: kWh
    accuracy_decimals: 1
    value_type: U_WORD
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 332
    register_type: holding
    name: m30_3_period
    id: m30_3_period
    unit_of_measurement: Hz
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.01
  - platform: modbus_controller
    modbus_controller_id: modbus_hub_m30
    address: 333
    register_type: holding
    name: m30_3_tps_1
    id: m30_3_tps_1
    unit_of_measurement: °C
    accuracy_decimals: 1
    value_type: U_WORD
    filters:
      - multiply: 0.1
  # - platform: modbus_controller
  #  modbus_controller_id: modbus_hub_m30
  #  address: 334
  #  register_type: holding
  #  name: m30_3_tps_2
  #  id: m30_3_tps_2
  #  unit_of_measurement: °C
  #  accuracy_decimals: 1
  #  value_type: U_WORD


light:
  - platform: partition
    name: "M30_LED1"
    id: M30_LED1
    segments:
      - id: light1
        from: 14
        to: 14


  - platform: partition
    name: "M30_LED2"
    id: M30_LED2
    segments:
      - id: light1
        from: 13
        to: 13

  - platform: partition
    name: "M30_LED3"
    id: M30_LED3
    segments:
      - id: light1
        from: 12
        to: 12

  - platform: partition
    name: "M30_LED4"
    id: M30_LED4
    segments:
      - id: light1
        from: 11
        to: 11

  - platform: partition
    name: "M30_LED5"
    id: M30_LED5
    segments:
      - id: light1
        from: 10
        to: 10

  - platform: partition
    name: "M30_LED6"
    id: M30_LED6
    segments:
      - id: light1
        from: 9
        to: 9

  - platform: partition
    name: "M30_LED7"
    id: M30_LED7
    segments:
      - id: light1
        from: 8
        to: 8

  - platform: partition
    name: "M30_LED8"
    id: M30_LED8
    segments:
      - id: light1
        from: 7
        to: 7

  - platform: partition
    name: "M30_LED9"
    id: M30_LED9
    segments:
      - id: light1
        from: 6
        to: 6

  - platform: partition
    name: "M30_LED10"
    id: M30_LED10
    segments:
      - id: light1
        from: 5
        to: 5

  - platform: partition
    name: "M30_LED11"
    id: M30_LED11
    segments:
      - id: light1
        from: 4
        to: 4

  - platform: partition
    name: "M30_LED12"
    id: M30_LED12
    segments:
      - id: light1
        from: 3
        to: 3

  - platform: partition
    name: "M30_LED13"
    id: M30_LED13
    segments:
      - id: light1
        from: 2
        to: 2

  - platform: partition
    name: "M30_LED14"
    id: M30_LED14
    segments:
      - id: light1
        from: 1
        to: 1

  - platform: partition
    name: "M30_LED15"
    id: M30_LED15
    segments:
      - id: light1
        from: 0
        to: 0

  - platform: partition
    name: "M30_LED16"
    id: M30_LED16
    segments:
      - id: light1
        from: 15
        to: 15

  - platform: partition
    name: "M30_LED17"
    id: M30_LED17
    segments:
      - id: light1
        from: 16
        to: 16

  - platform: partition
    name: "M30_LED18"
    id: M30_LED18
    segments:
      - id: light1
        from: 17
        to: 17

  - platform: partition
    name: "M30_LED19"
    id: M30_LED19
    segments:
      - id: light1
        from: 18
        to: 18

  - platform: partition
    name: "M30_LED20"
    id: M30_LED20
    segments:
      - id: light1
        from: 19
        to: 19

  - platform: partition
    name: "M30_LED21"
    id: M30_LED21
    segments:
      - id: light1
        from: 20
        to: 20

  - platform: partition
    name: "M30_LED22"
    id: M30_LED22
    segments:
      - id: light1
        from: 21
        to: 21

  - platform: partition
    name: "M30_LED23"
    id: M30_LED23
    segments:
      - id: light1
        from: 22
        to: 22

  - platform: partition
    name: "M30_LED24"
    id: M30_LED24
    segments:
      - id: light1
        from: 23
        to: 23

  - platform: partition
    name: "M30_LED25"
    id: M30_LED25
    segments:
      - id: light1
        from: 24
        to: 24

  - platform: partition
    name: "M30_LED26"
    id: M30_LED26
    segments:
      - id: light1
        from: 25
        to: 25

  - platform: partition
    name: "M30_LED27"
    id: M30_LED27
    segments:
      - id: light1
        from: 26
        to: 26

  - platform: partition
    name: "M30_LED28"
    id: M30_LED28
    segments:
      - id: light1
        from: 27
        to: 27

  - platform: partition
    name: "M30_LED29"
    id: M30_LED29
    segments:
      - id: light1
        from: 28
        to: 28

  - platform: partition
    name: "M30_LED30"
    id: M30_LED30
    segments:
      - id: light1
        from: 29
        to: 29
       
  # Example for light segment source
  - platform: esp32_rmt_led_strip
    id: light1
    rgb_order: GRB
    pin: GPIO12
    num_leds: 30
    rmt_channel: 0
    chipset: ws2812

Print this item

  M30 ESP32 I/O pin define
Posted by: admin - 01-05-2024, 11:02 AM - Forum: KC868-M16 / M1 / MB / M30 - Replies (7)

Ethernet (LAN8720) I/O define:

ETH_ADDR        0
ETH_POWER_PIN  -1
ETH_MDC_PIN    23
ETH_MDIO_PIN  18
ETH_TYPE      ETH_PHY_LAN8720
ETH_CLK_MODE  ETH_CLOCK_GPIO17_OUT

IIC BUS:
SDA:5
SCL:16

SPI BUS:
SCK:14
MOSI:15
MISO:2

WS2812 RGBW LED:12

----------------------------------
ARM CPU TXD:32
ARM CPU RXD:33

4G:
RXD:13
TXD:4

Print this item

  how to enable Raspberry pi CM4 additional UART serial ports
Posted by: admin - 01-05-2024, 06:02 AM - Forum: KC868-Server Raspberry Pi4 local server - No Replies

edit config.txt file, add:

dtoverlay=uart2
dtoverlay=uart3
dtoverlay=uart4
dtoverlay=uart5

Note that the kernel will reject attempts to enable UARTs where the pins are in use by something else (e.g. UART0, UART1 or one of the I2C ports), or it might even disable the other thing, so make sure what you are trying to do is possible.

uart1 being enabled by default, pi 4 having 4 extra uarts.

Print this item

  Communicate between multiple ESP's with RS485 Modbus
Posted by: k0cka - 01-04-2024, 11:22 PM - Forum: Getting Started with ESPHome and Home Assistant - Replies (10)

Hello, I was searching on the internet but I could not find answers to my questions. So I would like to try my luck here and see if someone can help me.

I would like to ask if it’s possible to communicate between multiple ESP’s using modbus in ESPHome. So for example - I press a button on esp1 and turn on a relay on esp2.

I have some max485 modules to convert UART to RS485, but I just don’t understand how should the yaml files been written since I’m a total newbie in this field.

Thank you in advance!

Print this item

  Multiple DS18B20 Temperature sensor at the same GPIO pin
Posted by: tamibandy - 01-04-2024, 03:57 PM - Forum: DIY Project - Replies (1)

Hello,

On Kincony A8 controller, I made a code for reading multiple temperature sensor with one GPIO(14) pin (DS18B20 type). I made the reading on the second core of the ESP32's processor, to don't make any delay in the normal program cycle.
In the code is managed the multiple reading to can assign every DS18B20 temperature sensor to a fix variable by unique code of the DS18B20.

Here I will attach a short code about it. I didn't uploaded all of the code because there is a lot of other things in it too. Maybe if you want to use, need to do some other implementations too. But for a start it is perfect.

Code:
#include <DS18B20.h>
#include <Preferences.h>
DS18B20 ds(14);
struct DS18B20_tempSensor {
  uint8_t temperatureID;
  uint8_t address[8];
  float value;
};
DS18B20_tempSensor dsTemp[16];
struct Parameters {
  uint32_t  magic;
  byte temperatureAddress[16][8];
};
Parameters paramLocal;
const Parameters paramDefault = {
  0x626C6E6B
};
float temperature[16];
void setup() {
  loadParameters();
  xTaskCreatePinnedToCore(
      Task1code, /* Function to implement the task */
      "Task1", /* Name of the task */
      10000,  /* Stack size in words */
      NULL,  /* Task input parameter */
      0,  /* Priority of the task */
      &Task1,  /* Task handle. */
      0); /* Core where the task should run */
}
void loop() {
 
}
void Task1code( void * parameter) {
  for(;;) {
    while(ds.selectNext()) {
     
      uint8_t address[8];
      ds.getAddress(address);
      bool found = false;
      for(int i = 0; i < 16; i++) {
        if(memcmp(dsTemp[i].address, address, 8) == 0) {
          found = true;
          dsTemp[i].value = ds.getTempC();
          break;
        }
      }
      if(!found) {
        for(int i = 0; i < 16; i++) {
          bool empty = true;
          for(int j = 0; j < 8; j++) {
            if(dsTemp[i].address[j] != 0) {
              empty = false;
              break;
            }
          }
          if(empty) {
            ds.setResolution(12);
            bool match = false;
            for(int j = 0; j < 16; j++) {
              if(memcmp(paramLocal.temperatureAddress[j], address, 8) == 0) {
                match = true;
                dsTemp[i].temperatureID = j + 1;
                break;
              }
            }
            if(!match) {
              dsTemp[i].temperatureID = 99;
            }
            for(int j = 0; j < 8; j++) {
              dsTemp[i].address[j] = address[j];
            }
            dsTemp[i].value = ds.getTempC();
            break;
          }
        }
      }
    }
  }
}
bool loadParameters() {
  Preferences prefs;
  if (prefs.begin("esp32", true)) { // read-only
    memset(&paramLocal, 0, sizeof(paramLocal));
    prefs.getBytes("parameters", &paramLocal, sizeof(paramLocal));
    if (paramLocal.magic != paramDefault.magic) {
      Serial.print(F("Using default parameters."));
      paramLocal = paramDefault;
    }
    return true;
  } else {
    Serial.print(F("Parameters read failed"));
    return false;
  }
}

bool saveParameters() {
  Preferences prefs;
  if (prefs.begin("esp32", false)) { // writeable
    prefs.putBytes("parameters", &paramLocal, sizeof(paramLocal));
    Serial.print(F("Parameters stored to flash"));
    return true;
  } else {
    Serial.print(F("Parameters write failed"));
    return false;
  }
}

Print this item

Photo Module sim7670C cannot send messages, cannot call, nor receive messages or calls! Ple
Posted by: Tchip - 01-04-2024, 02:14 PM - Forum: Development - Replies (7)

Hi everybody! I'm new to the 7670C sim module and currently I still don't know how to configure it to receive, send messages and calls.
I sent AT commands to it and it responded OK. But when I send messages and calls, it cannot make or receive calls and messages. Look forward to the help. Thank you so much!

   
   
   

Print this item

  It is possible a hardware modification?
Posted by: tamibandy - 01-04-2024, 10:59 AM - Forum: KC868-A8 - Replies (1)

Is there possibility to do A8 custom board?

Board with nextion HMI connector 5VDC, GND, STX, RTX? Instead of 433 radio control.
Ethernet not needed if WiFi is available and those GPIO pins could be freed up.

Print this item