Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PZEM-004T With A6 on Serial
#1
Howdy!

Thanks for the A6 Board, im using the second one already and i enjoy it.
I encountered a problem, connected PZEM-004T to Serial on A6 (GPIO12, 13)

When i power the board, it doesnt boot. I plug out the PZEM-004T from A6, it boots. I plug pzem back in. It works normaly, and i receive all the needed data.
What is the problem i have on boot?

pastebin code:
https://pastebin.com/Rbujh2R1

code:
Code:
esphome:
name: kotela6
friendly_name: KotelA6
libraries:
- "Wire"
- "ArduinoJson"

 
esp32:
board: esp32dev
framework:
type: arduino
 
 
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
 
 
 
logger:
 
api:
encryption:
key:
 
captive_portal:
 
ota:
password: "
 
#########################
 
uart:
- id: ubus1
tx_pin: GPIO13
rx_pin: GPIO12
baud_rate: 9600
stop_bits: 1
 
 
 
 
 
i2c:
sda: GPIO4
scl: GPIO15 # Change SCL to GPIO22 to avoid issues with GPIO15
scan: true
 
 
 
##########################
pcf8574:
- id: 'pcf8574_hub_out_1' # for output channel 1-8
address: 0x24
- id: 'pcf8574_hub_in_1' # for input channel 9-16
address: 0x22
pcf8575: false
 
 
#####################
time:
- platform: ds1307
id: rtc_time
 
 
sensor:
 
#### PZEM-004T V3 ####
 
- platform: pzemac
address: 1
current:
name: "pMeter_current"
accuracy_decimals: 2
voltage:
name: "pMeter_voltage"
accuracy_decimals: 2
power:
name: "pMeter_power"
unit_of_measurement: W
accuracy_decimals: 2
id: pMeter_power
frequency:
name: "pMeter_frequency"
unit_of_measurement: Hz
accuracy_decimals: 2
power_factor:
name: "pMeter_power_factor"
accuracy_decimals: 2
id: pMeter_power_factor
energy:
name: "pMeter_energy"
unit_of_measurement: Wh
accuracy_decimals: 1
id: pMeter_energy
update_interval: 5s
 
 
- platform: template
name: "pMeter_cumulative power"
unit_of_measurement: "kWh"
accuracy_decimals: 1
update_interval: 5s
icon: mdi:power
lambda: return (( (id(pMeter_energy).state)/1000.0));
 
- platform: total_daily_energy
name: "pMeter_of_day"
power_id: pMeter_power
unit_of_measurement: "kWh"
accuracy_decimals: 2
id: pMeter_power_of_day
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
icon: mdi:counter
 
- platform: template
name: "pMeter_veille"
id: template_pMeter_veille
unit_of_measurement: "kwh"
accuracy_decimals: 2
icon: mdi:power
update_interval: 10s
 
- platform: template
name: "pMeter_power_apparente"
id: pMeter_power_apparente
unit_of_measurement: "VA"
accuracy_decimals: 2
update_interval: 10s
icon: mdi:power
lambda: return ( (id(pMeter_power).state/id(pMeter_power_factor).state));
 
- platform: template
name: "pMeter_power_reactive"
id: pMeter_power_reactive
unit_of_measurement: "VAr"
accuracy_decimals: 2
update_interval: 10s
icon: mdi:power
lambda: return ( ( sqrt( (id(pMeter_power_apparente).state)*(id(pMeter_power_apparente).state) - (id(pMeter_power).state)*(id(pMeter_power).state) ) ) );
 
- platform: wifi_signal
name: "WiFi power_pMeter"
update_interval: 10s
 
- platform: uptime
name: "up"
id: uptime_sec
 
 
 
 
 
 
 
