Skip to content

02 ‐ Credentials and Settings

Resinchem edited this page Nov 30, 2023 · 3 revisions

02- Credentials and Settings

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 your D1 Mini or ESP8266 board. Both files and their options are described below.

Credentials.h

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. If the example shows quote marks, those quote marks should be included when substituting your values.

Define Example Description
SID "YOUR_WIFI_SSID" Enter your wifi SSID or name
PW "YOUR_WIFI_PASSWORD" Enter the password for your Wifi
MQTTUSERNAME "MQTT_USER" Enter the user name for your MQTT broker
MQTTPWD "MQTT_PASSWORD" Enter the password for your MQTT broker
MQTTSERVER "192.168.1.108" 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 "analog_clock" Enter the SSID the ESP will broadcast if it cannot connect to wifi
AP_PWD "hot_spot_pw" 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.

Settings.h

This file contains additional options and settings. You should update them as needed to match your build and preferences. You can change any of the MQTT setting to different names and/or topics if desired. Just be sure to update any external applications sending or receiving these MQTT topics are updated to match. If quotes are shown in the examples below, your values should include those quotes as well.

Important Note: As currently written, the code requires that the WIFIMODE be set to 1 or 2 and MQTTMODE must be enabled with a valid MQTT broker entered in the Credentials.h file.

Define Default Description
WIFIMODE 2 0 = AP only, 1 = wifi only, 2 = both
WIFIHOSTNAME "ANALOG_CLOCK" Wifi host name - should show up in router under this name
MQTTMODE 1 0 = Disable MQTT, 1 = enable (WIFIMODE must be 1 or 2)
MQTTCLIENT "analog_clock" MQTT client name (every MQTT client must have unique name)
MQTT_TOPIC_SUB "cmnd/aclock" Default MQTT subcribe topic for receiving commands
MQTT_TOPIC_SUB2 "stat/tm1638" Secondary MQTT topic for receiving current date and time (create in Home Assistant automation if this doesn't already exist)
MQTT_TOPIC_PUB "stat/aclock" Default MQTT topic used to publish clock states
OTA_HOSTNAME "ANALOG_CLOCK_OTA" Hostname to broadcast as port in the IDE for OTA Updates.
SERIAL_DEBUG 1 0 = disabled (must disable if using RX/TX pins), 1 = enable

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_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 options - These options can be changed after the clock boots via either the onboard push buttons and/or MQTT, but the values below will be used whenever the clock first boots. You can change any of the values to match your start-up preferences.

Variable Default Description
blinkCurMinute true The current minute LED will blink at the interval speficied. Set to false to turn blinking off.
blinkInterval 1000 The time value, in milliseconds, that the current minute LED will toggle off and on when the blinkCurMinute option is true. Ignored if blinking is disable. Avoid setting this value too low or too high. 500 - 4000 is probably an OK range.
sweepMinutes true Redraw the minute LEDs each time the minute changes, in a sweeping pattern from minute 1 to the current minute. Only applicable if the display mode is Full (dispMode 0), ignored otherwise.
dispMode 0 The initial display mode for the minute LEDS at boot time. Can be changed after boot via the onboard buttons or via MQTT. Currently supports five different modes (0-4)

See the wiki section on Display Modes for details on the different display modes.

Be sure to save the files after making any changes. The application must be compiled and uploaded to the D1 Mini via USB or OTA update after any changes before they will take effect.