OTA using ESP8266 working but seems to lose configuration after several hours

You’ve referred to this as being an OTA issue, but I think you mean that it’s a dynamic provisioning problem - the device is losing its WiFi credentials. Is this correct?

Unfortunately, the snippet of code you’ve posted doesn’t really help, because it doesn’t tell us which pins your sensors are attached to.
One thing that is clear is that you’ve not un-commented a board type as you should, so the custom board configuration in the Settings.h tab is being used.
My guess is that you are using GPIO0 (pin D3 on a Wemos D1 Mini - if that what you mean by a LOLIN board) for something, and this is being pulled LOW for > 10 seconds and this is clearing your credentials.

You should read this, and refer to the actual Settings.h tab in your sketch (the default settings have changed since this was written)…

Do you really need the dynamic provisioning functionality of Blunk Edgent?

Pete.