You might be facing difficulties simulating nodemcu/esp8266 in proteus. The reason is clear that there are no third party libraries by the time of this post to simulate nodemcu in proteus. Then what's the solution now!
There might not have a third party library but we can mimic the behaviour of Nodemcu using some of the components. We will connect the nodemcu to the pc using usb cable and capture the COM port on proteus using COMPIM module of proteus. We need an arduino to read that data and execute the necessary instructions. This way we can simulate the functionalities of wifi and also complete the project.
How to use nodemcu in proteus
Let's see what we will learn from this tutorial:
1. How to use com ports in proteus
2. How to connect nodemcu to the internet
3. NodeMCU Arduino Serial communication
4. Simulate NodeMCU in proteus
Circuit Design for NodeMCU Simulation in Proteus
Let's build the circuit according to the figure below. You may need to add the arduino library into proteus if you don't have it already. You also need a few more components.
1. COMPIM
2. Virtual Terminal
2. LED
4. Resistance
COMPIM in proteus to capture Computer Ports
This module gives us the ability to capture data coming to the pc ports and also we could send data to the ports. This modules works for bluetooth and wifi ports also. You will find it in the proteus component library.
Arduino code for simulation
You need to compile the following code. Then find the location of hex file and put into the proteus arduino program file.
int light = 7;
void setup() {
pinMode(light, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
String str = Serial.readStringUntil('#');
if (str == "Light-on") {
digitalWrite(light, HIGH);
Serial.println("Light is on");
}
else if (str == "Light-off") {
digitalWrite(light, LOW);
Serial.println("Light is off");
}
}
}
NodeMCU Code
Upload the following code to your nodeMCU and find your IP using the serial monitor. After that close the serial monitor and keep your NodeMCU connected.
#include <ESP8266WiFi.h>
const char* ssid = "Your Wifi Name"; //enter your wi-fi name
Now paste the ip address in your browser to access the control panel. Keep your nodeMCU connected to the pc and start the simulation in proteus.
NodeMCU Proteus
You will see the received data on the virtual terminal window in the proteus. This will be read by arduino and it will either turn on the LED or off based on the command.
Watch the video below if you have any difficulties understanding this post.
Leave a Comment