-
Notifications
You must be signed in to change notification settings - Fork 2
02 Credentials and Settings
02- Credentials and Settings
There are two files included with the main .ino file and you will need to edit both of these files before installing the firmware on the ESP32. Both files and their options are described below.
The credentials file contains your particular information for wifi and MQTT. Edit this file and supply your own information.
All values, except for MQTTPORT should be enclosed in double-quote marks. Just replace the values between the quotes with your particular values. All values are case-sensitive.
Define | Example | Description |
---|---|---|
SID | "MyWiFi" | Enter your wifi SSID or name |
PW | "MyPassword" | Enter the password for your Wifi |
MQTTUSERNAME | "MyBroker" | Enter the user name for your MQTT broker |
MQTTPASSWORD | "MQTTPassword" | Enter the password for your MQTT broker |
MQTTSERVER | "192.168.1.115" | Enter the IP address or URL for your MQTT broker |
MQTTPORT | 1883 | Enter the port for the MQTT broker. By default this is 1883 and should not be quoted |
AP_SSID | "amp_ap" | Enter the SSID the ESP32 will broadcast if it cannot connect to wifi |
AP_PWD | "12345678" | Password for the AP |
After making the appropriate changes, save the file. You should not need to edit this file again unless any of the above information changes.
This file contains additional options and settings. You should update them as needed to match your build and preferences. Since my amp was called Desk Amp here and in Home Assistant, you may wish to update those particular items to give your amp a meaningful name.
ESP32 Pins Used
Define | Default | Description |
---|---|---|
RX_PIN | 16 | ESP32 Receive pin - connected to amp TX |
TX_PIN | 17 | ESP32 Transmit pin - connected to amp RX |
SDA_PIN | 21 | Data pin for the SSD1306 OLED Display |
SCL_PIN | 22 | Clock pin for the SSD1306 OLED Display |
DISP_PIN | 19 | ESP32 pin connected to the rotary knob switch pin |
IR_RECV_PIN | 18 | ESP32 pin connected to the external IR Receiver signal pin |
WIFI and MQTT modes, topics and hostnames - Be sure to use a different publish and subscribe topic or unexpected behavior may result, including 'ghosting' commands on the amp.
Define | Default | Description |
---|---|---|
WIFIMODE | 2 | 0 = AP only, 1 = wifi only, 2 = both |
MQTTMODE | 1 | 0 = Disable MQTT, 1 = enable (WIFIMODE must be 1 or 2) |
MQTTCLIENT | "DeskAmp" | MQTT client name (every MQTT client must have unique name) |
WIFIHOSTNAME | "DeskAmp | Wifi host name - should show up in router under this name |
MQTT_TOPIC_SUB | "cmnd/deskamp" | Topic amp will subscribe to for receiving commands |
MQTT_TOPIC_PUB | "stat/deskamp" | MQTT topic that the amp will use to publish its states |
OTA_HOSTNAME | "DeskAmpOTA" | Hostname to broadcast as port in the IDE for OTA Updates. |
OLED display settings and setup (based on SSD1306)
Define | Default | Description |
---|---|---|
SCREEN_WIDTH | 128 | Display width, in pixels |
SCREEN_HEIGHT | 64 | Display height, in pixels |
SCREEN_ADDR | 0x3C | 7-bit I2C address (check your display documentation) |
OLED_RESET | -1 | Reset pin. Use -1 if display does not have a reset pin |
OTA update settings - Do not change these unless you have a need and understand what you are doing
Variable | Default | Description |
---|---|---|
ota_flag | true | Must be true for board to broadcast port to IDE upon boot |
ota_time_elapsed | 0 | Counter when OTA ctive. Leave at zero. |
ota_boot_time_window | 2500 | Minimum time on boot for IP address to broadcast port to IDE, in milliseconds |
ota_time_window | 20000 | Time to pause code for upload to start, in milliseconds. Setting too high may result in watchdog reset |
Boot up and other options
Variable | Default | Description |
---|---|---|
mqttTopicPub | "stat/deskamp" | Needed for initial MQTT publish. Must match MQTT_TOPIC_PUB above |
dispTempDisplay_duration | 4000 | How long to display a state change on display before returning to default display value, in milliseconds |
bootDispMode | 1 | Default display mode at boot: 1=Source, 2=Volute, 3=Title, 4=Track, 5=Mute, 6=Blank |
enableIR | 1 | 0 = Disable IR at boot, 1 = enable |
More information on the display and IR options: The OLED display has a 'default' display mode. When new data is received (for example, a change in the treble setting), the display will temporarily show this new setting for the time specified in the duration above (4 seconds is the default). The display will then return back to the default display mode.
The default display mode can be changed after the system boots by clicking the rotary knob. The value listed here in the setting is the default mode that will be set as the initial default. If, for example, you always want the default display mode to be Volume whenever the ESP32 boots, change this value to 2.
Similary, the IR functionality can be enabled or disabled (and switched back and forth) after boot up via an MQTT command. The setting here is just the default IR mode at boot.
Be sure to save the file after making any changes.