I'm trying to create SMS alarm using Twilio, Firebase and Arduino IDE. Using sensors I am measuring the temperature. If the temperature is higher than a specified value (ESP reads that value from Firebase Realtime Database), a SMS should be sent using twilio. I am also storing the measures in Firebase Realtime Database. The code worked well, until I tried to retrieve data from Firebase one more time and set data two more times. I believe that I'm running out of heap. I have only 10k heap left and cannot send SMS via Twilio. It only prints: connecting to api.twilio.com, but I don't receive the message.
I deallocate the Firebase Data objects after every loop, however, I believe, I still don't have enough heap. Do you have any suggestions how to optimize the code and gain more memory?
I posted the same question with code included on StackOverflow (https://stackoverflow.com/questions/64067911/esp8266-nodemcu-running-out-of-heap) because it exceeds the maximum allowed length on Arduino Forum.
Any help would be appreciated!