Difference between revisions of "S16: Warriors"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Design & Implementation)
(Testing & Technical Challenges)
 
(322 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Grading Criteria ===
+
== Wifi based sensor system ==
<font color="green">
+
This is an IoT based sensor system which allows sensor data to be accessed over the internet from anywhere.
*  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.
 
</font>
 
  
== Project Title ==
+
== Abstract ==
Internet of Things based GPS Tracking System
+
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.
  
== Abstract ==
+
== Objectives ==
A GPS & GSM Based Vehicle Tracking combine the installation of an electronic device in a vehicle, with purpose-designed computer software to enable the company to track the vehicle's location. We are using Global Positioning System (GPS) technology for locating the vehicle. Vehicle information can be viewed in Web application.
+
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
  
== Objectives & Introduction ==
+
3) Set up TCP Server:
Show list of your objectives.  This section includes the high level details of your project.  You can write about the various sensors or peripherals you used to get your project completed.
+
* 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 web page 
 +
   
  
 
=== Team Members & Responsibilities ===
 
=== Team Members & Responsibilities ===
*  Sujeeth Emmadi
+
'''Ankit Gandhi'''
** 
+
 
Bharat Khanna
+
--> Software Architecture, Raspberry Pi setup, ESP8266 firmware development
** 
+
 
* Veena Manasa Kanakamalla
+
'''Bharat Khanna'''
** 
+
 
*  Ankit Gandhi
+
--> Device driver development for SIM808/ESP8266 for ARM microcontroller, PCB designing
** Rasberry Pi environment setup, Hardware support
+
 
 +
'''Sujeeth Emmadi'''
 +
 
 +
--> Software Architecture, Wiki Report, PHP web server
 +
   
 +
'''Veena Manasa Kanakamalla'''
 +
 
 +
--> Wiki Report, Sensor interface, Hardware Support
  
 
== Schedule ==
 
== 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.
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 49: Line 57:
 
*Parts and components identification and ordering
 
*Parts and components identification and ordering
 
| Completed
 
| Completed
|  
+
| 03/27/2016
 
|-
 
|-
 
! scope="row"| 2
 
! scope="row"| 2
Line 57: Line 65:
 
*Design of Software Architecture(Flow diagram)
 
*Design of Software Architecture(Flow diagram)
 
| Completed
 
| Completed
|  
+
| 04/03/2016
 
|-
 
|-
 
! scope="row"| 3
 
! scope="row"| 3
Line 63: Line 71:
 
| 04/10/2016
 
| 04/10/2016
 
|  
 
|  
*Firmware Development for I2C(Temperature Sensor) and GPS  
+
*Device deiver development for I2C(Temperature Sensor) and UART(GPS) communication protocol
 
*Testing of individual module
 
*Testing of individual module
 
| Completed
 
| Completed
|  
+
| 04/10/2016
 
|-
 
|-
 
! scope="row"| 4
 
! scope="row"| 4
Line 72: Line 80:
 
| 04/17/2016
 
| 04/17/2016
 
|  
 
|  
*Wifi firmware development on LPC
+
*Device Driver development for ESP8266(Wi-Fi module) on ARM microcontroller
 
| Completed
 
| Completed
|  
+
| 04/20/2016
 
|-
 
|-
 
! scope="row"| 5
 
! scope="row"| 5
Line 80: Line 88:
 
| 04/24/2016
 
| 04/24/2016
 
|  
 
|  
*Wifi Application development on Raspberry PI
+
*Socket programming on server(Raspberry Pi) to communicate between microcontroller and server.
 
| Completed
 
| Completed
|  
+
| 04/24/2016
 
|-
 
|-
 
! scope="row"| 6
 
! scope="row"| 6
Line 90: Line 98:
 
*Webserver development on Raspberry PI
 
*Webserver development on Raspberry PI
 
| Completed
 
| Completed
|  
+
| 05/01/2016
 
|-
 
|-
 
! scope="row"| 7
 
! scope="row"| 7
Line 96: Line 104:
 
| 05/08/2016
 
| 05/08/2016
 
|  
 
