In the future can you please title your post with the phrase that you are asking about. (This is part of the forum rules and makes things a lot easier for all members. Thanks!)
I would make the following changes in your sentence so that the time sequence is correct and it flows better: When I came back to my apartment I had to turn on the heater in spite of the warm weather, (in order) to take the humidity away/to get rid of the humidity.
Note: "I have a doubt" is a literal translation of Spanish to English and does not work in English. The phrase should be: I have a question.