Platformio Portable Configuration File

Goal: Use my “franks_env.ini” file to build an image using Liligo-rtl_433 and add support for a BME280 sensor. I have a lilygo LORA32 915 flashed up and receiving data from my weather station just fine. My first step was to create the franks_env.ini so I could experiment in building my custom flash. I can’t seem to get any settings from franks_env.ini to load into my flash while compiling. If I add a random line like just the word “test” I get errors, so I figure the compiler is at least seeing the file. Below is my file which I started by just copying the lilygo-rtl_433 config from the environments.ini. Most of the lines can and will be removed once I better understand what I am doing wrong.

Kinda stuck here right now so any suggestions are most welcome!

[env:lilygo-rtl-FG]
extends = env:lilygo-RTL_433
platform = ${com.esp32_platform}
board = 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=“Franks_Gateway-NEW!”’
‘-DMQTT_SERVER=“10.0.0.5”’
; *** OpenMQTTGateway Modules ***
‘-DZgatewayRTL_433=“rtl_433”’
‘-DZradioSX127x=“SX127x”’
; *** ssd1306 Display Options ***
‘-DZdisplaySSD1306=“LilyGo_SSD1306”’
; ‘-DLOG_TO_OLED=true’ ; 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 = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1

Hello,

Have you selected the board in the bottom bar:

Also, as you are using the extends PIO command, you may remove all the definitions that are already present in the original environment

Thanks for getting back so quickly! I just see “Auto” at the bottom, but I am able to erase and reflash my board no problem.

As far as that “extends” command… I am not entirely sure what that does anyway. Don’t seem to matter if I remove it. Now if I go into the environments.ini and make a basic change there, that will be written to my board… I just can’t seem to get the complier to follow the directions in franks_env.ini. I assume I will need that to add and configure BME280 support?

Hold up… trying again with this…

image

I would suggest removing the extends option in this case and just duplicating the environment with a different name. Test with this one and add your new modules/options

Removed the extends command. same result. I keep looking for the gateway name on my board display to change based off of:
‘-DGateway_Name=“Franks_Gateway-NEW!”’
but it’s not updating. That line in franks_env.ini should over right the default stored in the environments.ini correct?

Add at top of your file

[platformio]

default_envs = lilygo-rtl-FG

I get this error:
Warning! Ignore unknown configuration option default_envs in section [env:lilygo-rtl-FG]

[env:lilygo-rtl-FG]
default_envs = lilygo-rtl-FG
platform = ${com.esp32_platform}
board = 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=“Franks_Gateway-NEW!”’
‘-DMQTT_SERVER=“10.0.0.5”’
; *** OpenMQTTGateway Modules ***
‘-DZgatewayRTL_433=“rtl_433”’
‘-DZradioSX127x=“SX127x”’
; *** ssd1306 Display Options ***
‘-DZdisplaySSD1306=“LilyGo_SSD1306”’
; ‘-DLOG_TO_OLED=true’ ; 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 = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1

Added brackets [default_envs = lilygo-rtl-FG] compiling now

Still seems to be using this config from the enviorment.ini file…
If I make changes here… they ARE written to my board.

[env:lilygo-rtl_433]
platform = ${com.esp32_platform}
board = 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=“Franks_Gateway”’
‘-DMQTT_SERVER=“10.0.0.5”’
;‘-DESPWifiManualSetup=true’
;‘-Dwifi_ssid=“%$%$##$@”’
;‘-Dwifi_password=“HUNBG”’
; *** OpenMQTTGateway Modules ***
‘-DZgatewayRTL_433=“rtl_433”’
‘-DZradioSX127x=“SX127x”’
; *** ssd1306 Display Options ***
‘-DZdisplaySSD1306=“LilyGo_SSD1306”’
; ‘-DLOG_TO_OLED=true’ ; 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 = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1

I am using these icons to build and send my flash if that matters.

image

going to try a stripped down env.ini file next.