|  
*Integration of all modules, Testing and debugging of the system
+
*Integration of all modules  
| In Progress
+
| Completed
|  
+
| 05/08/2016
 
|-
 
|-
 
! scope="row"| 8
 
! scope="row"| 8
Line 104: Line 112:
 
| 05/15/2016
 
| 05/15/2016
 
|  
 
|  
*Final testing and Documentation
+
*Testing and debugging
| In Progress
+
| Completed
|  
+
| 05/20/2016
 
|-
 
|-
 
|-
 
|-
Line 113: Line 121:
 
| 05/22/2016
 
| 05/22/2016
 
|  
 
|  
*Final testing and Wiki Report
+
* Report writting
| In Progress
+
| Completed
|  
+
| 05/23/2016
 
|-
 
|-
 
|}
 
|}
Line 161: Line 169:
  
 
== Design & Implementation ==
 
== Design & Implementation ==
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
+
   
[[File:Block.png|center|400px|caption]]
+
=== System Block Diagram ===
 +
----
 +
[[File:Cmpe244 warriors blockdiagram.jpg|center|500px|border]]
 +
 
 +
===Components===
 +
----
 +
==== SJOne Board ====
 +
----
 +
[[File:Cmpe244_warriors_sjone_board.jpg‎|left|200px|thumb|SJOne board]]
 +
 
  
=== Hardware Design ===
 
<u> ''' Raspberry Pi ''' </u>
 
: Raspberry Pi is powered with Broadcom BCM2837 1.2GHz 64-bit quad-core ARMv8 processor.
 
: Integrated 802.11n wireless LAN
 
:
 
: Raspberry Pi is used as Web Server
 
  
<u> ''' SIM808 GPS/GSM Module ''' </u>
+
*Powered by ARM Cortex-M3
: Raspberry Pi is powered with Broadcom BCM2837 1.2GHz 64-bit quad-core ARMv8 processor.
+
*On board Temperature Sensor and light sensor.
: Integrated 802.11n wireless LAN
+
*Many GPIOs with two SPI, Multiple UARTs, and I2C availability.
:
+
*Power from USB or External Power.
: Raspberry Pi is used as Web Server
 
  
<u> ''' ESP8266 Wifi Module ''' </u>
+
 
: Raspberry Pi is powered with Broadcom BCM2837 1.2GHz 64-bit quad-core ARMv8 processor.
+
The SJOne board offers whole lot of features out of which the temperature sensor, light intensity sensor and UART interfaces are utilized for the project.
: Integrated 802.11n wireless LAN
+
 
:
+
==== The WiFi Module - ESP8266 ====
: Raspberry Pi is used as Web Server
+
----
 +
[[File:Cmpe244 warriors esp8266.jpg ‎|right|200px|thumb|ESP8266]]
 +
 
 +
 
 +
The features of ESP8266 are:
 +
 
 +
*1 x Analog input (1.8V max)
 +
*9 x GPIO (3.3V logic), which can also be used for I2C or SPI
 +
*2 x UART pins
 +
*2 x 3-12V power inputs, reset, enable, LDO-disable, 3.3V output
 +
 
 +
 
 +
We have used UART for communication in our project.
 +
 
 +
==== SIM808 GPS Module====
 +
----
 +
[[File:Sim808.jpg ‎|left|200px|thumb|SIM808]]
 +
 
 +
 
 +
SIM 808 MiniGSM + GPS, an all-in-one cellular phone module which provides location-tracking, voice, text, SMS and data facilities
 +
 
 +
*  Quad-band 850/900/1800/1900MHz
 +
*  AT command interface with "auto baud" detection
 +
*  22 tracking / 66 acquisition channels
 +
*  Sensitivity: Tracking: -165 dBm, Cold starts : -147 dBm
 +
*  Accuracy: approx 2.5 meters
 +
 
 +
==== Raspberry Pi 3 ====
 +
----
 +
[[File:Raspberry pi3.jpg ‎|right|200px|thumb|Raspberry Pi]]
 +
 
 +
 
 +
* A 1.2GHz 64-bit quad-core ARMv8 CPU with 1 GB RAM
 +
* On board 802.11n Wireless LAN
 +
