Esdi Printout
Esdi Printout
Esdi Printout
AIM:
To develop and verify the interfacing of real time clock and serial port with ARMDEVELOPMENT
KIT microcontroller using embedded C program.
APPARATUS REQUIRED:
HARDWARE:
LPC2148 Kit - 1 No
PC
SOFTWARE:
PROCEDURE:
Connect RTC & RS323 (Serial) to the LPC2148 Development Board as shown incircuit.
Connect COM-0/ISP to PC using the Serial Port Cable.
Connect Adaptor with LPC2148 Kit & Switch ON.
To Edit / Compile / generate Hex file: Refer General procedure given in Page MDK-ARM Keil
µVision
To down load and run this program: Refer General procedure given in Page FlashMagic
PROGRAM:
RTC:
#include <LPC213x.h>
#include <stdio.h> #include
<ctype.h> #include
<stdlib.h> #include
"UART.h" #define BUZZ 7
//Buzzer Connected to P0.7
PLLFEED = 0x55;
MAMCR = 0x02; //Memory Acceleration Module Fully Enabled MAMTIM =
0x04; //MAM fetch cycles are 4 CCLKs in duration VPBDIV = 0x02; //Divide
Clock for PCLK = 30MHz
}
void RTC_Setup(char *Buff)
{
unsigned char TimE;char
i=0; for(i=0;i<2;i++)
{
while(!isdigit(Key)); //Waittill
Key = 0 to 9
if (i==0)
{
TimE = 10 * atoi( &Key );
}
if (i==1)
{
TimE += atoi( &Key );
}
putchar(Key);
Key = 0;
}
*Buff = TimE; /Load Setup New Value
}
void Delay()
{
unsigned int i,j;
for(i=0;i<50;i++)
Kf.oLr.N
(j.=C0.E;j/<B7.E
00/E
;jE
+E
+/);VI/20EC512– EMBEDDED SYSTEM DESIGN AND IOT
}
void Wait()
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
{
Delay();Delay();Delay();
Delay();Delay();Delay();
Delay();Delay(); Delay();
}
void Alarm(void)
{
IOSET0 = 1 << BUZZ;
Wait();Wait();
IOCLR0 = 1 << BUZZ;
Wait();
}
//void Clean(void)
//{
// unsigned char i;
// //for(i=0;i<250;i++)
// printf("[2M");
//}
void main(void)
{
Initialize(); UART1_Init(9600/*Baud
Rate*/);
U1IER = 3;//Enable UART1 Recieve Interrupt
//PINSEL0 |= (1 << 18); //Select Pin as UART1 IO0DIR |=
(1<<7); //Configure P0.7 as O/p (Buzzer)VICVectAddr0 =
(unsigned)UART1_ISR; VICVectCntl0 = 0x20 | 7;
VICIntEnable |= (1 << 7); VICVectAddr2 =
(unsigned)RTC_ISR;VICVectCntl2 = 0x20 |
13; VICIntEnable |= (1 << 13);
AMR = 0xFF; //Mask all valued except hh:mm:ss foralarm
comparision
PREINT = 0x00000392; // Set RTC Prescaler for PCLK 30 MHzPREFRAC =
0x00004380;// printf("[2J\0");// Clear Screen
CCR = 0x01;
//CIIR = 0x01;
UART1_PutS("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
UART1_PutS(" ARM LPC2138 RTC Demo\n\r ----------------------------------- \n\n\n");
UART1_PutS("> Press * to Set Time\n"); UART1_PutS("> Press ! to
Set Alarm\n"); UART1_PutS("> Press $ to Snooze Alarm 5
Minutes\n");UART1_PutS("> Press . to Stop Alarm\n");
UART1_PutS("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");while(1)
{
printf("CTC : %d\t",CTC);
//
Display time format hh:mm:ss
DelayMs(100); // Delay for display
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
if (Key == '*')
{
Key = 0;
UART1_PutS(">> Set Time: ");
RTC_Setup(&HOUR);
UART1_PutC(':');
RTC_Setup (&MIN);
UART1_PutC (':');
RTC_Setup (&SEC);
//printf("\r\tTIME: %02d:%02d:%02d \r",HOUR,MIN,SEC);
// Display time format hh:mm:ss
//printf("^[2J");
U1THR = 0x1B; //Escape UART1_PutS("[2J\0"); // Clear
Screen
if (Key == '!')
{
AMR = 0xF8;
Key = 0;
UART1_PutS(">>\tSet Alarm: ");
RTC_Setup(&ALHOUR);
UART1_PutC(':');
RTC_Setup(&ALMIN);
UART1_PutC(':');
RTC_Setup(&ALSEC)
}
if (Key == '$' && Flag == 1)
{
if (MIN >= 55)
{
ALHOUR = HOUR + 1; ALMIN = 5 -
(60 - MIN);
}
else
{
ALMIN = MIN + 5;
}
Key = 0;
Flag = 0;
}
if (Key == '.')
{
Key = 0;
Flag = 0;
}
if (Flag == 1)
{
Alarm (); Wait (); Alarm ();
}
}
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
void UART1_ISR(void) irq
{
char Msg;
if(((Msg = U1IIR) & 0x01) == 0)//Check Flag Status ofRecieve
Interrupt
{
switch(Msg & 0x0E) //Filter Msg
{
case 0x04: while (!(U1LSR & 0x20));
//Recieve DataKey
= U1RBR;
case 0x02: break; // Interruptdefault :
break;
}
}
SERIAL PORT:
OUTPUT:
RESULT:
Thus the real time clock and serial port interfacing with ARM DEVELOPMENT KIT processorhas been executed
successfully.
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
TO INTERFACE WIFI MODULE WITH RASPBERRY PI
The ESP-01 ESP8266 is a serial WIFI Wireless Transceiver Module developed based on ESP8266 SoC withintegrated TCP/IP
protocol stack that can give any microcontroller access to your WiFi network. This Wi-Fi Module is capable of of either hosting an
application or offloading all Wi-Fi networking functions from another application processor.
The ESP-01 ESP8266 module has a powerful onboard processing and storage capabilities that allow it to be integrated with the
sensors and other application specific devices through its GPIOs .
Please note The ESP8266 Module is not capable of 5-3V logic shifting and will require an external LogicLevel Converter.
Please do not power it directly from your 5V dev board.
Table of Contents
802.11 b/g/n
Wi-Fi Direct (P2P), soft-AP
Integrated TCP/IP protocol stack
Integrated TR switch, balun, LNA, power amplifier and matching network
Integrated PLLs, regulators, DCXO and power management units
+19.5dBm output power in 802.11b mode
Power down leakage current of <10uA
1MB Flash Memory
Dimensions: 25 x 15 x 11 mm (LxWxH)
PCB Thickness: 1mm
Weight: 2 gm
Integrated low power 32-bit CPU could be used as application processor
SDIO 1.1 / 2.0, SPI, UART
STBC, 1×1 MIMO, 2×1 MIMO
A-MPDU & A-MSDU aggregation & 0.4ms guard interval
Wake up and transmit packets in < 2ms
Standby power consumption of < 1.0mW (DTIM3)
We have seen previously the interfacing guides for this Wi-Fi Module with Arduino and PIC Microcontroller. In this Tutorial we
will Interface this ESP8266 Wi-Fi Module with Raspberry Pi Pico development board to set up Wi-Fi wireless connectivity. This
Wireless Wi-Fi Connectivity with Pico development board help to facilitate all the IOT prospective features so we can host the data
and Post the data
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
to the server and any API connected over clouds like we can send Sensors reading to the Webserver, SendingData over Email.
Before proceeding further you may look at our previous tutorials for Interfacing ESP-01 ESP8266 Wi-Fimodule.
Recommended Tutorials:
To proceed further with concept of Interfacing the ESP-01 Wi-Fi Module with Raspberry Pi Pico Board weneed to
Refer below tutorials to follow above steps to make our Pico board ready for programming
As the ESP-01 Wi-Fi module communicating over serial bus , the interfacing or connection with Raspberry Pi Pico Development
board will be very easy as we need to used only two UART0 GPIO pins of Pico board. Wewill connect Wi-Fi module at TX(0) pin/
GPIO0 and RX(0) pin/ GPIO1. Refer below Pinout and circuit diagram for your better interfacing.
The following image is the pinout diagram of Raspberry Pi Pico Board , it is 40 pin development board that includes 26-GPIO,
GND, Debug and +5VCC pins. Raspberry Pi Pico GPIOs are the multifunction pins which can be configured or used for the one the
function at a time. Like Digital or Analog configuration.
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
Components Required
Circuit Diagram :
Below is the Circuit diagram for interfacing ESP-01 Wi-Fi Module Module with Pico Board usingMicroPython
programming.
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
MicroPython Script for Interfacing ESP8266 Wi-Fi Module
To know how to program Raspberry Pi Pico board using MicroPython tools please refer below tutorials step by steps:
To establish a communication between ESP8266 module and Raspberry Pi Pico we need to sends AT commands to the ESP8266
module to configure ESP8266 as a TCP web server. In the below MicroPython script we have passed AT commands serially one
by one enable Wi-Fi module so it can communicate with Pico Board and setup a Webserver. To program Raspberry Pi Pico board
we will use uPyCraft IDE , copy thebelow code and save it as a PIco-ESP8266.py.
PIco-ESP8266.py:
import uos
import machine
import utime
print()
print("Machine: \t" + uos.uname()[4])
print("MicroPython: \t" + uos.uname()[3])
def Rx_ESP_Data():
recv=bytes()
while uart0.any()>0:
recv+=uart0.read(1)
res=recv.decode('utf-8')
return res
After Downloading the PIco-ESP8266.py to the Pico board we need to AT commands starts executing sequentially toconfigure
the ESP-01 board as webserver. The response each AT commands will get printed on the Python shell window.
OK
1,CLOSED
CMD: AT+RST
resp:
b'AT+RST\r\r\n\r\nOum 0x2a\r\nload 0x3ffe8000, len 2124, room 8 \r\ntail 4\r\nchksum
0x07\r\nload 0x3ffe8850, len 9276, room 4 \r\ntail
8\r\nch8\x80\x0c\x8es\x88\x03\x8c\xe3No\x83d\x8e\x98l\x130\xec\x0c\x88\x80l\x8es\x88\x03
s\x88\x03\x87\t\x907\xff\r\nready\r\nWIFI CONNECTED\r\n'
CMD: AT+RESTORE
resp:
b'AT+RESTORE\r\r\n\rhksum 0x2a\r\nload 0x3ffe8000, len 2124, room 8 \r\ntail 4\r\nchksum
0x07\r\nload 0x3ffe8850, len 9276, room 420EC512 – EMBEDDED
\r\ntail SYSTEM
8\r\nchksum DESIGN AND IOT
0xba\r\ncsum
0xba\r\n\x8c\xe3No\x83l\x8e\x84l\x130\xec\x0c\x88\x80\x0c\x8es\x88\x03\x8c\xe3No\x83l\x8
e\x8fl\x1b0\xec\x0c\x88\x80\x04\x8es\x88\x03\x84\xe3Ng\x83l\x8e\x90l\x130\xec\x04\x88\x8
0l\x8es\x88\x03s\x88\x03\x8f\t\x907\x03F\xe7\x93N\xe3c\x0c\x88\x83\x84cs\xf1cv\x03c\xc1\
x13N\xe0Io\xe0Io\xc1cNl\x01cx\x7f\x93o\xf0\x13o\xce\x93N\x8c\x03F\x00\x03F\x8f\to\xfc\x0
1cpy\x0c\x88\x8c\x04\x8e\x83\x8c\x8f\x80l\x8e\xe3\x8c\x8f\x8c\xec\x8e\xecl\x8f\xc8d`\t\x
03O\x98\x1b\x03F\xe7\x93N\xe3c\x04\x88\xe3\xec\x8f\xc6\x0cc@\x03O\xe0\x03F\xef\x93N\xe3c
\x0c\x88\x83\x0c\x8e|l\x8es\x88\x03s\x88\x03\r\nready\r\n'
CMD: AT+CWMODE?
resp:
AT+CWMODE?
+CWMODE:2
OK
CMD: AT+CWMODE=1
resp:
AT+CWMODE=1
OK
CMD: AT+CWMODE?
resp:
AT+CWMODE?
+CWMODE:1
OK
CMD: AT+CWJAP="JioFiberhome3G","Micro@123"
resp:
AT+CWJAP="JioFiberhome3G","Micro@123"
WIFI CONNECTED
WIFI GOT IP
OK
CMD: AT+CIFSR
resp:
AT+CIFSR
+CIFSR:STAIP,"192.168.29.83"
+CIFSR:STAMAC,"8c:aa:b5:c4:e6:da"
OK
CMD: AT+CIPMUX=1
resp:
AT+CIPMUX=1
OK
CMD: AT+CIPSERVER=1,80
resp:
AT+CIPSERVER=1,80
OK
Starting connection to ESP8266...
resp:
0,CONNECT
1,CONNECT
+IPD,0,454:GET / HTTP/1.1
Host: 192.168.29.83
Connection: keep-Kit/537.36 (KHTML, like Gecko) Chrome/102.
connectionId:0
20EC512– EMBEDDED SYSTEM DESIGN AND IOT
! Incoming connection - sending webpage
CMD: AT+CIPCLOSE=0
resp:
0,CLOSED10.0; Win64; *,*/*;q=0.8
Referer: http://192.168.29.83/
Accept-Language: en-US,en;q=0.9
Waiting For connection...
Result:
In the result of AT command response in Python shell window we can find the IP address configured andconnected with ESP8266
module. Enter the same IP address in your web browser to get the Webserver response from Pico board using ESP-01 module. It
indicated that our Interfacing of Wi-Fi module on successfully completed and it is ready to send any data like sensor reading over
webserver.