How to Build an Integrated Gateway For Power Supply Station.
Published: 2020-09-22 10:03:36

The existing and newly built five-star power supply station has installed a lot of smart devices, such as photovoltaic energy storage, central air conditioning, smart lighting, smart curtains, access control systems, and so on. Each sub-system interface is different, and there is no unified interface or platform, this project is going to solve this problem, and also settle some specific problems, such as carrier communication, and leakage monitoring, and so on.


##Hardware

Main Control: STM32F767IGT6. External extension of 32-bit SDRAM.

External interfaces include:

- 1 10/100M gateway.
- 1 RS485 interface.
- 1 CAN interface.
- 1 RS232 interface.
- 1 carrier communication interface.
- 1 relay switch volume interface.
- 3 AC voltage measurement interfaces.
- 1 leakage monitoring interface.
- 1 TYPEA-USB connector.
- 1 Micro-USB interface.
- 1 temperature and humidity measurement interface.
- WIFI.
- 4G.


##Implementation features:

- Modbus-TCP docking photovoltaic energy storage system.
- Modbus-RTU docking the central air conditioning system.
- Measure the ambient temperature and humidity of the installation.
- Measure the three-phase voltage value.
- Measure the leakage value of the switch.
- QPSI device analog U-stick.
- LCD displays sub-system data and acquisition data.
- Timely upload of ucloud leakage value and remote control the power.


##Kernel

- Inter-thread synchronization: semaphore, mutex.
- Inter-thread communication: mailbox, message queue.
- Memory management: memheap management algorithm.
- I/O Device Management: PIN Device、SPI Device、UART Device、RTC - - Device、LCD Device、WATCH DOG Device、SENSOR Device.
- FinSH Console
- Virtual File System
- NETDEV NIC(Network Interface Controller)
- AT Command
- SAL (Socket Abstraction Layer)
- UCLOUD Software Package: ucloud_iot_sdk-latest
- AT Device Software Package: at_device-latest
- LIBMODBUS Software Package: libmodbus-latest
- OTA Software Package: ota_downloader-latest
- Network Package: netutils-latest
- DHTxx Software Package: dhtxx-latest
- EASYFLASH Software Package: EasyFlash-latest
- FAL Software Package: fal-latest

##Hardware Architecture

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qqs8iwidmpgu5hvw8tlb.png)

- ATT7022EU: Measuring three-phase voltage and leakage.
- W25Q256: One piece for storing word libraries and pictures and another piece for firmware download, factory firmware, EASYFLASH use, etc.
- AM2301: Temperature and humidity measurement.
- EC200T: 4G communication.
- ADM2483: RS485 communication.
- MAX232A:RS232 Communication.
- ESP8266: WIFI.
- LCD: RGB888, screen resolution 800 x 480.
- IS42S32800G: 32-bit SDRAM, 32M.

##Software Architecture
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8jfyu5o0fuuv4s35uj7k.png)

##Software Module
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yeduvl6c409393khk9zs.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uedovhrj73ogg7ttjne7.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cf0aje78jsztvlgwyi8l.png)

The above photo shows the most important task that responsible for refreshing the data displays on the screen, other acquisition tasks and data interaction tasks have their own semaphore, refresh task to get the semaphore waiting for 10MS, and then refresh the corresponding area.


##Presentation
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1expqecrg1ueaunzxzeq.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/33hd3lu5x95qum3scvxt.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0d027bo9fw3uabbe8cep.png)


**RT-Thread Contact Info:**

 [Website](https://www.rt-thread.io/)  |  [Github](https://github.com/RT-Thread)  | [Twitter](https://twitter.com/rt_thread) |  [Facebook](https://www.facebook.com/RT-Thread-IoT-OS-110395723808463)   |   [Youtube](https://www.youtube.com/channel/UCdDHtIfSYPq4002r27ffqPw
)