The heat is surely the problem, i had many of cases like that, i recommend putting an AC unit on the electrical cabinet which is much cheaper than any part of CNC machine.
The main problem is in the CPU board. When i first stumbled upon this kind of problem i was assuming it was motion board, but after checking with another motion board, all Z-axis cables replaced, and even tried with all new input boards the problem stayed the same.
Only when i replaced the CPU board the problem was solved.
After installing the AC unit i tried to put in the old CPU card that makes that problem and to this day it is still working perfectly after 3 years have passed.