Program NodeMcu with arduino





NodeMCU Dev Board is based on widely explored esp8266 System on Chip from Expressif. If simply saying it’s an esp12 with a voltage regulator and a serial programmer. So instead of using esp12 and programming it using a serial converter, in NodeMcu we can just connect directly to pc
with usb and program.

Uses simple LUA based programming language. Lua is primarily used in video game industry since 1993. Lua is a fast language engine with small footprint that you can embed easily into your application. If you want to program your NodeMcu with Lua you can use ESPlorer IDE. You can download it from here. But in this article I’m going to tell you how you can program your NodeMcu with Arduino.




Pin mapping















In nodeMcu pin mapping is somewhat different, you can access D0 to D10 pins (GPIO pins) as below.
#define D0 16
#define D1 5
#define D2 4
#define D3 0
#define D4 2
#define D5 14
#define D6 12
#define D7 13
#define D8 15
#define D9 3
#define D10 1
 
*important- this is a device which operates in 3.3v level. So the output voltage of GPIO pins is 3.3v.
 
You can also power up nodeMcu with Vin 5v pin. But the 5V input won’t be enough to boot, after booting 5V is
enough, you will have to supply at least about 5.2V to boot.
 
Coding
 
Since I’ve mentioned a port in my code, you will have to add the port to your wifi router. Go to port forwarding
in your router and add the port number mentioned in your code (mine is 301).
 
You can download the code from here.
 
Select the port and the board as nodeMcu your version. Upload the code. Open serial port and set baud rate to
115200. Then it will give your ip for nodeMcu.
 
 
Change this line in setup const char* host = "192.168.8.101";  and set it to ip from the serial monitor.
 
Now open your web browser and type your ip with port number, eg: 192.168.8.101:301
 
 








                               

Connect your LED to pins D2(positive) and D3(negative), and press the two buttons you have on your web browser.
 

Comments

Popular posts from this blog

Getting started with ai thinker a7 module