Home made ESP32dev with sx1278 (433mHz)

Hi Team,

I’ve soldered an ESP32 dev board to an SX1278 to use as a minimal OpenMQTTGateway, but can’t get the buildflags quite right.
I’ve used the Liligo-Lora board as a starting point (removing the display functionality), and while it installs correctly, I’m not seeing any MQTT messages come in. Changing the board to esp32dev, requires some further build flags, but still no messages come in.

See the custom env below

[env:DIY-Gateway]
platform = ${com.esp32_platform}
board = esp32dev ; used to be ttgo-lora32-v21
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h
board_build.partitions = min_spiffs.csv
lib_deps =
  ${com-esp32.lib_deps}
  ; ${libraries.ssd1306}
  ${libraries.rtl_433_ESP}
build_flags =
  ${com-esp32.build_flags}
; *** OpenMQTTGateway Config ***
  ;'-UZmqttDiscovery'          ; disables MQTT Discovery
  '-DvalueAsATopic=true'    ; MQTT topic includes model and device
  '-DGateway_Name="DIY-Gateway"'
; *** OpenMQTTGateway Modules ***
  '-DZgatewayRTL_433="rtl_433"'
  '-DZradioSX127x="SX127x"'
  '-DRF_SX1278="SX1278"'     ;Added to fix compile errors, and force the library to use custom config
  '-DRF_MODULE_DIO0=26'    ; SX1278 pin DIO0
  '-DRF_MODULE_DIO1=13'    ; Added to fix compile errors, but not connected
  '-DRF_MODULE_DIO2=5'    ; Added to fix compile errors, but not connected
  '-DRF_MODULE_RST=14'     ; pin to be used as hardware reset
  '-DRF_MODULE_CS=18'
  '-DRF_MODULE_MOSI=27'
  '-DRF_MODULE_MISO=19'
  '-DRF_MODULE_SCK=5'
  ; '-DESPWifiManualSetup=true'
  ; '-DMQTT_PORT="1883"'
; *** rtl_433_ESP Options ***
 '-DRTL_DEBUG=4'             ; rtl_433 verbose mode
;  '-DRTL_VERBOSE=58'          ; LaCrosse TX141-Bv2, TX141TH-Bv2, TX141-Bv3, TX141W, TX145wsdth sensor
 '-DRAW_SIGNAL_DEBUG=true'   ; display raw received messages
;  '-DMEMORY_DEBUG=true'       ; display memory usage information
;  '-DDEMOD_DEBUG=true'         ; display signal debug info
;  '-DMY_DEVICES=true'         ; subset of devices
  '-DPUBLISH_UNPARSED=true'    ; publish unparsed signal details
;  '-DRSSI_THRESHOLD=12'       ; Apply a delta of 12 to average RSSI level
;  '-DAVERAGE_RSSI=5000'       ; Display RSSI floor ( Average of 5000 samples )
  '-DSIGNAL_RSSI=true'         ; Display during signal receive
  '-DNO_DEAF_WORKAROUND=true'

I’m comfortable that the modules for sending and receiving work and are properly connected based on tests with this code for sender and receiver: GitHub - LilyGO/TTGO-LORA32: ESP32-TTGO-T3

Thanks for your help!

I just made something similar, I used a rfm98 but its the same chip as far as I can tell and its working without the display,


this is the settings I used. best of luck!

[platformio]
default_envs = rtl_433SX127x_mine-ota


[env:rtl_433SX127x_mine]
;platform = ${com.esp32_platform}
platform = espressif32@3.5.0
board = esp32dev 
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h lolin32_lite esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
  ${com-esp32.lib_deps}
;  ${libraries.ssd1306}
  ${libraries.rtl_433_ESP}
build_flags =
  ${com-esp32.build_flags}
  '-DONBOARD_LED=13'  
  '-DGateway_Name="OpenMQTTGateway"'
  '-DBase_Topic="rf/"'
  '-DESPWifiManualSetup=true'
  '-Dwifi_ssid="xxxxx"'
  '-Dwifi_password="xxxxxx"'
  '-DMQTT_USER="open_mqtt"'
  '-DMQTT_PASS="xxxxx"'
  '-DMQTT_SERVER="192.168.1.226"'
  '-Dota_password="otapassword"'  
