OMG. I realized now that the post was dated 2020 !!! Please apologise me if I have spammed the forum. !!!
You can refer to this old topic, where I've annexed (answert #13 more or less) both 8266 and MIt codes with their explanation.
Starting from there you can adapt these chunks of code for your needs (I guess
).
Best wishes.