* 40 GPIO pins and many serial interfaces
 +
* Micro SD card slot
 +
* On board chip antenna for radio
 +
 
 +
 
 +
 
 +
The Raspberry Pi 3 is the third generation Raspberry Pi. In this project raspberry pi is used as webserver.
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===
In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the '''Software Design''' section is isolated to talk about high level workings rather than inner working of your project.
+
----
 +
The hardware design includes PCB designing using cadsoft Eagle(software for PCB board designing).  The circuit design of PCB includes SIM808(GSM/GPS module) and ESP826( Wi-Fi module) which is connected to ARM cortex-M3 microcontroller. Onboard sensors of SJOne board like TEMT6000X01(light sensor) and TMP102(temperature sensor) are also used to collect data. I2C, UART and TCP/IP are the three communication protocols that are being used in the project for establishing communication of temperature/light sensor, SIM808/ESP8266 & raspberry pi with ARM microcontroller respectively.
 +
 
 +
==== ESP8266 interface with SJOne ====
 +
----
 +
The WiFi module(ESP8266) is interfaced with the SJOne board(ARM microcontroller) using UART3 bus. Pin number '''p4.28''' and '''p4.29''' is used as RX and TX respectively.
 +
 
 +
==== SIM808 GPS Module Interface with SJOne ====
 +
----
 +
The SIM808 module is interfaced with SJOne using UART protocol. 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 board (TX) and TX pin of GPS is connected to pin '''P2.9''' of SJOne (RX).
 +
 
 +
=== Software Design & Implementation  ===
 +
----
 +
: System consists of two entities. A client and a server.
 +
[[File:cmpr244_warriors_flowchart.png|400pk|border|center|Flowchart]]
 +
==== Client ====
 +
----
 +
 
 +
On the Client side, SJOne(ARM Cortex-M3) is interfaced with the sensors(temperature, light, latitude, longitude, time etc). It collects the data from sensors at regular interval and sends the received data to the server over WiFi.
 +
 
 +
The client software is written on FreeRTOS using C/C++, including features of real-time embedded system, which is implemented using two tasks.
 +
 
 +
'''sensorTask'''
 +
 
 +
:This task takes sensor readings at regular intervals (3 milliseconds) (light, temperature, time, latitude, longitude, and time) and stores in a structure
 +
:And then calls the semaphoregive API which signals the higher priority WiFi task.
 +
 
 +
 
 +
'''wifitask (Higher priority task than sensor task)'''
 +
 
 +
:In the initialization it configures the ESP8266 for WiFi communication and connects to a predefined WiFi network and the server.
 +
:Then it waits for the semaphore from sensor task. Once signaled by sensor task, sends the data to the server.
 +
 
 +
 
 +
 
 +
'''Pseudo code for client'''
 +
<pre>
 +
sensorTask() {
 +
:readSensorData();
 +
:xSemaphoreGive();
 +
:delay();
 +
}</pre>
 +
 
 +
<pre>wifiTask() {
 +
:xSemaphoreTake();
 +
:sendData();
 +
}</pre>
 +
 
 +
<pre>main() {
 +
:xSemaphoreCreateBinary();
 +
:addtask(sensorTask, medium_priority);
 +
:addtask(wifiTask, high_priority);
 +
:start_scheduler();
 +
}</pre>
 +
 
 +
==== Server ====
 +
----
 +
Raspberry pi is used as TCP and web server. TCP server listens for client connection request, once connected, the server reads the data and stores it into MySQL database. Then web server reads the latest sensor values from the database and displays on the web page and plots the latitude and longitude using google maps.
 +
 
 +
Environmet setup requires installation of '''apache''', '''mysql''' and '''php''' on the board.
 +
 
 +
These commands can be used for installation
 +
 
 +
<pre>
 +
:sudo apt-get install apache2 -y
 +
:sudo apt-get install php5 libapache2-mod-php5 -y
 +
:sudo apt-get install php5-mysql
 +
</pre>
 +
 
 +
For Wifi network setup
 +
 +
pi@raspberrypi: sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
  
