Arduino board ESP keep dropping connection with losant

I have been using my Arduino IDE to compile my code and flash t he firmware to my ESP8266 and ESP-32 board. It send the data to the door opening and closing status to the Losant site. It works fine to begin with but after a few minutes the Losant reported connection lost. I have been trying with different board such as D1. And it doing the same. It has been frustration because my first project and cannot get it to work. I have to unplug the power to the board and plug back in it works for a few minutes then the connection lost again. I am using this examples code https://docs.losant.com/getting-started/losant-iot-dev-kits/door-sensor-kit/. Any help appreciated. I like to use the Arduino IDE and not Mongoose.