; *** OpenMQTTGateway Config ***
  ;'-UZmqttDiscovery'          ; disables MQTT Discovery
  '-DvalueAsATopic=true'       ; MQTT topic includes model and device
; *** OpenMQTTGateway Modules ***
  '-DZgatewayRTL_433="rtl_433"'
  '-DZradioSX127x="SX127x"'
  
 ; '-DOOK_MODULATION=false'       ; False is FSK, True is OOK
   
  '-DRF_SX1278="SX1278"'   ; Heltec ESP 32 Module - module settings come from heltec_wifi_lora_32_V2/pins_arduino.h

  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup

  
  ;'-DRF_SX1278="SX1278"'   ; Heltec ESP 32 Module - module settings come from heltec_wifi_lora_32_V2/pins_arduino.h  
  '-DRF_MODULE_DIO0=17'    ; SX1276 pin DIO0
  '-DRF_MODULE_DIO1=4'    ; SX1276 pin DIO1
  '-DRF_MODULE_DIO2=2'    ; SX1276 pin DIO2
  '-DRF_MODULE_RST=15'     ; pin to be used as hardware reset
  ;'-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup
; *** Heltec module requires non-standard SPI Config ***
  '-DRF_MODULE_CS=5'      ; pin to be used as chip select
  '-DRF_MODULE_MOSI=23'
  '-DRF_MODULE_MISO=19'
  '-DRF_MODULE_SCK=18'  
  
; *** ssd1306 Display Options ***
;  '-DZdisplaySSD1306="HELTEC_SSD1306"'
;  '-DLOG_TO_OLED=false'         ; Enable log to OLED
;  '-DJSON_TO_OLED=true'
;  '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
;  '-DDISPLAY_IDLE_LOGO=false'
;  '-DDISPLAY_BRIGHTNESS=80'
;  '-DDISPLAY_METRIC=false'
custom_description = Gateway using RTL_433_ESP and RadioLib
monitor_port = COM3
monitor_speed = 115200
upload_port = COM3
upload_speed = 921600


[env:rtl_433SX127x_mine-ota]
extends = env:rtl_433SX127x_mine
upload_protocol = espota
upload_port = 192.168.1.141
upload_flags =
  --auth=otapassword
  --port=8266

2 Likes

Thanks so much!

I definitly got further now. I see in the serial connection the ‘SX127x Status’, and the LED on the esp32 with OMG even flashes when the other board is sending a message, but somehow it’s not publishing in MQTT. (It’s not a Wi-Fi or MQTT problem as I see the normal status messages in MQTT explorer).
I’ve then turned on some debugging flags, and I see that the messages get ignored:
‘rtl_433_ESP(6): Ignored Signal length: 43996, Time since last bit length: 40424, Gap length: 557089, Signal RSSI: -46, Current RSSI: -96, pulses 0, noise count: 0’

Any thoughts?

Seems like some things have changed. I can’t get your to compile as-is. the error I get is “no matching function for call to ‘WiFiClass::waitForConnectResult(int)’” however that seems to be resolved using ‘platform = espressif32’

This is the current configuration:

[env:DIY-Gateway-2]
;platform = ${com.esp32_platform}
platform = espressif32 ; @3.5.0
board = esp32dev 
; ~/.platformio/packages/framework-arduinoespressif32/variants/.../pins_arduino.h lolin32_lite esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
  ${com-esp32.lib_deps}
;  ${libraries.ssd1306}
  ${libraries.rtl_433_ESP}
build_flags =
  ${com-esp32.build_flags}
  '-DONBOARD_LED=2'
  '-DGateway_Name="OMGateway"'
  '-DBase_Topic="OMG/"'
  '-DESPWifiManualSetup=true'
  '-Dwifi_ssid="XXX"'
  '-Dwifi_password="XXX"'
  '-DMQTT_USER="XXX"'
  '-DMQTT_PASS="XXX"'
  '-DMQTT_SERVER="192.168.4.81"'
  '-Dota_password="XXX"'  
