Arduino IOT revolutionises the way you can connect and automate your
devices. It used to be that you had to use an Internet Shield that
plugged into your Arduino and then connect that shield to the internet
via an internet cable to your router.
However, with the fantastic ESP range of devices, it is
now simpler than ever to setup an internet connection because they
implement WiFi operation with radio hardware built into the ESP board; so
there's no tricky setup.
For programming you simply plug into a USB port as you do for all Arduino boards.
You can put an ESP device anywhere and, as long as it has a power
source, it can connect to your local internet. No wires in sight!
Most of the following C/C++ examples deal with the WiFi aspect of
using the ESP32 or ESP8266 and some libraries will be different for each
but the web code ideas are the same. The question is which device
should you choose ESP32 or ESP8622.
The following pages give you a tutorial on setting up and using Arduino iot:
First off you'll need to get an ESP32 board and program it using the Arduino IDE.
The link shows you how to program an AI thinker (Arduino CAM board) but
you can choose any of the available boards and follow the same process
for programming any ESP32 board (the libraries used are the same for any ESP32 board).
You will also want to know about serving web pages using an Arduino Web Server.
You an choose between a synchronous or asynchronous web server. In that
link find out what the difference is between the two and run code
examples to show their action.
There's one problem when you use just a plain old web server and that
is: Every time you went to get an update to the page you have to reload
the page. If you wanted to see sensor readings every second you don't
really want to have to keep clicking the refresh button - that's where WebSockets come in.
The ESP32 WebSocket Server
page shows you exactly how to implement websockets on an ESP32.
There are four steps showing you the various parts of the
WebSocket operation :
The code required to implement each of these elements is in that link and shows you exactly how WebSockets work.
How to setup and program the NodeMCU V3
(ESP8266 ESP12e) board using the Arduino IDE. This example shows you
how to program the boot loader back into an ESP8266 (if you want to
change back from using LUA) and the it shows an example for
scanning for available WiFi network names.
Lua is an interpreted programming language (in the same way that
python is also interpreted) meaning that you don't have to program the
entire Flash memory every time you update 'your' program. Lua uses a
slightly different programming language idea in that all actions are
event
driven.
Once the ESP8266 is programmed with Lua
functionality you can upload your program over the serial port. You
only upload your program and then use a Lua editor (Esplorer) to manage
your Lua programs.
Setting up the ESP8266 as a webserver using the LUA language.
Once you have got LUA running you can investigate example programs that
control an LED.
Did you know there are two similar board:
Confused about these board variants? Which one is right for you?
Find out the exact differences between the ESP-01 and ESP-01S here and choose
the right one.
Note: Parts of this page were written using chatgpt
as a research assistant. Some images were created using leonardo.ai.
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.