Autoconnect sketch connects but then fails to connect again

Ive managed to get Ken Taylor's Autconnect or WiFiManager with parameter example to work on my ESP8266 esp01s.

Original library code: WiFiManager/ConfigOnSwitchFS.ino at master · kentaylor/WiFiManager · GitHub

and to this I added the following tab for my code which makes the ESP01s take a measurement from a dht22 on its GPIO02 and post it to an emoncms instance which works fine otherwise. My code is here:

But I get this error in the SM:

*WM: Request redirected to captive portal
*WM: Handle root
*WM: WiFi save
*WM: Parameter
*WM: 
*WM: 
*WM: Parameter
*WM: thingspeakapikey
*WM: bde919c2b47c5f12
*WM: Parameter
*WM: sensordht22
*WM: T
*WM: Parameter
*WM: pinsda
*WM: 2
*WM: Parameter
*WM: pinscl
*WM: 14
*WM: Sent wifi save page
*WM: Connecting to new AP
*WM: Connecting wifi with new parameters...
*WM: previous settings invalidated
*WM: After waiting...
*WM: 5.66
*WM: seconds
*WM: Connection result: 
*WM: WL_CONNECTED
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Handle root
*WM: Request redirected to captive portal
*WM: Handle root
*WM: Server Close
*WM: Sent server close page
Connected...yeey :)
Saving config file
{"thingspeakApiKey":"bde919c2b47c5f12","sensorDht22":true,"pinSda":2,"pinScl":14}
Config file was successfully saved
⸮
 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld

 Starting
PIFFS opened: 
{"thingspeakApiKey":"bde919c2b47c5f12","sensorDht22":true,"pinSda":2,"pinScl":14}
Config file was successfully parsed
Mode: STA
PHY mode: N
Channel: 1
AP id: 0
Status: 0
Auto connect: 0
SSID (6): thanos
Passphrase (26): 9F5195BBD679AAE6
BSSID set: 0
After waiting 0.00 secs in setup() connection result is 0
Failed to connect, finishing setup anyway
connecting to santiapps.com
connection failed
connecting to santiapps.com
connection failed

So it seems to connect with with the portal but then doesnt work when it goes off on its own. After connecting to the ESPXXX ssid and configuring it for the thanos SSID with its password, it seems to connect and I can even see it on a network scan software, but then after clicking on the EXIT PORTAL button it tries to go off and connect on its own and thats when it fails and produces a After waiting 0.00 secs in setup() connection result is 0

and then the loop fails to connect to post the data as instructed, because of course its not connected to the SSID.

It seems to save and read the config.json file just fine.