S16: Warriors
Contents
Grading Criteria
- How well is Software & Hardware Design described?
- How well can this report be used to reproduce this project?
- Code Quality
- Overall Report Quality:
- Software Block Diagrams
- Hardware Block Diagrams
- Schematic Quality
- Quality of technical challenges and solutions adopted.
Project Title
WiFi Based Sensor System
Abstract
The most basic aspect of an IoT system is the network of devices/objects. IoT allows objects to be sensed and controlled remotely across existing network infrastructure. This project is based on the same fundamental. SJOne board senses temperature, light intensity, and GPS (SIM800) module. WiFi capability is added to SJOne board using ESP8266 serial module. SJOne(client) transmits the sensor data over the network to the server. Raspberry Pi 3 acts as a server, receives the data from the client and stores it in mysql database. A php webpage takes the most recent entry from database and displays on the webpage along with map.
Objectives
1) Set up sensor hub:
- Interface GPS module with SJOne
- Write drivers to access the temperature and light intensity sensors on-board SJOne
2) Set up TCP Client:
- Interface the WiFi module with SJOne board and implement a TCP client
- Write device driver to transmit data from SJOne client to the server
3) Set up TCP Server:
- Use Raspberry Pi 3 to work as a TCP server to receive data from client
- Create a database to keep a record of previously acquired data
4) Set up Webserver:
- Start the web server and host a webpage
Team Members & Responsibilities
Ankit Gandhi
--> Software Architecture, Rasberry Pi setup, ESP8266 firmware development
Sujeeth Emmadi
--> Software Architecture, Wiki Report, PHP webserver
Bharat Khanna
--> Interface SIM808 with ARM microcontroller (Firmware development), Hardware support
Veena Manasa Kanakamalla
--> Wiki Report, Sensor interface, Hardware Support
Schedule
This section of the report provides the team schedule for the Assembly line project, indicating the milestones to be achieved during the course of the project.
SI No. | Start Date | End Date | Task | Status | Actual Completion Date |
---|---|---|---|---|---|
1 | 03/21/2016 | 03/27/2016 |
|
Completed | |
2 | 03/28/2016 | 04/03/2016 |
|
Completed | |
3 | 04/04/2016 | 04/10/2016 |
|
Completed | |
4 | 04/11/2016 | 04/17/2016 |
|
Completed | |
5 | 04/18/2016 | 04/24/2016 |
|
Completed | |
6 | 04/25/2016 | 05/01/2016 |
|
Completed | |
7 | 05/02/2016 | 05/08/2016 |
|
Completed | |
8 | 05/09/2016 | 05/15/2016 |
|
Completed | |
8 | 05/16/2016 | 05/22/2016 |
|
In Progress |
Parts List & Cost
Item# | Part Description | Vendor | Qty | Cost |
---|---|---|---|---|
1 | Raspberry Pi | Adafruit | 1 | $39.95 |
2 | ESP8266-Wifi Module | Adafruit | 1 | $9.95 |
3 | SIM808 GPS/GSM Module | Adafruit | 1 | $49.95 |
4 | Passive GPS Antenna uFL | Adafruit | 1 | $3.95 |
5 | USB to TTL Serial Cable | Adafruit | 1 | $9.95 |
Design & Implementation
Block Diagram
ESP8266 interface with SJOne
The WiFi module, ESP8266, is interfaced with the SJOne board over the UART. We used the UART3 present on the SJOne board to the UART of ESP8266. The RX pin from ESP8266 is connected to pin P4.28 of SJOne (TX) and TX pin of ESP8266 to pin p4.29 of SJOne(RX).
bool esp8266_wifi::esp8266_init(LPC_UART_TypeDef *UARTx, uint32_t baudrate) { uint16_t baud = 0; const unsigned int pclk = sys_get_cpu_clock(); // Turn on UART3 module LPC_SC->PCONP |= (1 << 25); // Select clock for UART3 PCLK = CCLK LPC_SC->PCLKSEL1 &= ~(2<<18); LPC_SC->PCLKSEL1 |= (1<<18); // Configure UART3 :8-bit character length1 :1 stop bit :Parity Disabled UARTx->LCR = 0x03; // Enable DLAB (DLAB = 1) UARTx->LCR |= (1<<7); // For baudrate 115200 //div = 48000000/16*baudRate;// = 312; //divWord = 48000000/(16*115200); baud = (pclk / (16 * baudrate)); UARTx->DLL = (baud & 0xFF); UARTx->DLM = (baud >> 8); // Disabling DLAB (DLAB =0) UARTx->LCR &= ~(1<<7) ; // Enable & Reset FIFOs and set 4 char timeout for Rx UARTx->FCR = 0x07; UARTx->FCR &= ~(1<<3); // Pin select for P4.28 TXD3 and P4.29 RXD3 LPC_PINCON->PINSEL9 |= ((1<<24) | (1<<25) | (1<<26) | (1<<27)); mUARTx = UARTx; return true; }
SIM808 GPS Module Interface with SJOne
The SIM808 module is interfaced to SJOne using UART. The Transmit and Receive pins of the GPS module are connected to UART2 of SJOne. RX pin of GPS is connected to pin P2.8 of SJOne (TX) and TX pin of GPS is connected to pin P2.9 of SJOne (RX).
bool sim808_gps::sim808_gpsInit(LPC_UART_TypeDef *UARTx, uint32_t baudrate) { uint16_t baud = 0; const unsigned int pclk = sys_get_cpu_clock(); gUartSemaphore = xSemaphoreCreateBinary(); // Turn on UART2 module LPC_SC->PCONP |= (1 << 24); // Select clock for UART2 PCLK = CCLK LPC_SC->PCLKSEL1 &= ~(2<<16); LPC_SC->PCLKSEL1 |= (1<<16); // Configure UART2 :8-bit character length1 :1 stop bit :Parity Disabled UARTx->LCR = 0x03; // Enable DLAB (DLAB = 1) UARTx->LCR |= (1<<7); // For baudrate 115200 //div = 48000000/16*baudRate;// = 312; //divWord = 48000000/(16*115200); baud = (pclk / (16 * baudrate)); UARTx->DLL = (baud & 0xFF); UARTx->DLM = (baud >> 8); // Disabling DLAB (DLAB =0) UARTx->LCR &= ~(1<<7) ; // Enable & Reset FIFOs and set 4 char timeout for Rx UARTx->FCR = 0x07; UARTx->FCR |= (3<<6); //UARTx->FCR &= ~(1<<3); // Pin select for P2.8 TXD2 and P2.9 RXD2 LPC_PINCON->PINSEL4 &= ~((1<<16) | (1<<18)); LPC_PINCON->PINSEL4 |= ((1<<17) | (1<<19)); // Pin select for P4.28 TXD3 and P4.29 RXD3 //LPC_PINCON->PINSEL9 |= ((1<<24) | (1<<25) | (1<<26) | (1<<27)); NVIC_EnableIRQ(UART2_IRQn); UARTx->IER = (1 << 0) | (1 << 2); // B0:Rx, B1: Tx sim808_reset(LPC_GPIO0, GPS_RESET_PIN); printf("Starting communication\n"); mUARTx = UARTx; return true; }
Hardware Interface
The hardware design includes PCB designing using cadsoft Eagle(software for PCB board designing). The circuit of developed PCB board includes interfacing peripheral like SIM808(GSM/GPS module), ESP826( Wi-Fi module), LSM303(Accelerometer & Magnetometer) with ARM cortex-M3 microcontroller and raspberry Pi. I2C, UART and TCP/IP are the three communication protocols that are being used in the project for establishing communication between temperature/light sensor, SIM808/ESP8266 & raspberry pi and ARM microcontroller respectively.
Software Design
The software has been developed on FreeRTOS using C/C++ programming language including features of real-time embedded system. The software involves device driver development for I2C and UART protocol which are used to establish communication between SIM808(GSM/GPS module) & ESP8266(Wi-Fi) with the microcontroller. The code also includes implementation of fetching data like latitude & longitude of the current location, temperature, and luminosity at every timestamp. The data that is being collected on real time basis from the peripheral devices is continuously transmitted to the server(Raspberry Pi) by ESP8266 module using TCP/IP protocol. Socket programming is written on the server(Raspberry Pi) which is continuously listening to the ESP8266 module. On receiving data from the client(Microcontroller) the data is being manipulated and is being able to be displayed on the user-friendly web page using PHP language.
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Testing & Technical Challenges
Describe the challenges of your project.
- First and very important aspect for any project is requirement gathering.
Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
Issues
#1 LPC17xx UART Rx FIFO
- LPC17xx UART not able to receive more than 16 bytes
- Resolution :
- Used interuppt to solve this problem.
Conclusion
The project is based on embedded platform, implementing the concepts of semaphore, Task scheduling, queues etc. Addendum to this we have also implemented features of networking like socket programming and interfacing our output with a user-friendly interface on the web page using Internet of Things. This project helped us in learning a complete embedded application from hardware design till user interface that can be used at a commercial level.
Project Video
Upload a video of your project and post the link here.
Project Source Code
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
Appendix
You can list the references you used.