
How to Simulate Arduino in Proteus
In this blog, we will introduce the Proteus Simulation software by simulating interfacing DHT11 with Arduino.
Β
Proteus 8 Professional has been used for the rest of this tutorial.
Β
It also demos how we can test out our results in a simulation before implementing it on hardware.
Proteus Setup
Open the Proteus and click on the schematic capture icon on the top left corner.
Β
Navigate to the components section on the left bar and select the components required (Arduino, DHT11 and serial monitor).
Β
The virtual terminal/serial monitor is available in the instrument selector section as shown below(highlighted with yellow colour).
Β
Suppose any of the above instruments are not available in the component section theyβre corresponding proteus library will have to be downloaded which must include three extensions (.HEX, LIB, IDX)
Β
Copy both lib and IDX to the proteus library(In this case the location is β C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA\LIBRARYβ), and after that, the component would be available.
Β
Connect the DHT11 sensor to the Arduino board. Ensure proper connections and make note of the Arduino pin (it will be required for the code later on).
Β
After interfacing, the circuit should look like this.
Β
Save the above circuit and let's move to Arduino IDE for coding the above application.
Β
Β
CODE
#include<DHT.h>
DHT dht(2,DHT11);
void setup() {
Β // put your setup code here, to run once:
Β
Β Serial.begin(9600);
Β dht.begin();
}
Β
void loop() {
Β // put your main code here, to run repeatedly:
Β float t=dht.readTemperature();
Β float h=dht.readHumidity();
Β Serial.println("Temperature-");
Β Serial.println(t);
Β Serial.println("Humidity-");
Β Serial.println(h);
Β delay(5000); Β Β
Β
}
Β
Enter the above code into the Arduino IDE and compile/verify it. After verification is done successfully, locate the .hex file as shown below(you will find the hex file in the error and information window of Arduino ide)
Β
Β
Copy the above .hex file and open the previously saved Proteus circuit.
Β
Double click on the Arduino and paste the .hex file location in the program file option as shown below.
Β
Β
Clicking on the run button on the bottom left corner of the page will start the simulation as shown below
Β
Β
You can change the value of both the temperature and humidity by using the up and down arrows on the sensor and notice the changes in the serial monitor/virtual terminal.
Β
This blog has been submitted by Cyborg, NIT Rourkela under the Robocraze Club Outreach Program.
Authors: Pratik & Samantaray