; *** OpenMQTTGateway Config ***
  ;'-UZmqttDiscovery'          ; disables MQTT Discovery
  '-DvalueAsATopic=true'       ; MQTT topic includes model and device
; *** OpenMQTTGateway Modules ***
  '-DZgatewayRTL_433="rtl_433"'
  '-DZradioSX127x="SX127x"'
 ; '-DOOK_MODULATION=false'       ; False is FSK, True is OOK
  '-DRF_SX1278="SX1278"'   ; Heltec ESP 32 Module - module settings come from heltec_wifi_lora_32_V2/pins_arduino.h
  '-DRF_MODULE_INIT_STATUS=true'    ; Display transceiver config during startup

;  '-DRTL_DEBUG=4'           ; rtl_433 verbose mode
;  '-DRTL_VERBOSE=58'          ; LaCrosse TX141-Bv2, TX141TH-Bv2, TX141-Bv3, TX141W, TX145wsdth sensor
 '-DRAW_SIGNAL_DEBUG=true'   ; display raw received messages
;  '-DMEMORY_DEBUG=true'   ; display memory usage information
 '-DDEMOD_DEBUG=true'  ; display signal debug info
;	 '-DMY_DEVICES=true'		; subset of devices
 '-DPUBLISH_UNPARSED=true'   ; publish unparsed signal details
;  '-DRSSI_THRESHOLD=12'         ; Apply a delta of 12 (default 9)
;  '-DOOK_FIXED_THRESHOLD=0x50'  ; Inital OOK Threhold - Only for SX127X (default 5A)
;  '-DAVERAGE_RSSI=5000'     ; Display RSSI floor ( Average of 5000 samples )
 '-DSIGNAL_RSSI=true'             ; Display during signal receive

  '-DRF_MODULE_DIO0=26' ; SX1276 pin DIO0
  '-DRF_MODULE_DIO1=13' ; SX1276 pin DIO1
  '-DRF_MODULE_DIO2=4'  ; SX1276 pin DIO2
  '-DRF_MODULE_RST=14'  ; pin to be used as hardware reset
; *** Heltec module requires non-standard SPI Config ***
  '-DRF_MODULE_CS=18'   ; pin to be used as chip select
  '-DRF_MODULE_MOSI=27'
  '-DRF_MODULE_MISO=19'
  '-DRF_MODULE_SCK=5' 
; *** ssd1306 Display Options ***
;  '-DZdisplaySSD1306="HELTEC_SSD1306"'
;  '-DLOG_TO_OLED=false'         ; Enable log to OLED
;  '-DJSON_TO_OLED=true'
;  '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
;  '-DDISPLAY_IDLE_LOGO=false'
;  '-DDISPLAY_BRIGHTNESS=80'
;  '-DDISPLAY_METRIC=false'
custom_description = Gateway using RTL_433_ESP and RadioLib
monitor_port = COM3
monitor_speed = 115200
upload_port = COM3
upload_speed = 921600

maybe you have to much 433mhz noise with that receiver can you try a different antenna?
maybe add some extra electrolyte caps on 3.3v? I use 470uf on mine
or make it less sensitive not 100% sure about these but worth a try

  '-DRF_MODULE_FREQUENCY=433.92'  ;orignial value 433.92
  '-DOOK_FIXED_THRESHOLD=19' ;orignial value 15 
  '-DSX127X_RXBANDWIDTH=250'  ;orignial value 250 maybe increase this a bit?
  '-DRSSI_THRESHOLD=9' ;orignial value 9
  '-DMINRSSI=-72' ;orignial value-82 

Thanks again,

I’ve been playing around with multiple settings, but so far no luck.
I’m using the antenna that came with the LoRa module so that should be fine. I also don’t believe it’s an issue with power stability of the module, but a cap wouldn’t hurt I guess.

I’ll keep tinkering.
ps can;t seem to increase ‘-DSX127X_RXBANDWIDTH=250’ that gives a direct error when running on the ESP

I wouldn’t bet on it being correct. The antenna that came with my LORA for 433 resonated at about 880mhz. I use another LORA for Tinygs and the first thing they tell you is to throw away the antenna that comes with the LORA board as well.