How To Control A Camera With Nodemcu
Quick start with NodeMCU v3 (ESP8266), Arduino ecosystem, and PlatformIO IDE
Want to make an IoT project, only doesn't know how to start? Hither is the answer.
NodeMCU is a five-dollar open up-source IoT platform based on the ESP8266 Wi-Fi system on a scrap. Version three runs on the ESP-12E (ESP8266MOD) module and it's piece of cake to apply development lath equipped with analog and digital pins, a USB-to-serial adapter based on the CH340g module, and a micro USB socket.
By default, it runs Lua scripts, notwithstanding, the Arduino ecosystem is more suitable for beginners because of tons of information and libraries available. Or, if you've already started building a device with Arduino and need some Wi-Fi capabilities, information technology'd be easier to migrate your codebase to the ESP8266.
Regular coding for Arduino happens in the Arduino IDE, despite there is a more powerful solution: PlatformIO — a free and open-source ecosystem for IoT development. Here are some pros:
- Faster compiling
- Autocomplete
- Powerful library manager
- A convenient way to organize your lawmaking
- IDE customization and plugins
Having these three whales: hardware, software ecosystem, and IDE — will assistance you to a quick beginning with IoT and get beyond :)
NodeMCU v3 (ESP8266)
The development board comes with built-in firmware providing the possibility to control the Wi-Fi chip with AT commands. Just unwrap your brand new NodeMCU board and plug it into your figurer with a USB cable, it volition blink with blue LED a couple of times.
It uses a CH340g chip to convert the serial interface to the USB, which ways your computer needs drivers to piece of work with the board. Windows ten motorcar can automatically detect and install advisable drivers, but if yous demand hither is a driver to download (WCH is a Chinese company that designed this flake).
To check that the board working, we'll laissez passer some commands. Yous can use Serial Monitor from Arduino IDE or any serial terminal you similar, for example, Bray'southward Terminal.
Find port detected and connect to it with 9600
baud rate. Tap on the RST button to reset the evolution board and some "junk" should appear in the receive window:
Play with baud charge per unit (e.g. 38400
, 115200
) to go a line maxim "ready". My boards worked with 115200
by default:
Switch to CR+LF
line endings and send AT
command, it should respond with OK
message:
Now we are able to play with other commands such equally:
-
AT+RST
restarts the module -
AT+GMR
checks version information -
AT+CWMODE?
returns electric current mode: 1 — station, ii — soft access point, 3 — station + soft AP -
AT+CWMODE=3
sets station + soft AP mode (restart module withAT+RST
command after) -
AT+CWJAP="MyNetwork","qwerty12"
connects toMyNetwork
withqwerty12
password, replies withWIFI CONNECTED
andWIFI GOT IP
messages after the connexion established -
AT+CIFSR
returns connection info
You lot tin too plant a TCP connection with other devices in your network or find more commands in the ESP8266 AT Command Examples document. The board will say ERROR
, if the command you sent is not supported.
PlatformIO
Let'southward move on to the IDE. Proceed with the simple steps suggested on the PlatformIO website: Installation.
PlatformIO, in fact, is a Visual Studio Code extension, so what you lot need is to install the VS Code and add the platformio-ide
extension:
Give it a time to practice some installation magic, it'll also pull the C/C++ extension (ms-vscode.cpptools
), restart VS Code in the end and that's it — you're able to code!
Code
Despite some tutorials say information technology's needed to erase/flash the board with appropriate tools, I found it unnecessary when working with PlatformIO. You lot also non required to mess with Arduino IDE board manager besides!
Only click on the PlatformIO icon on the left bar and select New projection:
Name your project, select NodeMCU 1.0 (ESP-12E Module) board and Arduino framework, use default project location or not:
Click on End and permit information technology download all dependencies and build the project structure. Cheque the platformio.ini
file:
Information technology is the principal configuration file you'll exist interested in: platform
, board
and framework
parameters tell PlatformIO compiler what to use to compile the project. You can also specify here projection dependencies (libraries and versions), series monitor baud rate, and many other things. More details available here: Projection Configuration File.
Allow'due south endeavour to build the projection, find the PlatformIO: Build button (checkmark icon) on the bottom bar, and click it to launch the build process. If everything is fine, you'll get the same output in the terminal window:
Blink
I haven't managed to make built-in LED work on my boards, but perhaps you'll be luckier: information technology should exist attached to the LED_BUILTIN
pin. Let's glimmer the world:
Click on the PlatformIO: Upload button (correct arrow) to build and upload firmware to the lath. Blue LED will blink until the process completed.
External LED wiring scheme, if you demand:
Wi-Fi connection
At present we can test Wi-Fi capabilities and find out how to add together libraries. I suggest the WiFiManager library which provides a uncomplicated API to configure your module connection from the browser.
Go to the Libraries registry and search for wifimanager
:
Click on the WifiManager past tzapu library and and so on the Installation tab, it will evidence means to require the library in your platformio.ini
file:
Copy lib_deps = tzapu/WifiManager @ ^0.16.0
to theplatformio.ini
file and modify the master.cpp
code:
Upload the project and open the PlatformIO: Serial Monitor window, it will initialize the Wi-Fi managing director and outset HTTP server:
Get to Wi-Fi settings on your device and connect to the access bespeak created past the board.
If information technology's an Android device, you'll exist asked to "sign in to Wi-Fi network". In fact, it'll move you lot to the HTML page served past the module. If not, you lot tin open a browser and type in AP IP address
received in the Final window (192.168.4.one
here):
Type SSID and countersign of your local network, click on Relieve and bank check the Final window:
If the connection is successful, y'all'll encounter the Idle
bulletin, which means the loop()
function started its work. From that betoken, you're good to become with the Internet capabilities you need in the Arduino-friendly environment!
The final projection you can observe on GitHub: https://github.com/loginov-rocks/NodeMCU-Arduino-PlatformIO
Good luck with IoT projects!
Source: https://loginov-rocks.medium.com/quick-start-with-nodemcu-v3-esp8266-arduino-ecosystem-and-platformio-ide-b8415bf9a038
Posted by: williamsalksomed.blogspot.com
0 Response to "How To Control A Camera With Nodemcu"
Post a Comment