Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanShakir committed Oct 13, 2021
1 parent 2aa4a2d commit 1c3e38c
Showing 1 changed file with 66 additions and 75 deletions.
141 changes: 66 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@

[![Status](https://img.shields.io/badge/status-active-success.svg)]()


</div>

---


<p align="center"> SmartAgri
<br>
</p>


## 📝 Table of Contents

- [About](#about)
Expand All @@ -33,7 +30,6 @@
- [Built Using](#built_using)
- [Authors](#authors)


## 🧐 About <a name = "about"></a>

This repo contains
Expand All @@ -45,8 +41,6 @@ This repo contains

for Smart SmartAgri.



## Getting Started <a name = "getting_started"></a>

These instructions will get you a copy of the project up and running on your system.
Expand All @@ -67,40 +61,37 @@ A step by step series that tell you how to get the Firmware and Backend running

You should have Arduino IDE Installed

1. Add ESP32 Board to your Arduino IDE
1. In your Arduino IDE, go to File> Preferences
Installing ESP32 Add-on in Arduino IDE Windows, Mac OS X, Linux open preferences
2. Enter ```https://dl.espressif.com/dl/package_esp32_index.json```
into the “Additional Board Manager URLs” field then, click the “OK” button:
Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma(each board will go to neaw line) as follows:
```https://dl.espressif.com/dl/package_esp32_index.json,\n http://arduino.esp8266.com/stable/package_esp8266com_index.json```


2. Open the Boards Manager. Go to Tools > Board > Boards Manager…
3. Search for ESP32 and press install button for the ESP32 by Espressif Systems“:
4. That’s it. It should be installed after a few seconds.
5. In your Arduino sketchbook directory, create tools directory if it doesn't exist yet.
6. Unpack the tool into tools directory(present in libs/ESP32FS-1.0.zip) (the path will look like <home_dir>/Arduino/tools/ESP32FS/tool/esp32fs.jar).
7. Close and re-open the Arduino IDE.

8. Now copy the contents of the libs folder to the libraries directory of your Arduino
1. If you are using windows, the libraries directory will be Documents/Arduino/libraries
1. Add ESP32 Board to your Arduino IDE
1. In your Arduino IDE, go to File> Preferences
Installing ESP32 Add-on in Arduino IDE Windows, Mac OS X, Linux open preferences
1. Enter `https://dl.espressif.com/dl/package_esp32_index.json`
into the “Additional Board Manager URLs” field then, click the “OK” button:
Note: if you already have the ESP32 boards URL, you can separate the URLs with a comma(each board will go to neaw line) as follows:
`https://dl.espressif.com/dl/package_esp32_index.json,\n http://arduino.esp8266.com/stable/package_esp8266com_index.json`

1. Open the Boards Manager. Go to Tools > Board > Boards Manager…
1. Search for ESP32 and press install button for the ESP32 by Espressif Systems“:
1. That’s it. It should be installed after a few seconds.
1. In your Arduino sketchbook directory, create tools directory if it doesn't exist yet.
1. Unpack the tool into tools directory(present in libs/ESP32FS-1.0.zip) (the path will look like <home_dir>/Arduino/tools/ESP32FS/tool/esp32fs.jar).
1. Close and re-open the Arduino IDE.

1. Now copy the contents of the libs folder to the libraries directory of your Arduino
1. If you are using windows, the libraries directory will be Documents/Arduino/libraries

##### ESP32 Node FW Uploading
1. Select ESP32 Dev Module from Tools->Board->ESP32
2. Select the correct port from Tools->Port
3. Then open Firmware.ino file,
4. Select Tools > ESP32 Sketch Data Upload menu item. This should start uploading the files into ESP32 flash file system.
5. Now Upload the Code to your ESP32 Dev Module.
6. Your ESP32 is now ready to be used.

1. Select ESP32 Dev Module from Tools->Board->ESP32
2. Select the correct port from Tools->Port
3. Then open Firmware.ino file,
4. Select Tools > ESP32 Sketch Data Upload menu item. This should start uploading the files into ESP32 flash file system.
5. Now Upload the Code to your ESP32 Dev Module.
6. Your ESP32 is now ready to be used.

## Circuit <a name = "circuit"></a>


### ESP32 Dev Module Pinout


Follow the pinout diagram given below to connect different components to your ESP32 Dev Module board.

![Pinout](Circuit/ESP32-Pinout.jpg)
Expand All @@ -111,12 +102,11 @@ Here's the complete circuit diagram of the system.

![CircuitDiagram](Circuit/Circuit_bb.png)


## Server Details <a name = "server"></a>

```diff
```diff
- [THIS SETCTION WILL BE IMPLEMENTED/UPDATED IN THE UPCOMING MILESTONES]
````
```

### Monitoring

Expand All @@ -131,6 +121,7 @@ Here's the complete circuit diagram of the system.
- ufw
- mongod
- mongo-express

### Version Details

- Node v12.16.1
Expand All @@ -139,45 +130,53 @@ Here's the complete circuit diagram of the system.
### Server Links <a name = "srv"></a>

- MQTT Broker Link: hivemq.com
- Backend Link:
- Frontend Link:
- Backend Link: http://sensors.production.rehanshakir.com/
- Frontend Link:

### Backend

- Backend is based on NodeJS and it is being managed by PM2. It starts automatically on server start.

## MQTT Topic Details <a name = "mqtt"></a>
```diff

```diff
- [THIS SETCTION WILL BE IMPLEMENTED/UPDATED IN THE UPCOMING MILESTONES]
````
```

### Topics List

#### Logs

1. <span style="color: green">smart-agri/logs</span> `(all log messages are published to this topic) READ-ONLY`

#### Fimrware

1. <span style="color: green">smart-agri/deviceExists</span> `(Publish DeviceMAC on this topic to check if device exisits in DB) WRITE-ONLY`
1. <span style="color: green">smart-agri/deviceExistance</span> `(Response from the above command {null or device MAC}) READ-ONLY`
2.
3. <span style="color: green">smart-agri/createNew</span> `(Publish data to create a new device in DB.) WRITE-ONLY`
2.
3. <span style="color: green">smart-agri/createNew</span> `(Publish data to create a new device in DB.) WRITE-ONLY`


- Data Format: DeviceMAC;SENSORS_LIST

4. <span style="color: green">smart-agri/updateDevice</span> `(Publish data to update a device in DB based on its MAC Address.) WRITE-ONLY`
- Data Format: DeviceMAC;SENSORS_LIST


## API Details <a name = "api"></a>
```diff
- [THIS SETCTION WILL BE IMPLEMENTED/UPDATED IN THE UPCOMING MILESTONES]
````

```diff
- Routes
* /api/users
* /api/mqtt
```

<!-- ### Admin Login
```http
POST http://34.214.65.82:8080/v1/loginAdmin
```
| Parameter | Type | Description |
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `Email` | `string` | **Required**. *Email address of the admin*|
| `Password` | `string` | **Required**. *Password of the admin*|
Expand All @@ -188,7 +187,7 @@ POST http://34.214.65.82:8080/v1/loginAdmin
POST http://34.214.65.82:8080/v1/updateAdmin
```
| Parameter | Type | Description |
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `Email` | `string` | **Required**. *Email address of the admin*|
| `Password` | `string` | **Required**. *Password of the admin*|
Expand All @@ -199,7 +198,7 @@ POST http://34.214.65.82:8080/v1/updateAdmin
GET http://34.214.65.82:8080/v1/listAll
```
| Parameter | Type | Description |
| Parameter | Type | Description |
| :--- | :--- | :--- |
```nothing```
Expand All @@ -209,7 +208,7 @@ GET http://34.214.65.82:8080/v1/listAll
POST http://34.214.65.82:8080/v1/ledgerLog
```
| Parameter | Type | Description |
| Parameter | Type | Description |
| :--- | :--- | :--- |
```nothing```
Expand All @@ -219,7 +218,7 @@ POST http://34.214.65.82:8080/v1/ledgerLog
POST http://34.214.65.82:8080/v1/addNewDevice
```
| Parameter | Type | Description |
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `DeviceMAC` | `string` | **Required**. *Email address of the Device*|
| `StartSession` | `string` | **Required**. *StartSession of the Device*|
Expand All @@ -235,11 +234,11 @@ POST http://34.214.65.82:8080/v1/addNewDevice
| `PresencePhases` | `string` | **Required**. *PresencePhases of the Device*|
| `Timestamp` | `string` | **NOT Required**. *Timestamp of the Device*| -->


### Responses
```diff

```diff
- [THIS SETCTION WILL BE IMPLEMENTED/UPDATED IN THE UPCOMING MILESTONES]
````
```

Many API endpoints return the JSON representation of the resources created or edited. However, if an invalid request is submitted, or some other error occurs, Gophish returns a JSON response in the following format:

Expand All @@ -249,22 +248,22 @@ Many API endpoints return the JSON representation of the resources created or ed
"message" : string
}
```

The `message` attribute contains a message commonly used to indicate errors or to return the logged status/

The `status` attribute describes if the transaction was successful or not.


### Status Codes

IoTManagementSystem Backend returns the following status codes in its API:

| Status Code | Description |
| :--- | :--- |
| 200 | `OK` |
| 201 | `CREATED` |
| 400 | `BAD REQUEST` |
| 404 | `NOT FOUND` |
| 500 | `INTERNAL SERVER ERROR` |
| Status Code | Description |
| :---------- | :---------------------- |
| 200 | `OK` |
| 201 | `CREATED` |
| 400 | `BAD REQUEST` |
| 404 | `NOT FOUND` |
| 500 | `INTERNAL SERVER ERROR` |

## Usage <a name = "usage"></a>

Expand All @@ -276,20 +275,14 @@ IoTManagementSystem Backend returns the following status codes in its API:

Dashboard Login Page![SCRD1](Circuit/scrd1.png)
Dashboard Home Page![SCRD2](Circuit/scrd2.png)
Dashboard Profile Page![SCRD3](Circuit/scrd3.png)
3. You can also download the logs in CSV format from the dashboard home page.
4. Power on your ESP32, it will present you with an AP named ```SmartA-abc``` (while ```SmartA``` can be changed in the portal and ```abc``` is a unique id for each esp32)
5. Default captive portal password `12345678AP` which can be changed in captive portal.
6. Connect to the ESP32 access point and open the web-browser and navigate to the link ```http://esp32.local/_ac```. This link will work on most of the operating systems but if your operating system is not allowing to open it, you may want to check the captive portal IP Address from the serial monitor and can use that IP address inplace of the above mentioned URL.
7. The default access IP Address is ```http://192.168.4.1/_ac```
8. You will be presented with a main dashboard as shown below(based on your device)
![SCR1](Circuit/scr1.png)
Dashboard Profile Page![SCRD3](Circuit/scrd3.png) 3. You can also download the logs in CSV format from the dashboard home page. 4. Power on your ESP32, it will present you with an AP named `SmartA-abc` (while `SmartA` can be changed in the portal and `abc` is a unique id for each esp32) 5. Default captive portal password `12345678AP` which can be changed in captive portal. 6. Connect to the ESP32 access point and open the web-browser and navigate to the link `http://esp32.local/_ac`. This link will work on most of the operating systems but if your operating system is not allowing to open it, you may want to check the captive portal IP Address from the serial monitor and can use that IP address inplace of the above mentioned URL. 7. The default access IP Address is `http://192.168.4.1/_ac` 8. You will be presented with a main dashboard as shown below(based on your device)
![SCR1](Circuit/scr1.png)

9. Once connected to a WiFi network, you can again access the captive portal using same URL or the IP Address from the Serial monitor.
10. The data is published to the MQTT Topic ```SmartA/{hostname}``` while the hostname is the one which you can define in Settings page of the captive portal.
11. You can open settings page with following default credentials
1. User: **AP Name (SmartA)**
2. Password: **admin**
10. The data is published to the MQTT Topic `SmartA/{hostname}` while the hostname is the one which you can define in Settings page of the captive portal.
11. You can open settings page with following default credentials
12. User: **AP Name (SmartA)**
13. Password: **admin**

## List of Components <a name = "list"></a>

Expand All @@ -314,15 +307,13 @@ Following components are used to make this project
9. 9V to 5V Buck Converter
https://www.amazon.com/UCTRONICS-Converter-Transformer-Voltage-Regulator/dp/B07XXWQ49N/ref=sr_1_1?dchild=1&keywords=9v+to+5v+step+down+converter&qid=1631287177&sr=8-1


## ⛏️ Built Using <a name = "built_using"></a>

- [NodeJS](https://nodejs.org/en/) - JS Framework for Backend Programming
- [Eclipse Paho MQTT](https://www.eclipse.org/paho/index.php?page=clients/python/index.php) - MQTT Client for Backend and RPiClient Software
- [Arduino](https://www.arduino.cc/) - Embedded Framework and IDE - For Sensor Node Design
- [VueJS](https://vuejs.org/) - For Dashboard Design


## ✍️ Authors <a name = "authors"></a>

- [@Nauman3S](https://github.com/Nauman3S) - Development and Deployment

0 comments on commit 1c3e38c

Please sign in to comment.