=== Software Design ===
+
And then put your ssid and password as follows
Show your software design.  For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level.  Do not show the details of the code.  For example, do not show exact code, but you may show psuedocode and fragments of code.  Keep in mind that you are showing DESIGN of your software, not the inner workings of it. 
 
  
=== Implementation ===
+
<pre>network={
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.
+
:ssid="your_ssid"
 +
:psk="password"
 +
}</pre>
  
== 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:
+
''' There are two modules on server side '''
  
=== My Issue #1 LPC17xx UART Rx FIFO ===
+
''' TCP server'''
:''' LPC17xx UART not able to receive more than 16 bytes'''
+
:'''Resolution ''':  
+
: TCP server connects to TCP client, receives the data and stores into the database.
:: Inside the interrupt reading as much data as available
+
: It is written in C. It uses TCP socket to accept client requests and receive the sensor data.
 +
 
 +
''' Web server'''
 +
: Web server reads data from database and display on the web page. It is written in PHP.
 +
: Google maps APIs are used latitude,longitude plotting.
 +
 
 +
'''Pseudo code for TCP server'''
 +
 
 +
<pre>main() {
 +
:createsocket(socket);
 +
:bind(socket);
 +
:listen(socket);
 +
:accept(socket);
 +
:readData(socket);
 +
:insertDataMysqlDatabase();
 +
}</pre>
 +
 
 +
== Testing & Technical Challenges =
 +
* First and very important step in any project is requirement gathering.
 +
* A good amount of time should be spent on Software and Hardware design. Once the on paper design is ready it makes the development phase very smooth. 
 +
* Once the development is done testing (individual and as a whole system ) also very important.
 +
* Wifi client module can be tested usb to serial cable with PC. From PC terminal we can give the AT commands and check the responses. Further testing requires a TCP server, which can respond to the requests. This can be implemented using Hercules utility. 
 +
* GPS module can also be tested in the same manner using  usb to serial cable with PC. From PC terminal we can give the AT commands and check the responses.
 +
* From client side GET/POST query can be used which will eliminate the requirement of TCP server.
 +
 
 +
===  '''Issues'''    ===
 +
 
 +
# '''LPC17xx UART Rx FIFO '''
 +
: LPC17xx UART not able to receive more than 16 bytes
 +
:Resolution :  
 +
:: Used interrupt to solve this problem.
  
 
== Conclusion ==
 
== Conclusion ==
Conclude your project here. You can recap your testing and problems.  You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
+
Facing issues such as UART FIFO size and power requirements, allowed us to understand that our knowledge over several aspects, when it came to depth, was lacking. Solving these problems, helped us understand those concepts better but, more importantly, we gained experience on how to approach situations where the project gets stuck.  
 +
 
 +
The concepts that we have worked on, and now understand better, in this project are:
 +
* Setting up TCP server-clients
 +
* Interfacing sensors using UART
 +
* Configuration of Interrupts
 +
* Understanding WiFi technology
 +
* Making use of AT commands
 +
* Socket Programming
  
 
=== Project Video ===
 
=== Project Video ===
Upload a video of your project and post the link here.
+
[https://www.youtube.com/watch?v=ILiFeN9xiJ8| Project video]
  
 
=== Project Source Code ===
 
=== Project Source Code ===
[https://sourceforge.net/projects/sjsu/files/CmpE_S2016/ Sourceforge Source Code Link]
+
Visit this link [https://sourceforge.net/projects/wifi-sensor-system/files/?source=navbar Sourceforge]
  
 
== References ==
 
== References ==
=== Acknowledgement ===
 
Any acknowledgement that you may wish to provide can be included here.
 
 
=== References Used ===
 
List any references used in project.
 
  
=== Appendix ===
+
* [https://cdn-shop.adafruit.com/datasheets/SIM808_Hardware+Design_V1.00.pdf Adafruit-SIM808]
You can list the references you used.
+
* [https://cdn-learn.adafruit.com/downloads/pdf/adafruit-huzzah-esp8266-breakout.pdf Adafruit-ESP8266]
 +
* [https://github.com/adafruit/Adafruit_ESP8266 Adafruit_ESP8266_Github]
 +
* [https://github.com/adafruit/Adafruit_FONA Adafruit_SIM808_Github]

Latest revision as of 23:25, 24 May 2016

Wifi based sensor system

This is an IoT based sensor system which allows sensor data to be accessed over the internet from anywhere.

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 web page


Team Members & Responsibilities

Ankit Gandhi

--> Software Architecture, Raspberry Pi setup, ESP8266 firmware development

Bharat Khanna

--> Device driver development for SIM808/ESP8266 for ARM microcontroller, PCB designing

Sujeeth Emmadi

--> Software Architecture, Wiki Report, PHP web server

Veena Manasa Kanakamalla

--> Wiki Report, Sensor interface, Hardware Support

Schedule

SI No. Start Date End Date Task Status Actual Completion Date
1 03/21/2016 03/27/2016
  • System design and High level Block diagram
  • Parts and components identification and ordering
Completed 03/27/2016
2 03/28/2016 04/03/2016
  • Design of Software Architecture(Flow diagram)
Completed 04/03/2016
3 04/04/2016 04/10/2016
  • Device deiver development for I2C(Temperature Sensor) and UART(GPS) communication protocol
  • Testing of individual module
Completed 04/10/2016
4 04/11/2016 04/17/2016
  • Device Driver development for ESP8266(Wi-Fi module) on ARM microcontroller
Completed 04/20/2016
5 04/18/2016 04/24/2016
  • Socket programming on server(Raspberry Pi) to communicate between microcontroller and server.
Completed 04/24/2016
6 04/25/2016 05/01/2016
  • Webserver development on Raspberry PI
Completed 05/01/2016
7 05/02/2016 05/08/2016
  • Integration of all modules
Completed 05/08/2016
8 05/09/2016 05/15/2016
  • Testing and debugging
Completed 05/20/2016
8 05/16/2016 05/22/2016
  • Report writting
Completed 05/23/2016

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

System Block Diagram


Cmpe244 warriors blockdiagram.jpg

Components


SJOne Board


SJOne board


  • Powered by ARM Cortex-M3
  • On board Temperature Sensor and light sensor.
  • Many GPIOs with two SPI, Multiple UARTs, and I2C availability.
  • Power from USB or External Power.


The SJOne board offers whole lot of features out of which the temperature sensor, light intensity sensor and UART interfaces are utilized for the project.

The WiFi Module - ESP8266


ESP8266


The features of ESP8266 are:

  • 1 x Analog input (1.8V max)
  • 9 x GPIO (3.3V logic), which can also be used for I2C or SPI
  • 2 x UART pins
  • 2 x 3-12V power inputs, reset, enable, LDO-disable, 3.3V output


We have used UART for communication in our project.

SIM808 GPS Module


SIM808


SIM 808 MiniGSM + GPS, an all-in-one cellular phone module which provides location-tracking, voice, text, SMS and data facilities

  • Quad-band 850/900/1800/1900MHz
  • AT command interface with "auto baud" detection
  • 22 tracking / 66 acquisition channels
  • Sensitivity: Tracking: -165 dBm, Cold starts : -147 dBm
  • Accuracy: approx 2.5 meters

Raspberry Pi 3


Raspberry Pi


  • A 1.2GHz 64-bit quad-core ARMv8 CPU with 1 GB RAM
  • On board 802.11n Wireless LAN
  • 40 GPIO pins and many serial interfaces
  • Micro SD card slot
  • On board chip antenna for radio


The Raspberry Pi 3 is the third generation Raspberry Pi. In this project raspberry pi is used as webserver.

Hardware Interface


The hardware design includes PCB designing using cadsoft Eagle(software for PCB board designing). The circuit design of PCB includes SIM808(GSM/GPS module) and ESP826( Wi-Fi module) which is connected to ARM cortex-M3 microcontroller. Onboard sensors of SJOne board like TEMT6000X01(light sensor) and TMP102(temperature sensor) are also used to collect data. I2C, UART and TCP/IP are the three communication protocols that are being used in the project for establishing communication of temperature/light sensor, SIM808/ESP8266 & raspberry pi with ARM microcontroller respectively.

ESP8266 interface with SJOne


The WiFi module(ESP8266) is interfaced with the SJOne board(ARM microcontroller) using UART3 bus. Pin number p4.28 and p4.29 is used as RX and TX respectively.

SIM808 GPS Module Interface with SJOne


The SIM808 module is interfaced with SJOne using UART protocol. 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 board (TX) and TX pin of GPS is connected to pin P2.9 of SJOne (RX).

Software Design & Implementation


System consists of two entities. A client and a server.
Flowchart

Client


On the Client side, SJOne(ARM Cortex-M3) is interfaced with the sensors(temperature, light, latitude, longitude, time etc). It collects the data from sensors at regular interval and sends the received data to the server over WiFi.

The client software is written on FreeRTOS using C/C++, including features of real-time embedded system, which is implemented using two tasks.

sensorTask

This task takes sensor readings at regular intervals (3 milliseconds) (light, temperature, time, latitude, longitude, and time) and stores in a structure
And then calls the semaphoregive API which signals the higher priority WiFi task.


wifitask (Higher priority task than sensor task)

In the initialization it configures the ESP8266 for WiFi communication and connects to a predefined WiFi network and the server.
Then it waits for the semaphore from sensor task. Once signaled by sensor task, sends the data to the server.


Pseudo code for client

sensorTask() {
:readSensorData();
:xSemaphoreGive();
:delay(); 
}
wifiTask() {
:xSemaphoreTake();
:sendData();
}
main() {
:xSemaphoreCreateBinary();
:addtask(sensorTask, medium_priority);
:addtask(wifiTask, high_priority);
:start_scheduler();
}

Server


Raspberry pi is used as TCP and web server. TCP server listens for client connection request, once connected, the server reads the data and stores it into MySQL database. Then web server reads the latest sensor values from the database and displays on the web page and plots the latitude and longitude using google maps.

Environmet setup requires installation of apache, mysql and php on the board.

These commands can be used for installation

:sudo apt-get install apache2 -y
:sudo apt-get install php5 libapache2-mod-php5 -y
:sudo apt-get install php5-mysql

For Wifi network setup

pi@raspberrypi: sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

And then put your ssid and password as follows

network={
:ssid="your_ssid"
:psk="password" 
}


There are two modules on server side

TCP server

TCP server connects to TCP client, receives the data and stores into the database.
It is written in C. It uses TCP socket to accept client requests and receive the sensor data.

Web server

Web server reads data from database and display on the web page. It is written in PHP.
Google maps APIs are used latitude,longitude plotting.

Pseudo code for TCP server

main() {
:createsocket(socket);
:bind(socket);
:listen(socket);
:accept(socket);
:readData(socket);
:insertDataMysqlDatabase();
}

Testing & Technical Challenges

  • First and very important step in any project is requirement gathering.
  • A good amount of time should be spent on Software and Hardware design. Once the on paper design is ready it makes the development phase very smooth.
  • Once the development is done testing (individual and as a whole system ) also very important.
  • Wifi client module can be tested usb to serial cable with PC. From PC terminal we can give the AT commands and check the responses. Further testing requires a TCP server, which can respond to the requests. This can be implemented using Hercules utility.
  • GPS module can also be tested in the same manner using usb to serial cable with PC. From PC terminal we can give the AT commands and check the responses.
  • From client side GET/POST query can be used which will eliminate the requirement of TCP server.

Issues

  1. LPC17xx UART Rx FIFO
LPC17xx UART not able to receive more than 16 bytes
Resolution :
Used interrupt to solve this problem.

Conclusion

Facing issues such as UART FIFO size and power requirements, allowed us to understand that our knowledge over several aspects, when it came to depth, was lacking. Solving these problems, helped us understand those concepts better but, more importantly, we gained experience on how to approach situations where the project gets stuck.

The concepts that we have worked on, and now understand better, in this project are:

  • Setting up TCP server-clients
  • Interfacing sensors using UART
  • Configuration of Interrupts
  • Understanding WiFi technology
  • Making use of AT commands
  • Socket Programming

Project Video

Project video

Project Source Code

Visit this link Sourceforge

References