somethings are a bit odd.
i'd recommend initializing communication and sensor outside the while loop.
also, i recomend using loop acquisition bigger than 2 seconds, in conformity with sensor datasheet to avoid overheating.
i can not develop this code, don't have this sensor here to test. but recently i gave some instructions that worked out for some colleagues.
first, get used to how the sensor works, reading its datasheet and using arduino libraries (they are good sources of information) as a guide:
https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf
https://github.com/enjoyneering/AHT10
here are the links for the answers i gave. check out if those can help you:
https://forums.ni.com/t5/Hobbyist-Toolkit/Using-multiple-sensors-together-with-linx/m-p/4150738#M745
https://forums.ni.com/t5/Hobbyist-Toolkit/Vi-for-VELM6075/m-p/4151957#M749
also, another possibility is to implement the library in your microcontroller main loop and use custom command to request information from the sensor.:
https://web.archive.org/web/20200806103634/https://www.labviewmakerhub.com/doku.php?id=learn:tutoria...
hope it helps
Jorge Augusto Pessatto Mondadori, PhD
Sistema Fiep
CLAD, CLD