Saturday, 15 September 2018

Arduino UNO - WIFI Module ESP8266 Connection Steps


Requirements:
1. Arduino UNO
2. ESP8266 Wifi Module



 Connecting the Arduino UNO to ESP8266 :

   1. Connect the Arduino'ss 3.3V PIN output to the red line on a breadboard.
   2. The ESP8266 works with 3.3V and not 5V, so this is necessary.
   3. Connect Arduino's GND (ground) to the blue line on bread board.
   4. Connect the RES or RESET pin of Arduino to the blue line.
      When you ground the reset pin, the Arduino works as USB to serial connector, required for talking to the ESP8266.
      (When you ground the Reset PIN, you wont be able to load your binary to Arduino, so if you want to load any of your code to arduino make sure the reset pin is not grounded)
   5. Connect the RXD pin of the Arduino to the RX pin of the ESP8266.
   6. Connect the TXD pin of the Arduino to the TX pin of the ESP8266.
      Usually, when we want two things to talk to each other over serial, we connect the TX pin of one to the RX of the other (send goes to receive and receive goes to send).
      Here Arduino is not talking to ESP8266, it only powers the ESP8266 module & gives us a interface to send connection commands from our computer to the ESP.
   7. Connect the GND pin of the ESP to the blue line on breadboard.
   8. Connect the VCC of ESP to the red line on breadboard.
   9. At last CH_PD goes to the red line. (CH_PD - Chip Power Down) Used to enable / disable the Wifi module.
      A good feature to save power when wifi is not in use.

Sending Comands to ESP8266 Wifi Module from PC:
1. We will not be uploading any binary to the ESP8266.
2. Open Arduino IDE → Tools Menu → Serial Monitor.
3. Set baud rate to 115200 [the default ESP8266 firmware uses]
4. Set line endings to 'Both NL & CR'.
5. Now type AT & click Send, this will send an AT command to ESP8266 module, & ESP will respons back with OK acknowledge.


You should see output as below:



ESP8266 AT Commands :



Commands
Description
Set/Execute
Parameters
AT+RST
restart the module
AT+CWMODE
wifi mode
AT+CWMODE=<mode>
1= Sta, 2= AP, 3=both
AT+CWJAP
join the AP
AT+ CWJAP =<ssid>,< pwd >
ssid = ssid, pwd = wifi password
AT+CWLAP
list the AP
AT+CWLAP

AT+CWQAP
quit the AP
AT+CWQAP

AT+ CWSAP
set the parameters of AP
AT+ CWSAP= <ssid>,<pwd>,<chl>, <ecn>
ssid, pwd, chl = channel, ecn = encryption
AT+ CIPSTATUS
get the connection status
AT+ CIPSTATUS

AT+CIPSTART
set up TCP or UDP connection
1)single connection (+CIPMUX=0) AT+CIPSTART= <type>,<addr>,<port>; 2) multiple connection (+CIPMUX=1) AT+CIPSTART= <id><type>,<addr>, <port>
id = 0-4, type = TCP/UDP, addr = IP address, port= port
AT+CIPSEND
send data
1)single connection(+CIPMUX=0) AT+CIPSEND=<length>; 2) multiple connection (+CIPMUX=1) AT+CIPSEND= <id>,<length>

AT+CIPCLOSE
close TCP or UDP connection
AT+CIPCLOSE=<id> or AT+CIPCLOSE

AT+CIFSR
Get IP address
AT+CIFSR

AT+ CIPMUX
set mutiple connection
AT+ CIPMUX=<mode>
0 for single connection 1 for mutiple connection
AT+ CIPSERVER
set as server
AT+ CIPSERVER= <mode>[,<port> ]
mode 0 to close server mode, mode 1 to open; port = port
+IPD
received data




Video demo for AT Commands:

Wednesday, 12 September 2018

Arduino UNO - Blink LED

Let us try a very simple program to control a LED via a C program.

Requirements:
1. Arduino UNO
2. LED bulb
3 Arduino IDE

Arduino UNO
uses a ATmega328P microchip which is a 8-bit AVR RISC-based microcontroller with
  • 32KB ISP flash memory with read-while-write capabilities
  • 1024B EEPROM, 2KB SRAM
  • 23 general purpose I/O lines
  • 32 general purpose working registers
  • 3flexible timer/counters with compare modes,
  • internal and external interrupts
  • serial programmable USART(Universal Synchronous/Asynchronous Receiver/Transmitter)
  • a byte-oriented 2-wire serial interface
  • SPI serial port.
  • a 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF packages).
  • a programmable watchdog timer with internal oscillator.
  • 5 software selectable power saving modes. 
  • device operates between 1.8-5.5 volts.

LED Bulb



Arduino IDE
  • Install the Arduino IDE on your PC. You will get the Setup for Arduino here
    (download size 178MB) [ Version 1.8.7 ]
    https://www.arduino.cc/en/Main/Software
Arduino IDE comes with few working sample codes. Of which we will be using one for our 1st simple tutorial.

STEPS:
1. Open Arduino IDE
2. Goto > File > Examples > 01. Basics > Blink
3. This opens the Blink LED Sample code as shown in image below.



4. Connect your Arduino UNO to PC via USB cable.
5. Connect a LED bulb with positive end to PIN 13, & negative end to ground PIN GND
    ( in LED  bulb the long end is positive & short end is negative.)
6. Now click the VERIFY button on Arduino IDE. This will build the code & check for errors if any.
7. Now click UPLOAD button on Arduino IDE. This will burn the code on to your Arduino UNO.
8. You will see long glow at TX , RX LED when your code is uploading.
9. Once done immediately your code will start executing. You will be able to see the LED attached to pin 13 toggle on/off with a delay of 1 second.





BLOG INDEX