Profiles - wolfen351/public-micropython-iot-platform GitHub Wiki

Profiles are a way to define a set of configuration parameters that can be used to configure a module. This is useful when you have a module that can be used in different scenarios, and you want to be able to switch between them easily.

Creating a Profile

Profiles are stored in the profiles folder. You can create a new profile by copying an existing one and modifying it to suit your needs. The profile is a JSON file that contains the following fields by default:

{
    "name": "LilyGo Battery Powered Temp Sensor",
    "shortName": "lilygo-gps",
    "activeModules": ["basic", "mqtt", "ota", "thingsboard", "web", "wifi", "gps", "homeassistant"],
    "cpuSpeed": 160000000,
    "statusLedPin": 3
}

Common Fields

The fields are:

  • name - The name of the profile
  • shortName - A short name for the profile
  • activeModules - A list of modules that are active in this profile
  • cpuSpeed - The speed of the CPU in Hz
  • statusLedPin - The pin that the status LED is connected to

Module-Specific Fields

Profiles often include additional sections to configure specific modules. Below are examples of module-specific configurations

GPS Module

"gps": {
    "rxPin": 16,
    "txPin": 17
}

This would configure the GPS module to use pins 16 and 17 for the RX and TX pins.

The whole profile will look like this:

{
    "name": "LilyGo Battery Powered Temp Sensor",
    "shortName": "lilygo-gps",
    "activeModules": ["basic", "mqtt", "ota", "thingsboard", "web", "wifi", "gps", "homeassistant"],
    "cpuSpeed": 160000000,
    "statusLedPin" : 3,
    "gps": {
        "rxPin": 16,
        "txPin": 17
    }
}

Relay Module

"relay": {
    "flipcommand": "/button/onboard/1",
    "pin": 4
}

Defines the command and pin for controlling a relay.

PIR (Motion Sensor) Module

"pir": {
    "pinA": 36,
    "pinACommand": "/trigger/0",
    "pinB": 35,
    "pinBCommand": "/trigger/1"
}

Configures motion detection with two pins and their respective commands.

OTA (Over-the-air updates)

"ota": {
    "url": "https://firmware.example.com/firmware",
    "tmp_filename": "new_firmware.tar.gz",
    "excluded_files": [],
    "delete": []
}

Usage

The profile is used by the sync.ps1 script to send the correct files to the board. It is also used by the web UI to configure the board. Only the modules that are active in the profile will be sent to the board, to save space. The micropython code will also use the profile to load only the specified modules into memory.

Available Profiles

Here is a list of available profiles and their purposes:

Profile Name Short Name Description
LilyGo Battery Powered Temp Sensor lilygo-gps A GPS-enabled temperature sensor.
Sonoff Basic R4 Board sonoffbasicr4_relay A relay board with OTA and MQTT support.
S2 Mini LED Strip s2mini-ledstrip Controls an LED strip with 120 LEDs.
S2 Mini Garage Door Closer s2mini-garagedoorcloser Automates garage door operations.
Esp32 2 Relays Board esp32-2relay A board with two relays for automation.

Refer to the profiles folder for more profiles and their configurations.