INTERNET OF THINGS
Lecture 2
- Arduino IDE
- NodeMCU
- Wifi Mode
ARDUINO IDE
INTRODUCTION
The Arduino Integrated Development Environment TAPIT
- Contains:
• A text editor for writing code
• A message area, a text console,
• A toolbar with buttons for common
functions and a series of menus.
• It connects to the Arduino and
Genuino hardware to upload
programs and communicate with
them.
3
https://create.arduino.cc/editor
- Arduino programs can be divided in three main parts: TAPIT
Structure:
- setup, loop
- if, if…else, for, switch case…
Values:
- Constants: HIGHT|LOW…
- Data types: void, char…
Functions:
- Digital I/O
- Analog I/O
- …..
More:
https://www.arduino.cc/en/Reference/HomePage
4
NODEMCU INTRODUCTION
5
TAPIT
NodeMcu
http://www.nodemcu.com
6
Development Kit TAPIT
Features:
• 802.11 b/g/n
• WiFi 2.4 GHz, support WPA/WPA2
• Integrated low power 32-bit MCU
• Integrated 10-bit ADC
• Integrated TCP/IP protocol stack
• Deep sleep power < 5uA
• Wake up and transmit packets in < 2ms
• Standby power consumption of < 1.0mW (DTIM3)
• SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control,
PWM, GPIO
7
TAPIT
Development Kit
8
TAPIT
POWER:
9
TAPIT
KEY & LED
10
TAPIT
Digital I/O
pinMode(pin, mode)
11
TAPIT
Digital I/O
digitalWrite(pin, value)
- Write a HIGH or a LOW value to a digital pin.
- If the pin has been configured as an OUTPUT
with pinMode().
- Its voltage will be set to the corresponding value:
5V (or 3.3V on 3.3V boards) for HIGH,
0V (ground) for LOW.
12
TAPIT
Digital I/O
digitalRead(pin)
Reads the value from a specified digital pin,
either HIGH or LOW.
pin: the number of the digital pin you want to
read (int)
Returns: HIGH or LOW
13
TAPIT
Analog I/O (10BITADC)
analogReference(type)
Configures the reference voltage used
for analog input (i.e. the value used as
the top of the input range).
The options are:
14
TAPIT
Analog I/O (10BITADC)
analogRead(pin)
Reads the value from the specified analog pin.
Returns int (0 to 1023)
analogWrite(pin, value)
pin: the pin to write to.
value: the duty cycle: between 0
(always off) and 255 (always on).
15
TAPIT
Communication
Serial.begin(speed)
Sets the data rate in bits per second (baud) for
serial data transmission.
Serial.print(val)
Prints data to the serial port as human-
readable ASCII text
Serial.available() Serial.read()
16
NODEMCU WIFI MODE
17
NodeMCU can run in one of four WiFi
modes:
• Station mode (STA), where the NodeMCU device
joins an existing network
• Access point (AP) mode, where it creates its own
network that others can join
• Station + AP mode, where it both creates its own
network while at the same time being joined to
another existing network
• WiFi off
18
TAPIT
WiFi Mode and Connection
STA
AP
STA
STA
STA Server
19
STA
20