text_sensor:
- platform: template
name: pMeter_uptime
lambda: |-
int seconds = (id(uptime_sec).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
icon: mdi:clock-start
update_interval: 113s
 
################################################# SENSOR
binary_sensor:
 
 
- platform: status
name: "pMeter_status"
- platform: gpio
name: "flood_elling"
icon: mdi:home-flood
pin:
pcf8574: pcf8574_hub_in_1
number: 0
mode: INPUT
inverted: true
 
- platform: gpio
name: "flood_pool"
icon: mdi:home-flood
pin:
pcf8574: pcf8574_hub_in_1
number: 1
mode: INPUT
inverted: true
- platform: gpio
name: "flood_pump"
icon: mdi:home-flood
pin:
pcf8574: pcf8574_hub_in_1
number: 2
mode: INPUT
inverted: true
- platform: gpio
name: "KC868-A6-IN-4"
pin:
pcf8574: pcf8574_hub_in_1
number: 3
mode: INPUT
inverted: true
- platform: gpio
name: "KC868-A6-IN-5"
pin:
pcf8574: pcf8574_hub_in_1
number: 4
mode: INPUT
inverted: true
- platform: gpio
name: "KC868-A6-IN-6"
pin:
pcf8574: pcf8574_hub_in_1
number: 5
mode: INPUT
inverted: true
 
 
################################################# RELAYS
switch:
 
- platform: restart
name: "pMeter_restart"
 
### KINCONY 1
- platform: gpio
name: "Boiler ten"
id: relay_1
icon: mdi:fan
pin:
pcf8574: pcf8574_hub_out_1
number: 0
mode: OUTPUT
inverted: true
 
 
- platform: gpio
name: "free"
id: relay_2
pin:
pcf8574: pcf8574_hub_out_1
number: 1
mode: OUTPUT
inverted: true
 
########################### ######### BOILER PUMP
- platform: gpio
name: "Boiler Pump"
icon: mdi:pump
id: relay_3
pin:
pcf8574: pcf8574_hub_out_1
number: 2
mode: OUTPUT
inverted: true
 
 
################################## #RECIRCULATE
 
 
- platform: gpio
name: "Recirculate Pump"
icon: mdi:pump
id: relay_4
pin:
pcf8574: pcf8574_hub_out_1
number: 3
mode: OUTPUT
inverted: true
 
######################## INTERLOCK WATER STOP ###########################
- platform: gpio
name: "HouseWater OFF"
icon: mdi:water-off-outline
 
id: relay_5
pin:
pcf8574: pcf8574_hub_out_1
number: 4
mode: OUTPUT
inverted: true
interlock: [relay_6] # Interlock with Grow Pump_6
 
- platform: gpio
name: "HouseWater ON"
icon: mdi:water
id: relay_6
pin:
pcf8574: pcf8574_hub_out_1
number: 5
mode: OUTPUT
inverted: true
interlock: [relay_5]
restore_mode: ALWAYS_ON
 


Attached Files Image(s)
   
Reply
#2
Lol, just came here to ask the same question. I'm trying to add a second RS485 module using GPIO12 and GPIO13.

Also doesn't boot and I get the following serial output:


Code:
rst:0x10 (RTCWDT_RTC_RESET),boot:0x37 (SPI_FAST_FLASH_BOOT)
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
invalid header: 0xffffffff
Reply
#3

I made a workaround hack, it is dumb but it works.
Used one of the relays in NO to break GPIO12. and on boot made a sequence so that it switches on (GPIO12 starts working after board has booted)
It ate one of the relay on board, i will wait for the admin for any advice


  on_boot:
    priority: 600  # Boot priority, ensure it happens after most components have started
    then:
      - delay: 10s
      - switch.turn_on: relay_3
Reply
#4
GPIO12 use for ESP32 start.
KC868-A6 have two GREEN terminal free GPIO (label: GPIO-1, GPIO-2) they are GPIO32,GPIO33. So you can use these pins for your serial port device.
here is schematic for KC868-A6: https://www.kincony.com/download/KC868-A6-schematic.pdf
Reply
#5
(09-03-2024, 06:13 AM)admin Wrote: GPIO12 use for ESP32 start.
KC868-A6 have two GREEN terminal free GPIO (label: GPIO-1, GPIO-2) they are GPIO32,GPIO33.  So you can use these pins for your serial port device.
here is schematic for KC868-A6: https://www.kincony.com/download/KC868-A6-schematic.pdf

Do you mean  TEM./HUMI./1# and  TEM./HUMI./2# terminals can be used for serial?
Reply
#6
(09-02-2024, 06:31 PM)Techno Wrote:
I made a workaround hack, it is dumb but it works.
Used one of the relays in NO to break GPIO12. and on boot made a sequence so that it switches on (GPIO12 starts working after board has booted)
It ate one of the relay on board, i will wait for the admin for any advice


  on_boot:
    priority: 600  # Boot priority, ensure it happens after most components have started
    then:
      - delay: 10s
      - switch.turn_on: relay_3

I like that, unfortunately all my relays are used.

I think I have no choice but to use a UART to I2C bridge. see https://esphome.io/components/weikai.html
Reply
#7
(09-03-2024, 06:13 AM)admin Wrote: GPIO12 use for ESP32 start.
KC868-A6 have two GREEN terminal free GPIO (label: GPIO-1, GPIO-2) they are GPIO32,GPIO33.  So you can use these pins for your serial port device.
here is schematic for KC868-A6: https://www.kincony.com/download/KC868-A6-schematic.pdf

you mean these?


Attached Files Image(s)
   
Reply
#8
yes, you are right. TEM./HUMI./1# and TEM./HUMI./2
Reply
#9
(09-03-2024, 11:47 PM)admin Wrote: yes, you are right. TEM./HUMI./1# and  TEM./HUMI./2

I got in to question
Right now i have ports:
  • Temp1 for temp sensors (Pin Temp1)
  • Temp2 for Pzem (PIN 13 and Pin Temp2)

all is working great.
I want to hook CO2 sensor that is UART, please advise what port can i use for that?
Reply
#10
if your CO2 sensor is serial signal by TTL level. you can use a RS232->TTL converor module. so that you can use RS232 port.
Reply


Forum Jump:


Users browsing this thread: