ESP8266_swiss_army_board/README.md

219 lines
7.3 KiB
Markdown

# ESP8266_swiss_army_board
Arduino based project running on my custom made board
## The hardware :
**The board :**
![](http://82.64.196.164/images/git/SAB_front.jpg)
![](http://82.64.196.164/images/git/SAB_back.jpg)
**The modules :**
![](http://82.64.196.164/images/git/SAB_cmp_mod.jpg)
### Hardware pin mapping :
![](http://82.64.196.164/images/git/ESP8266_pinout.png)
(This image wasn't done by me)
**So we have :**
* I2C (for OLED screen and RTC)
* GPIO4 --> SDA
* GPIO5 --> SCL
* SPI (for µSDCard)
* GPIO13 --> MOSI
* GPIO12 --> MISO
* GPIO14 --> CLK
* GPIO2 --> µSDCard CHIP_SELECT
* FLASH_BTN
* GPIO 0
## Here is a list of the components needed in order to build such a board :
* 1x 1N4001 reverse voltage protection diode
* 1x AMS1117 5v voltage regulator
* 1x AMS1117 3.3v voltage regulator
* 2x 22µf electrolytic capacitors
* 2x 0.1µf (code 104) tantalum capacitors
* 1x jumper
* 1x 2 pins male header
* 1x On/Off switch
* 2x push buttons
* 1x ESP8266 E12
* 1x 19 pins female header
* 1x 2 screws terminal
* 1x micro USB socket
* 1x 100 ohm resistor
* 2x 1k ohm resistor
* 1x 6.8k ohm resistor
* 1x 3.9k ohm resistor
* 1x 22k ohm resistor
* 2x 10k ohm resistor
* 1x 33k ohm resistor
* 1x 4.7k ohm resistor
* 1x 7cmx5cm pcb
## The software :
### Default FLASH Options (for the Arduino IDE) :
![](http://82.64.196.164/images/git/flash_option.png)
### I2C Hardware addresses :
* OLED screen : 0x3C
* RTC DS3231 : 0x68
* PCF8574 : 0x27
### External librairies used :
* Adafruit_SSD1306 (not my work) [link](https://github.com/adafruit/Adafruit_SSD1306)
* Adafruit-GFX (not my work) [link](https://github.com/adafruit/Adafruit-GFX-Library)
* RTClib-master (not my work) [link](https://github.com/adafruit/RTClib)
* AT24CXX-master (not my work) [link](https://github.com/cyberp/AT24Cx)
/!\ Some of these librairies have been modified for the project, thus, it is recommended to get them from the repository here : [link](http://82.64.196.164/git/Th3maz1ng/ESP8266_swiss_army_board/src/branch/master/src/libs)
### SD Card structure (subject to changes) :
``` json
/
|_CONFIG
| AP.CFG
| SCREEN.CFG
| SERVER.CFG
| STA.CFG
|_FTP
|_LOGS
|_WWW
```
### Example of a config file structure (.CFG) :
``` json
#This line is a comment and will be ignored
#All comments should be at the top of the file
#The parameter names are case sensitive /!\
this_is_the_parameter_name : this_is_a_numeric_value
'this is the parameter name' : this_is_a_numeric_value
this_is_the_parameter_name : 'this is a string value'
'this is the parameter name' : 'this_is_a_string_value'
```
### For AP.CFG it would be :
``` json
#This config file stores the configuration needed to set the AP
#up for the ESP8266SwissArmyBoad
#If this file is not present or if there is an error at parsing time
#default values will be used instead.
#If the password is an empty string aka '', the network will be open
SSID : 'ESP8266SwissArmyBoard'
PASSWORD : 'APassWord'
CHANNEL : 1
SSID_HIDDEN : 'true'
AP_MAX_CONNECTION : 4
```
### For STA.CFG it would be :
``` json
#This config file stores the configuration needed to connect the board
#to a wifi hotspot
#If this file is not present or if there is an error at parsing time
#only the AP functionality will be enabled
SSID : 'MyHotspotSSID'
PASSWORD : 'MySuperSecuredPassword'
```
### System WEB api :
Here is a list of the available api calls for the board :
* /sab/web/apitester
* HTTP request method : ALL
* Description : Test if the api system is available
* Response format : JSON
* OK : { "status" : "ok", "API" : "available" }
* FAIL : NOTHING
* /sab/view/next
* HTTP request method : GET
* Description : Display the next view on the screen
* Response format : JSON
* OK : { "status" : "ok", "ViewUID" : "UID" }
* FAIL : { "status" : "failed", "message" : "REASON" }
* /sab/view?UID=x
* HTTP request method : GET
* Description : Display the view with the corresponding id
* Response format : JSON
* OK : { "status" : "ok", "ViewUID" : "UID" }
* FAIL : { "status" : "failed", "message" : "REASON" }
* /sab/rtc/get/datetime
* HTTP request method : GET
* Description : Get RTC's time
* Response format : JSON
* OK : { "status" : "ok", "date" : "xx/xx/xxxx", "time" "xx:xx:xx" }
* /sab/rtc/set/datetime?datetime=day_month_year_hours_minutes_seconds
* HTTP request method : GET
* Description : Set RTC's clock
* Response format : JSON
* OK : { "status" : "ok", "date" : "xx/xx/xxxx", "time" "xx:xx:xx" }
* FAIL : { "status" : "failed", "message" : "REASON" }
* /sab/sdcard/size
* HTTP request method : GET
* Description : Show SD Card size in GByte
* Response format : JSON
* OK : { "status" : "ok", "card" : "present", "size" : "xx.xx", "unit" : "GByte" }
* OK : { "status" : "ok", "card" : "not present", "size" : "0" }
* /sab/sdcard/unmount
* HTTP request method : GET
* Description : Unmount the SD Card in order to remove it
* Response format : JSON
* OK : { "status" : "ok", "card" : "unmounted" }
* /sab/sdcard/mount
* HTTP request method : GET
* Description : Mount the SD Card
* Response format : JSON
* OK : { "status" : "ok", "card" : "mounted" }
* FAIL : { "status" : "failed", "message" : "REASON" }
* /esp/restart
* HTTP request method : GET
* Description : Restart the UC, this one is recommended compared to the reset call
* Response format : JSON
* OK : { "status" : "ok", "message" : "module restarting in 10 seconds" }
* /esp/reset
* HTTP request method : GET
* Description : Reset the UC
* Response format : JSON
* OK : { "status" : "ok", "message" : "module resetting in 10 seconds" }
* /sab/wifi/stainfo
* HTTP request method : GET
* Description : Get the module's station information
* Response format : JSON
* OK : { "status" : "ok", "RSSI" : "-XX", "RSSI2" : "X", "local IP" : "XXX.XXX.X.XX", "mac" : "XX:XX:XX:XX:XX:XX" }
* /sab/systeminfo
* HTTP request method : GET
* Description : Get the module's system information (free memory, heap frag etc...)
* Response format : JSON
* OK : { "status" : "ok", "CPU freq" : "XX", "free RAM" : "XXXXX", "heap frag" : "X", "max block" : "XXXXX", "nb views" : "X" }
* /sab/power/info
* HTTP request method : GET
* Description : Get the module's power information
* Response format : JSON
* OK : { "status" : "ok", "power type" : "USB", "level" : "0", "unit" : "%" }
* /sab/io/get/level
* /sab/io/get/level?P0&P2&PX...
* HTTP request method : GET
* Description : Get the module's I/O logic levels, it is possible to check the level of specific pins
* Response format : JSON
* OK : { "status" : "ok", "P0" : "1", "P1" : "1", "P2" : "0", "P3" : "1", "P4" : "1", "P5" : "1", "P6" : "1", "P7" : "1" }
### Things to do :
* Screen Manager ✓
* µSDcard File System
* Add a file truncate function ✓
* File Config Parser
* Add save config ✓
* Templated Dictionary Class ✓
* RTC Manager ✓
* RTC FLASH Manager
* FTP Server ✓
* Passive mode ✓
* Active mode (needs to be done)
* WEB ServerManager ✓
* WEB ServerManagerV2 with multiple clients ✓
* GPIO Util ✓
* Task Scheduler Manager (in progress - almost done)
* Writing a proper documentation and wiki for the board