Manual update of config.txt file

For the vast majority of users, the setup app does everything needed to maintain your desired configuration. From time to time advanced users and DIYers find it necessary to manually alter their config.txt file.

First a word about the config.txt file. It is formatted using Json notation, and any modifications must conform to Json rules. It is strongly advised that any modified config.txt file be checked with a Json linter such as https://jsonlint.com/. Failure to do so can cause the config to be rejected in its entirety.

The file is protected by the firmware and cannot be directly written with the file manager or by any other means. There are two indirect ways to modify it.

  1. Remove the SD card and edit the file with your computer.

  2. Upload a staged config+1.txt file to replace your current file.

The first method is pretty straightforward. The second is the subject of this post.

Older versions of IoTaWatt did not protect the config file from rewrite, so the setup app simply wrote a new file to replace the old. This opened up several windows where the old file was deleted but the new file, for various reasons, never replaced it. Incidences of lost config files were rare but did happen.

When protection was introduced, the config file was reinvented as three different versions:

config-1.txt - the previous valid config
config.txt - the current valid config
config+1.txt - an updated config candidate.

When a file named config+1.txt is uploaded, it is written to the root directory. Subsequently, after the file transfer is complete, it is processed as a new config. If no errors are found, the current config.txt is renamed to config-1.txt and config+1.txt is renamed to config.txt. Should anything happen to interrupt the renaming process, the IoTaWatt will look for a config+1.txt file whenever it can’t find a config.txt file.

So long story short, if you upload your new file as config+1.txt, it will be vetted and replace the current config.txt.