Posting data to a server securely via http

I found this: GitHub - arpitchauhan/cryptographic-protocols-arduino-and-PC: This project demonstrates how cryptographic protocols can be implemented for the case when an Arduino board and a PC communicate. Primitives implemented: AES, RSA and Diffie–Hellman key exchange.

Which has Diffie–Hellman implementation. I have not looked at it as yet but surely that would be the best way to go over AES? Also what about man in the middle attacks?