Skip to content

Commit 9c8c189

Browse files
committed
Init AtomS3
1 parent 8a324b9 commit 9c8c189

File tree

140 files changed

+65017
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+65017
-30
lines changed

.github/workflows/clang-format-check.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ jobs:
77
strategy:
88
matrix:
99
path:
10-
- check: './' # path to include
11-
exclude: '' # path to exclude
10+
- check: "./" # path to include
11+
exclude: "(FactoryTest)" # path to exclude
1212
# - check: 'src'
1313
# exclude: '(Fonts)' # Exclude file paths containing "Fonts"
1414
# - check: 'examples'
1515
# exclude: ''
1616
steps:
17-
- uses: actions/[email protected]
18-
- name: Run clang-format style check for C/C++/Protobuf programs.
19-
uses: jidicula/[email protected]
20-
with:
21-
clang-format-version: '13'
22-
check-path: ${{ matrix.path['check'] }}
23-
exclude-regex: ${{ matrix.path['exclude'] }}
17+
- uses: actions/[email protected]
18+
- name: Run clang-format style check for C/C++/Protobuf programs.
19+
uses: jidicula/[email protected]
20+
with:
21+
clang-format-version: "13"
22+
check-path: ${{ matrix.path['check'] }}
23+
exclude-regex: ${{ matrix.path['exclude'] }}

README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
# M5Template-C-CPP
1+
# AtomS3 Library
22

3-
### SKU:xxx
3+
English | [中文](README_cn.md)
44

5-
Template for M5Stack C and CPP projects.
5+
<img src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-91894638-80df-4827-892e-cb8f50cf1041.jpg" alt="M5Atom Lite" width="350" height="350">
66

7-
## Steps
7+
* **For the Detailed documentation of AtomS3, please [Click here](https://docs.m5stack.com/en/core/AtomS3)**
88

9-
1. Change [clang format check path](./.github/workflows/clang-format-check.yml#L9-L15).
10-
2. Add License content to [LICENSE](/LICENSE).
11-
3. Change this [README.md](./README.md#L1-L8).
12-
4. Change link on line 78 of [bug-report.yml](./.github/ISSUE_TEMPLATE/bug-report.yml#L78).
9+
## Description
1310

14-
<!-- Example
15-
# M5Unit-ENV
11+
`AtomS3` is a highly integrated programmable controller based on `ESP32-S3` main control, which integrates ESP32-S3 main control, integrated `WiFi` function, and `8M` on-chip FLASH; `0.85` inch `IPS screen`; `Programmable button function` at the bottom of the screen; Built-in 5V to 3.3V circuit, 6-axis gyro sensor `MPU6886`, on-board `Type-C` interface, power supply and firmware download, one `HY2.0-4P` expansion port, `6 GPIOs and power pins` reserved at the bottom to facilitate expansion applications. The product size is only `24*24mm`, which is suitable for various `embedded smart device applications`.
1612

17-
## Overview
13+
- `Reminder: If you need to burn the firmware, please press and hold the reset button (about 2 seconds) until the internal green LED lights up, then you can release it, at this time the device has entered download mode and waited for burning.`
1814

19-
### SKU:U001 & U001-B & U001-C
15+
## Applications
2016

21-
Contains M5Stack-**UNIT ENV** series related case programs.ENV is an environmental sensor with integrated SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data.
17+
- Internet of things terminal controller
18+
- IoT node
19+
- Wearable peripherals
2220

23-
## Related Link
21+
## Schematic
2422

25-
- [Document & Datasheet](https://docs.m5stack.com/en/unit/envIII)
23+
<img alt="schematics" src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-b85e925c-adff-445d-994c-45987dc97a44.jpg" width="100%" />
2624

27-
## Required Libraries:
25+
## Module Size
2826

29-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Adafruit_BMP280_Library)
30-
31-
## License
32-
33-
- [M5Unit-ENV - MIT](LICENSE) -->
27+
<img alt="module size" src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-abe8d8b0-3d8c-4f42-a84a-093bfed0aa38.png" width="100%" />

README_cn.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# AtomS3 Library
2+
3+
中文 | [English](README_cn.md)
4+
5+
<img src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-91894638-80df-4827-892e-cb8f50cf1041.jpg" alt="M5Atom Lite" width="350" height="350">
6+
7+
* **如果查看 AtomS3 的详细介绍文档,[点击这里](https://docs.m5stack.com/zh_CN/core/AtomS3)**
8+
9+
## 描述
10+
11+
`AtomS3` 是一款基于`ESP32-S3`主控的高集成度可编程控制器,内部集成了ESP32-S3主控,集成`WiFi`功能,`8M`片上FLASH;`0.85``IPS屏幕`;屏幕下方具有`可编程按键功能`;内置5V转3.3V电路;6轴陀螺仪传感器`MPU6886`;板载`Type-C`接口,供电及固件下载;一个`HY2.0-4P`扩展端口;底部预留6个`GPIO以及电源引脚`,方便扩展应用。产品大小只有`24 * 24mm`,适用于各种`嵌入式`的智能设备应用。
12+
13+
## 应用
14+
15+
- 物联网节点
16+
- 微型控制器
17+
- 可穿戴设备
18+
19+
## 原理图
20+
21+
<img alt="schematics" src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-b85e925c-adff-445d-994c-45987dc97a44.jpg" width="100%" />
22+
23+
## 尺寸图
24+
25+
<img alt="module size" src="https://static-cdn.m5stack.com/resource/docs/products/core/AtomS3/img-abe8d8b0-3d8c-4f42-a84a-093bfed0aa38.png" width="100%" />
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5AtomS3 sample source code
5+
* 配套 M5AtomS3 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/products
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/products
8+
*
9+
* describe:EzData.
10+
* Date: 2022/12/29
11+
*******************************************************************************
12+
*/
13+
14+
#include "M5AtomS3.h"
15+
#include "M5_EzData.h"
16+
17+
// Configure the name and password of the connected wifi and your token.
18+
// 配置所连接wifi的名称、密码以及你的token
19+
const char* ssid = "Explore-F";
20+
const char* password = "xingchentansuo123";
21+
const char* token = "";
22+
23+
void setup() {
24+
M5.begin(); // Initialize M5Stack
25+
if (setupWifi(ssid, password)) { // Connect to wifi. 连接到wifi
26+
Serial.printf("Success connecting to %s\n", ssid);
27+
} else {
28+
Serial.printf("Connecting to %s failed\n", ssid);
29+
}
30+
}
31+
32+
void loop() {
33+
// Save the data 20 to the top of the testData topic queue. 保存数据20至
34+
// testData 队列首位
35+
setData(token, "testData", 20);
36+
delay(5000);
37+
38+
// Save 3 data in sequence to the first place of testList. 依次保存3个数据至
39+
// testList首位
40+
for (int i = 0; i < 3; i++) {
41+
addToList(token, "testList", i);
42+
delay(100);
43+
}
44+
delay(5000);
45+
46+
// Get a piece of data from a topic and store the value in result. 从一个
47+
// topic中获取一个数据,并将值存储在 result
48+
int result = 0;
49+
if (getData(token, "testData", result))
50+
;
51+
delay(5000);
52+
53+
// Get a set of data from a list and store the values in the Array array.
54+
// 从一个 list中获取一组数据,并将值存储在 Array数组中
55+
int Array[3] = {};
56+
if (getData(token, "testList", Array, 0, 3)) {
57+
Serial.print("Success get list\n");
58+
for (int i = 0; i < 3; i++) {
59+
Serial.printf("Array[%d]=%d,", i, Array[i]);
60+
}
61+
Serial.println("");
62+
} else {
63+
Serial.println("Fail to get data");
64+
}
65+
delay(5000);
66+
67+
// Remove data
68+
removeData(token, "testData");
69+
removeData(token, "testList");
70+
delay(5000);
71+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5AtomS3 sample source code
5+
* 配套 M5AtomS3 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/products
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/products
8+
*
9+
* Describe: I2C Scanner. I2C探测
10+
* Date: 2021/7/27
11+
*******************************************************************************
12+
This program scans the addresses 1-127 continuosly and shows the devices found
13+
on the TFT. 该程序连续扫描地址 1-127 并显示在外部(内部)I2C发现的设备。
14+
*/
15+
#include <M5AtomS3.h>
16+
17+
void setup() {
18+
M5.begin(true, true, true,
19+
false); // Init M5AtomS3(Initialization of external I2C is also
20+
// included). M5AtomS3(初始化外部I2C也包含在内)
21+
// Wire.begin(21, 22); //Detect internal I2C, if this sentence is not added,
22+
// it will detect external I2C. 检测内部I2C,若不加此句为检测外部I2C
23+
Wire.begin(26, 32);
24+
M5.Lcd.println("M5AtomS3 I2C Tester"); // Print a string on the screen.
25+
// 在屏幕上打印字符串
26+
delay(3000);
27+
}
28+
29+
void loop() {
30+
int address;
31+
int error;
32+
M5.Lcd.printf("\nscanning Address [HEX]\n");
33+
for (address = 1; address < 127; address++) {
34+
Wire.beginTransmission(
35+
address); // Data transmission to the specified device address
36+
// starts. 开始向指定的设备地址进行传输数据
37+
error = Wire.endTransmission(); /*Stop data transmission with the slave.
38+
停止与从机的数据传输 0: success. 成功 1: The amount of data
39+
exceeds the transmission buffer capacity limit.
40+
数据量超过传送缓存容纳限制 return value: 2:
41+
Received NACK when sending address. 传送地址时收到 NACK 3:
42+
Received NACK when transmitting data. 传送数据时收到 NACK
43+
4: Other errors. 其它错误 */
44+
if (error == 0) {
45+
M5.Lcd.print(address, HEX);
46+
M5.Lcd.print(" ");
47+
} else
48+
M5.Lcd.print(".");
49+
50+
delay(10);
51+
}
52+
delay(1000);
53+
M5.Lcd.setCursor(1, 12);
54+
M5.Lcd.fillRect(1, 15, 128, 128, BLACK);
55+
}

examples/Advanced/MQTT/MQTT.ino

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5AtomS3 sample source code
5+
* 配套 M5AtomS3 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/core/atom_matrix
7+
* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/atom_matrix
8+
*
9+
* Describe: MQTT.
10+
* Date: 2022/12/19
11+
*******************************************************************************
12+
*/
13+
#include "M5AtomS3.h"
14+
#include <WiFi.h>
15+
#include <PubSubClient.h>
16+
17+
WiFiClient espClient;
18+
PubSubClient client(espClient);
19+
20+
// Configure the name and password of the connected wifi and your MQTT Serve
21+
// host. 配置所连接wifi的名称、密码以及你MQTT服务器域名
22+
const char* ssid = "FS309";
23+
const char* password = "FS808808";
24+
const char* mqtt_server = "mqtt.m5stack.com";
25+
26+
unsigned long lastMsg = 0;
27+
#define MSG_BUFFER_SIZE (50)
28+
char msg[MSG_BUFFER_SIZE];
29+
int value = 0;
30+
31+
void setupWifi();
32+
void callback(char* topic, byte* payload, unsigned int length);
33+
void reConnect();
34+
35+
void setup() {
36+
M5.begin(true, true, true, false);
37+
setupWifi();
38+
client.setServer(mqtt_server,
39+
1883); // Sets the server details. 配置所连接的服务器
40+
client.setCallback(
41+
callback); // Sets the message callback function. 设置消息回调函数
42+
}
43+
44+
void loop() {
45+
if (!client.connected()) {
46+
reConnect();
47+
}
48+
client.loop(); // This function is called periodically to allow clients to
49+
// process incoming messages and maintain connections to the
50+
// server.
51+
//定期调用此函数,以允许主机处理传入消息并保持与服务器的连接
52+
53+
unsigned long now =
54+
millis(); // Obtain the host startup duration. 获取主机开机时长
55+
if (now - lastMsg > 2000) {
56+
lastMsg = now;
57+
++value;
58+
snprintf(msg, MSG_BUFFER_SIZE, "hello world #%ld",
59+
value); // Format to the specified string and store it in MSG.
60+
// 格式化成指定字符串并存入msg中
61+
USBSerial.print("Publish message: ");
62+
USBSerial.println(msg);
63+
client.publish("M5Stack", msg); // Publishes a message to the specified
64+
// topic. 发送一条消息至指定话题
65+
}
66+
}
67+
68+
void setupWifi() {
69+
delay(10);
70+
M5.Lcd.print("Connecting to Network...");
71+
USBSerial.printf("Connecting to %s", ssid);
72+
WiFi.mode(
73+
WIFI_STA); // Set the mode to WiFi station mode. 设置模式为WIFI站模式
74+
WiFi.begin(ssid, password); // Start Wifi connection. 开始wifi连接
75+
76+
while (WiFi.status() != WL_CONNECTED) {
77+
delay(500);
78+
USBSerial.print(".");
79+
}
80+
USBSerial.printf("\nSuccess\n");
81+
M5.Lcd.println("Success");
82+
M5.Lcd.println("For communication information see serial port");
83+
}
84+
85+
void callback(char* topic, byte* payload, unsigned int length) {
86+
USBSerial.print("Message arrived [");
87+
USBSerial.print(topic);
88+
USBSerial.print("] ");
89+
for (int i = 0; i < length; i++) {
90+
USBSerial.print((char)payload[i]);
91+
}
92+
USBSerial.println();
93+
}
94+
95+
void reConnect() {
96+
while (!client.connected()) {
97+
USBSerial.print("Attempting MQTT connection...");
98+
// Create a random client ID. 创建一个随机的客户端ID
99+
String clientId = "M5Stack-";
100+
clientId += String(random(0xffff), HEX);
101+
// Attempt to connect. 尝试重新连接
102+
if (client.connect(clientId.c_str())) {
103+
USBSerial.println("connected");
104+
// Once connected, publish an announcement to the topic.
105+
// 一旦连接,发送一条消息至指定话题
106+
client.publish("M5Stack", "hello world");
107+
// ... and resubscribe. 重新订阅话题
108+
client.subscribe("M5Stack");
109+
} else {
110+
USBSerial.print("failed, rc=");
111+
USBSerial.print(client.state());
112+
USBSerial.println("try again in 5 seconds");
113+
delay(5000);
114+
}
115+
}
116+
}

0 commit comments

Comments
 (0)