[env:lilygo-rtl-FG]
[default_envs = lilygo-rtl-FG]
platform = ${com.esp32_platform}

build_flags =
${com-esp32.build_flags}

‘-DGateway_Name=“Franks_Gateway-NEW!”’
‘-DMQTT_SERVER=“10.0.0.5”’

Appreciate the support… but still can’t figure out what I am missing.

Hi Frank,

Instead of trying with the default_envs or bottom build and upload options, which all require commenting or uncommenting different default_envs, can you see the PlatformIO icon on the left side - the alien head icon?

Select it and make sure that PROJECT TASKS is expanded, so that you should then see all defined environments, from the default environments.ini, and at the bottom your own defined lilygo-rtl-FG.

Can you see it, and when expanding lilygo-rtl-FG, under General, there should be the Build and Upload options just for this particular one environment.

An example with a different custom environment

Do take out the
[default_envs = lilygo-rtl-FG]
however from your environment though. @nikito7 suggestion meant that you should add this to the top of your portable config file, not within the environment itself. I do find the PROJECT TASKS way of building and uploading specific environments a lot easier and straight forward though :wink:

Could you also format any environment you are posting with the Preformatted Text option at the top of the text input field. Just makes it a lot easier for everyone else to read through them.

Let us know how you get on with my suggestions.

I only use cli.

Just as example

my_env.ini

[platformio]

default_envs = 
  han32-ttgo-ota
;  han32-ttgo
;  han-c3
;  han-c3-ota

; ### ### ###

[env:han32-ttgo]

platform = ${com.esp32_platform}
board = esp32dev
board_build.partitions = min_spiffs.csv

lib_deps =
  ${com-esp32.lib_deps}
  ${libraries.lora}
  Crypto = https://github.com/nikito7/__arduinolibs__crypto.git
  ChaChaPolyHelper = https://github.com/nikito7/__esp8266-chachapoly.git

build_flags =
  ${com-esp32.build_flags}
  '-DOMG_VERSION="han32-2024.01.21-0019"'
  '-DGateway_Name="LoRa_OMG1"'
  '-Dgw_password="edpbox123"'
; LoRa
  '-DZgatewayLORA="LORA"'
  '-DLORA_BAND=868E6'

custom_description = LoRa 868Mhz ESP32 Gateway
custom_hardware = Easy HAN LoRa ESP32

; ###

[env:han32-ttgo-ota]

extends = env:han32-ttgo
upload_protocol = espota
upload_port = 10.1.0.40
upload_flags =
  --auth=edpbox123
  --port=8266

; ### ### ###

Sorry not to get back right away…

By: uncommenting: ;default_envs = lilygo-rtl_433 in the platform.ini
uncommenting: //#define ZsensorBME280 “BME280” in the user_cinfig.h
updateing: int BME280_i2c_addr = 0x76; in the config_BME280.h
I can manualy compile and flash the lilygo T3 v 1.6.1 board, it connects and is sending the 2 seperate MQTT topics/data to my broker. Nice!

I restored all the settings above to default and started over making franks_env.ini a copy of the of the lilygo-rtl_433 section in the environments.ini

Still cant see to get platormio to use franks_env.ini to customize a flash.

[env:lilygo-rtl_433-FG]

platform = ${com.esp32_platform}
board = 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="Franks_Test"'
; *** OpenMQTTGateway Modules ***
  '-DZgatewayRTL_433="rtl_433"'
  '-DZradioSX127x="SX127x"'
; *** ssd1306 Display Options ***
  '-DZdisplaySSD1306="LilyGo_SSD1306"'
;  '-DLOG_TO_OLED=true'         ; 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 = For ESP32, Gateway using RTL_433_ESP and RadioLib
custom_hardware = ESP32 LILYGO LoRa32 V2.1

Success!! I notice this entry popped up in the project explorer.

image

Compiling that worked! I now have working portable configuration to experiment with!

3 Likes