In an Internet of Things (IoT) system, devices connected to the system exchange data. The data contains sensitive information about the connected devices in the system so it needs to be protected. Without security, the data in the IoT system can be easily retrieved. One way to prevent this is by implementing cryptography. Cryptography is a technique for protecting information by using encryption so that only the sender and receiver can see the contents of the information contained therein. The implementation of cryptography on IoT devices must consider the capabilities of IoT devices because in general IoT devices have limited processing capabilities compared to computer devices. Therefore, the selection of encryption algorithms needs to be adjusted to the computational capabilities of IoT devices. In this research, the affine cipher cryptography algorithm and Diffie-hellman key distribution algorithm are applied to the arduino atmega2560 IoT device. The purpose of this research is to increase the security of the IoT system by implementing cryptography. The method used in this research involves setting up a sequence of encryption and decryption steps using an affine cipher and diffie-hellman algorithms. Furthermore, these algorithms were implemented on an Arduino IoT device. Finally, the decryption time based on the number of characters and the avalanche test were tested. The results showed that on average, Arduino can perform decryption using affine cipher and diffie-hellman algorithms in 0.07 milliseconds per character. The avalanche test produced an average percentage of 45.51% from five trials.