bremby
(bremby)
January 10, 2022, 7:23pm
1
Hi,
I’m using an ESP32 with GSM and GPS module, as far I understand I should define the UART to assign the RT/TX pin; how I can define UART for both?
# Example configuration entry
uart:
rx_pin: D7
baud_rate: 9600
GPS Component — ESPHome
uart:
baud_rate: 9600
tx_pin: TX
rx_pin: RX
Sim800L Component — ESPHome
I didn’t find and example that can help me to understand how to assign more than one RX
regards
nikito7
(nikito7)
January 10, 2022, 8:44pm
2
uart:
- id: uart_1
tx_pin: GPIO15
rx_pin: GPIO13
baud_rate: 9600
- id: uart_2
rx_pin: GPIO12
baud_rate: 9600
2 Likes
bremby
(bremby)
January 10, 2022, 8:51pm
3
Oh boy!!!
So easy?!?!
I have another question, if I setup
uart:
- id: uart_1
tx_pin: GPIO27
rx_pin: GPIO26
baud_rate: 9600
- id: uart_2
rx_pin: GPIO03
baud_rate: 9600
then I have to do something to connect the GPS and the GSM with the correct UART, right?
# Declare GPS module
gps:
latitude:
id: uart_1_latitude
name: "Latitude"
longitude:
id: uart_1_longitude
name: "Longitude"
altitude:
id: uart_1_altitude
name: "Altitude"
# GPS as time source
time:
- platform: gps
id: uart_1_time
bremby
(bremby)
January 11, 2022, 6:05pm
5
can you help me with the indentation or do you have a full example
this produce this error
ERROR Error while reading config: Invalid YAML syntax:
mapping values are not allowed here
in "/config/esphome/sim7600e.yaml", line 189, column 13:
latitude:
uart:
- id: uart_1
tx_pin: GPIO27
rx_pin: GPIO26
baud_rate: 9600
- id: uart_2
rx_pin: GPIO03
baud_rate: 9600
# Declare GPS module
gps:
id: uart_1
latitude:
name: "Latitude"
longitude:
name: "Longitude"
altitude:
name: "Altitude"
speed:
name: "Speed"
course:
name: "Course"
satellites:
name: "Satellites"
but i have to define the uart
nikito7
(nikito7)
January 11, 2022, 6:20pm
6
Maybe put gps uart as first. And dont use uart_id for gps
You need test if gps will get the right one
bremby
(bremby)
January 15, 2022, 9:11pm
7
Hi,
I managed to find the correct syntax
gps:
uart_id: uart_2
latitude:
now I’m trying to get the UART log using the info from Custom UART Text Sensor — ESPHome
but the sensor returns Unknown :(, I try to dig in a little bit
nikito7
(nikito7)
January 15, 2022, 9:38pm
8
Test with only gps uart first and then add uart2
Gps uart may need to be the first
I think that gps component dont support uart_id yet
bremby
(bremby)
January 15, 2022, 9:51pm
9
Thank you @nikito7 , I’m following your suggestion
uart:
- id: uart_2
rx_pin: GPIO03
baud_rate: 9600
debug:
direction: BOTH
dummy_receiver: false
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
- platform: custom
lambda: |-
auto my_custom_sensor = new UartReadLineSensor(id(uart_2));
App.register_component(my_custom_sensor);
return {my_custom_sensor};
text_sensors:
id: "uart_readline_2"
name: uart2log
gps:
latitude:
name: "Latitude"
longitude:
name: "Longitude"
altitude:
name: "Altitude"
speed:
name: "Speed"
course:
name: "Course"
satellites:
name: "Satellites"
but the status is still unknown and I don’t get GPS data
[22:44:49][C][uart.arduino_esp32:105]: UART Bus:
[22:44:49][C][uart.arduino_esp32:107]: RX Pin: GPIO3
[22:44:49][C][uart.arduino_esp32:109]: RX Buffer Size: 256
[22:44:49][C][uart.arduino_esp32:111]: Baud Rate: 9600 baud
[22:44:49][C][uart.arduino_esp32:112]: Data Bits: 8
[22:44:49][C][uart.arduino_esp32:113]: Parity: NONE
[22:44:49][C][uart.arduino_esp32:114]: Stop bits: 1
[22:45:05][D][sensor:113]: 'Latitude': Sending state -1.00000 ° with 6 decimals of accuracy
[22:45:05][D][sensor:113]: 'Longitude': Sending state -1.00000 ° with 6 decimals of accuracy
[22:45:05][D][sensor:113]: 'Speed': Sending state -1.00000 km/h with 6 decimals of accuracy
[22:45:05][D][sensor:113]: 'Course': Sending state -1.00000 ° with 2 decimals of accuracy
[22:45:05][D][sensor:113]: 'Altitude': Sending state -1.00000 m with 1 decimals of accuracy
[22:45:05][D][sensor:113]: 'Satellites': Sending state -1.00000 with 0 decimals of accuracy
nikito7
(nikito7)
January 15, 2022, 10:05pm
10
You need good gps signal inside home
bremby
(bremby)
January 16, 2022, 5:50pm
11
Hi,
I think that I’m doing something wrong. I placed the ESP outside, but I’m not getting any value from UART and I don’t get any GPS data
I need to study a little bit more
nikito7
(nikito7)
January 16, 2022, 6:16pm
13
You may need a sim, if it is a-gps like mobile…
bremby
(bremby)
January 16, 2022, 6:20pm
14
Ahhh,
that’s can be the point
I connected the external GPS antenna
I had the impression that GPS and LTE are 2 different output. that’s why I’m trying GPIO03
nikito7
(nikito7)
January 16, 2022, 6:22pm
15
You need to know what is gps pin
And you need good power supply
8bitbrett
(Brett Hansen)
July 12, 2022, 9:42pm
17
Any update? I’m looking into using the cellular option as well just for texts messages and such. Is this possible?
bremby
(bremby)
November 27, 2022, 8:23pm
18
I found this Guide: LILYGO T-SIM7000G ESP32 (LTE, GPRS, GPS) | Random Nerd Tutorials , it sounds a good reference
based on that it seems that “This board only supports nano SIM cards. You need a SIM card for LTE and GPRS. However, if you only want to use GPS data, you don’t need a SIM card.”
this works:
# MMWAVE MOTION SENSOR #
uart:
- id: uart_mmwave
tx_pin: GPIO4
rx_pin: GPIO5
baud_rate: 115200
debug:
direction: BOTH
dummy_receiver: true
after:
delimiter: "\n"
sequence:
- lambda: UARTDebug::log_string(direction, bytes);
- id: uart_mhz
rx_pin: GPIO1
tx_pin: GPIO3
baud_rate: 9600
binary_sensor:
- platform: gpio
name: Mega MS mmwave
pin:
number: GPIO12
mode:
input: true
pullup: false
# PIR MOTION SENSOR #
- platform: gpio
pin: GPIO16
name: Mega MS PIR
device_class: motion
# PIR MOTION SENSOR #
number:
- platform: template
name: Mega MS mmwave Distance
id: distance
min_value: 0
max_value: 1350
initial_value: 315
optimistic: true
step: 15
restore_value: true
unit_of_measurement: cm
set_action:
- uart.write:
id: uart_mmwave
data: "sensorStop"
- delay: 1s
- uart.write:
id: uart_mmwave
data: !lambda
int cm = (int)ceil(x / 15.0);
std::string cms = "detRangeCfg -1 0 " + to_string(cm);
return std::vector<unsigned char>(cms.begin(), cms.end());
- delay: 1s
- uart.write:
id: uart_mmwave
data: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- uart.write:
id: uart_mmwave
data: "sensorStart"
- platform: template
name: Mega MS mmwave Latency
id: latency
min_value: 0
max_value: 65000
initial_value: 12500
optimistic: true
step: 25
restore_value: true
unit_of_measurement: ms
set_action:
- uart.write:
id: uart_mmwave
data: "sensorStop"
- delay: 1s
- uart.write:
id: uart_mmwave
data: !lambda
int ms = (int)ceil(x / 25.0);
std::string mss = "outputLatency -1 0 " + to_string(ms);
return std::vector<unsigned char>(mss.begin(), mss.end());
- delay: 1s
- uart.write:
id: uart_mmwave
data: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
- delay: 1s
- uart.write:
id: uart_mmwave
data: "sensorStart"
# GENERAL FUNCTION #
button:
- platform: restart
name: "Mega MS ESP32 Restart"
- platform: shutdown
name: "Mega MS Shutdown"
entity_category: diagnostic
# CO2 #
- platform: template
name: "Mega MS MH-Z19 Calibrate Zero (20 minutes at 400ppm)"
id: calibrate_zero
entity_category: diagnostic
on_press:
- mhz19.calibrate_zero: mhz19_sensor
# CO2 #
sensor:
- platform: wifi_signal
name: "Mega MS WIFI Signal"
update_interval: 60s
# CO2 #
- platform: mhz19
uart_id: uart_mhz
id: mhz19_sensor
co2:
name: "Mega MS MH-Z19 CO2 Value"
id: co2
temperature:
name: "Mega MS MH-Z19 Temperature"
id: temperature
update_interval: 60s
switch:
- platform: template
name: "Mega MS MH-Z19 Automatic Baseline Calibration"
entity_category: diagnostic
optimistic: true
on_turn_on:
mhz19.abc_enable: mhz19_sensor
on_turn_off:
mhz19.abc_disable: mhz19_sensor
# CO2 #