---
# System prepended metadata

title: GSM疊標燈 SPEC
tags: [ESP32, Templates, GSM疊標燈, Documentation, GSM]

---

---
title: 'GSM疊標燈 SPEC'
disqus: hackmd
---

GSM疊標燈
===


## Table of Contents

[TOC]

## CC Guide (控制中心)

新增 GSM 設備
1. GSM 號碼
2. 定時回報間隔 （0-1440 muinutes）
3. 日光開關
4. 強制開關 開啟/關閉

警示
1. 電壓偵測部份 低於10V發佈低電壓警示
2. 電流偵測部份 低於3A發佈燈泡故障警示

User story
---

```gherkin=
Feature: 警示

  # 由控制中心設定日光開關
  Scenario: 日光開關
    When UI設定日光開關ON
    Then 強制開啟日光開關
    
  # 由控制中心設定強制開關
  Scenario: 強制開關
    When UI設定強制開關ON
    Then 強制關閉強制開關

  # 由控制中心檢查定時回報做電壓偵測
  Scenario: 電壓偵測
    When 低於11V
    Then 發佈低電壓警示
  Scenario: 電壓偵測
    When 低於10V
    Then 發佈電壓不足警示
  
  # 由控制中心檢查定時回報做電壓偵測
  Scenario: 電流偵測
    When 低於3A
    Then 發佈燈泡故障警示
```


User flows
---
```sequence
CC->Gateway: set_gsm request
Note right of ESP32: ESP32 control GSM
Gateway-->ESP32: SMS:GPSMS request
ESP32-->Gateway: SMS:GPSMS response
Gateway->CC: set_gsm response
ESP32-->Gateway: SMS:GPSMS notify

```

> Read more about sequence-diagrams here: http://bramp.github.io/js-sequence-diagrams/

## 通訊協定範例
### set_gsm request
CC->Gateway

```
{
    "prefix": "$GPSMS",
    "type": "request",
    "command": "set_gsm",
    "did": "FFFF",
    "sid": "1029",
    "number": "0965031822",
    "report_interval": 120,
    "sun_relay_switch": 0,
    "main_relay_switch": 0
}
```
Gateway-->ESP32
> $GPSMS,FFFF,1029,1,F,120,0,0,#

ESP32-->Gateway
> $GPSMS,CFF4,1029,2,F,120,0,0,#

Gateway->CC
```
{
    "prefix": "$GPSMS",
    "client": "client-gsm",
    "did": "CFF4",
    "sid": "1029",
    "type": "response",
    "command": "set_gsm",
    "report_interval": "120",
    "sun_relay_switch": "0",
    "main_relay_switch": "0",
    "sms": {
        "number": "0965031822",
        "text": "$GPSMS,CFF4,1029,2,F,120,0,0,#\n",
        "receive": 1,
        "send": 1,
        "time": "2022-03-22T13:58:47+08:00",
        "out_sms": "RECV"
    }
}
```
### get_gsminfo notify
ESP32-->Gateway
> $GPSMS,CFF4,0002,0,8,120,0,0,12V,802,12.0,716,5.0,640.00A,NA,#
Gateway->CC
```
{
    "prefix": "$GPSMS",
    "client": "client-gsm",
    "did": "CFF4",
    "sid": "0002",
    "type": "notify",
    "command": "notify_gsminfo",
    "report_interval": "120",
    "sun_relay_switch": "0",
    "main_relay_switch": "0",
    "voltage_setting": "12V",
    "voltage": "802",
    "voltage_value": "12.0",
    "current": "716",
    "current_value": "5.0",
    "battery_status": "640.00A",
    "battery_hours": "NA",
    "sms": {
        "number": "0965031822",
        "text": "$GPSMS,CFF4,0002,0,8,120,0,0,12V,802,12.0,716,5.0,640.00A,NA,#\n",
        "receive": 2,
        "send": 0,
        "time": "2022-03-19T17:41:39+08:00",
        "out_sms": "RECV"
    }
}
```

## ESP 32
### MAP I/O
1.電流偵測--GPIO35
2.電壓偵測--GPIO39
3.日光開關--P25
4.強制 ON/OFF--P26
5.12V/24V Select P27
12V ----Hi
24V ----Low
![](https://i.imgur.com/T4oXb8y.jpg)

 
### 功能
GSM疊標燈有日光開關控制,白天不亮燈電流140 mA,晚上亮燈才有大電流(6~9A)。
蓄電池電流容量(12V/640A,24V/320A)以電壓偵測< 11.5V為起始點開始計時累算，
例如8.7A/hr+8.5A/hr+8.1A/hr+7.9A/hr…,直到白天電流140 mA結束,累計消耗電流
80A/day,
在12V模式蓄電池電流容量640A可用8天以上，24V模式可用4天,直到充電電壓＞12V時,才清除累計時數重新歸零。

## Appendix and FAQ

:::info
**Find this document incomplete?** Leave a comment!
:::

###### tags: `Templates` `Documentation` `GSM` `ESP32` `GSM疊標燈`
