Skip to content

Commit 7577db2

Browse files
committed
Init
1 parent b55c7a6 commit 7577db2

File tree

10 files changed

+358
-189
lines changed

10 files changed

+358
-189
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
# M5_ADS1100
1+
# M5-ADS1100
22

33
## Overview
44

5-
M5Stack-**UNIT ADC**
5+
### SKU:U013/U069
6+
7+
Contains M5Stack **Unit & Hat ADC** related case programs.
8+
69

710
## Related Link
811

9-
[Document & Datasheet](https://docs.m5stack.com/en/unit/adc)
12+
[Document & Datasheet - M5Unit-ADC](https://docs.m5stack.com/en/unit/adc)
13+
14+
[Document & Datasheet - M5Hat-ADC](https://docs.m5stack.com/en/hat/hat-adc)
1015

1116
## License
1217

13-
[UNIT_ADC - MIT](LICENSE)
18+
[Unit & Hat ADC - MIT](LICENSE)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5StickC sample source code
5+
* 配套 M5StickC 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/unit/adc
7+
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/adc
8+
*
9+
* Product: ADC. A/D转换器
10+
* Date: 2022/7/11
11+
*******************************************************************************
12+
Please connect to Port,Use ADC Unit to convert 0 ~ 12V analog voltage into
13+
16-bit data and display it on the screen.
14+
请连接端口,利用ADC单元将0 ~12V模拟电压转换成16位数据显示在屏幕上。
15+
*/
16+
17+
#include <M5StickC.h>
18+
#include "M5_ADS1100.h"
19+
20+
ADS1100 ads;
21+
22+
void setup(void) {
23+
M5.begin(); // Init M5StickC. 初始化M5StickC
24+
M5.Lcd.setRotation(3); // Rotating display. 旋转显示屏
25+
26+
// The address can be changed making the option of connecting multiple
27+
// devices 地址可以改变,以连接多个设备
28+
ads.getAddr_ADS1100(
29+
ADS1100_DEFAULT_ADDRESS); // 0x48, 1001 000 (ADDR = GND)
30+
31+
// The ADC gain (PGA). ADC增益(PGA)
32+
ads.setGain(GAIN_ONE); // 1x gain(default)
33+
// ads.setGain(GAIN_TWO); // 2x gain
34+
// ads.setGain(GAIN_FOUR); // 4x gain
35+
// ads.setGain(GAIN_EIGHT); // 8x gain
36+
37+
// Device operating mode. 设备工作模式
38+
ads.setMode(MODE_CONTIN); // Continuous conversion mode (default)
39+
// ads.setMode(MODE_SINGLE); // Single-conversion mode
40+
41+
// Data rate. 数据速率
42+
ads.setRate(RATE_8); // 8SPS (default)
43+
// ads.setRate(RATE_16); // 16SPS
44+
// ads.setRate(RATE_32); // 32SPS
45+
// ads.setRate(RATE_128); // 128SPS
46+
47+
ads.setOSMode(
48+
OSMODE_SINGLE); // Set to start a single-conversion. 设置开始一次转换
49+
50+
ads.begin(); // Sets up the Hardware. 设置硬件
51+
M5.Lcd.print("ADC");
52+
}
53+
54+
void loop(void) {
55+
byte error;
56+
int8_t address;
57+
58+
address = ads.ads_i2cAddress;
59+
Wire.beginTransmission(address);
60+
error = Wire.endTransmission();
61+
if (error == 0) // If the device is connected. 如果连接上设备
62+
{
63+
int16_t result;
64+
result = ads.Measure_Differential();
65+
M5.Lcd.fillScreen(BLACK);
66+
char data[20] = {0};
67+
sprintf(data, "%d", result);
68+
M5.Lcd.drawCentreString(data, 0, 20, 4);
69+
} else {
70+
M5.Lcd.setCursor(0, 40);
71+
M5.Lcd.drawString("No Found ADC sensor.", 0, 20);
72+
}
73+
delay(1000);
74+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5StickCPlus sample source code
5+
* 配套 M5StickCPlus 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/unit/adc
7+
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/adc
8+
*
9+
* Product: ADC. A/D转换器
10+
* Date: 2022/7/11
11+
*******************************************************************************
12+
Please connect to Port,Use ADC Unit to convert 0 ~ 12V analog voltage into
13+
16-bit data and display it on the screen.
14+
请连接端口,利用ADC单元将0 ~12V模拟电压转换成16位数据显示在屏幕上。
15+
*/
16+
17+
#include <M5StickCPlus.h>
18+
#include "M5_ADS1100.h"
19+
20+
ADS1100 ads;
21+
22+
void setup(void) {
23+
M5.begin(); // Init M5StickCPlus. 初始化M5StickCPlus
24+
M5.Lcd.setRotation(3); // Rotating display. 旋转显示屏
25+
26+
// The address can be changed making the option of connecting multiple
27+
// devices 地址可以改变,以连接多个设备
28+
ads.getAddr_ADS1100(
29+
ADS1100_DEFAULT_ADDRESS); // 0x48, 1001 000 (ADDR = GND)
30+
31+
// The ADC gain (PGA). ADC增益(PGA)
32+
ads.setGain(GAIN_ONE); // 1x gain(default)
33+
// ads.setGain(GAIN_TWO); // 2x gain
34+
// ads.setGain(GAIN_FOUR); // 4x gain
35+
// ads.setGain(GAIN_EIGHT); // 8x gain
36+
37+
// Device operating mode. 设备工作模式
38+
ads.setMode(MODE_CONTIN); // Continuous conversion mode (default)
39+
// ads.setMode(MODE_SINGLE); // Single-conversion mode
40+
41+
// Data rate. 数据速率
42+
ads.setRate(RATE_8); // 8SPS (default)
43+
// ads.setRate(RATE_16); // 16SPS
44+
// ads.setRate(RATE_32); // 32SPS
45+
// ads.setRate(RATE_128); // 128SPS
46+
47+
ads.setOSMode(
48+
OSMODE_SINGLE); // Set to start a single-conversion. 设置开始一次转换
49+
50+
ads.begin(); // Sets up the Hardware. 设置硬件
51+
M5.Lcd.print("ADC");
52+
}
53+
54+
void loop(void) {
55+
byte error;
56+
int8_t address;
57+
58+
address = ads.ads_i2cAddress;
59+
Wire.beginTransmission(address);
60+
error = Wire.endTransmission();
61+
if (error == 0) // If the device is connected. 如果连接上设备
62+
{
63+
int16_t result;
64+
result = ads.Measure_Differential();
65+
M5.Lcd.fillScreen(BLACK);
66+
char data[20] = {0};
67+
sprintf(data, "%d", result);
68+
M5.Lcd.drawCentreString(data, 0, 20, 4);
69+
} else {
70+
M5.Lcd.setCursor(0, 40);
71+
M5.Lcd.drawString("No Found ADC sensor.", 0, 20);
72+
}
73+
delay(1000);
74+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with Atom-Lite/Matrix sample source code
5+
* 配套 Atom-Lite/Matrix 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/unit/adc
7+
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/adc
8+
*
9+
* Product: ADC. A/D转换器
10+
* Date: 2021/8/18
11+
*******************************************************************************
12+
Please connect to Port A,Use ADC Unit to convert 0 ~ 12V analog voltage into
13+
16-bit data and display it on the Serial. 请连接端口,利用ADC单元将0 ~
14+
12V模拟电压转换成16位数据显示在串口上。
15+
*/
16+
17+
#include <M5Atom.h>
18+
#include "M5_ADS1100.h"
19+
20+
ADS1100 ads;
21+
22+
void setup(void) {
23+
M5.begin(); // Init M5Atom. 初始化M5Atom
24+
Wire.begin(26, 32); // Initialize pin 26,32. 初始化26,32引脚
25+
26+
// The address can be changed making the option of connecting multiple
27+
// devices 地址可以改变,以连接多个设备
28+
ads.getAddr_ADS1100(
29+
ADS1100_DEFAULT_ADDRESS); // 0x48, 1001 000 (ADDR = GND)
30+
31+
// The ADC gain (PGA). ADC增益(PGA)
32+
ads.setGain(GAIN_ONE); // 1x gain(default)
33+
// ads.setGain(GAIN_TWO); // 2x gain
34+
// ads.setGain(GAIN_FOUR); // 4x gain
35+
// ads.setGain(GAIN_EIGHT); // 8x gain
36+
37+
// Device operating mode. 设备工作模式
38+
ads.setMode(MODE_CONTIN); // Continuous conversion mode (default)
39+
// ads.setMode(MODE_SINGLE); // Single-conversion mode
40+
41+
// Data rate. 数据速率
42+
ads.setRate(RATE_8); // 8SPS (default)
43+
// ads.setRate(RATE_16); // 16SPS
44+
// ads.setRate(RATE_32); // 32SPS
45+
// ads.setRate(RATE_128); // 128SPS
46+
47+
ads.setOSMode(
48+
OSMODE_SINGLE); // Set to start a single-conversion. 设置开始一次转换
49+
50+
ads.begin(); // Sets up the Hardware. 设置硬件
51+
}
52+
53+
void loop(void) {
54+
byte error;
55+
int8_t address;
56+
57+
address = ads.ads_i2cAddress;
58+
59+
Wire.beginTransmission(address);
60+
error = Wire.endTransmission();
61+
if (error == 0) // If the device is connected. 如果连接上设备
62+
{
63+
int16_t result;
64+
65+
Serial.println("Getting Differential Reading from ADS1100");
66+
Serial.println(" ");
67+
result = ads.Measure_Differential();
68+
Serial.print("Digital Value of Analog Input between Channel 0 and 1: ");
69+
Serial.println(result);
70+
char data[20] = {0};
71+
sprintf(data, "%d", result);
72+
Serial.println("-----------");
73+
} else {
74+
Serial.println("ADS1100 Disconnected!");
75+
Serial.println("-----------");
76+
}
77+
78+
delay(1000);
79+
}

examples/ADC_ADS1100_M5Stack/ADC_ADS1100_M5Stack.ino renamed to examples/Unit_ADC_M5Core/Unit_ADC_M5Core.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/adc
88
*
99
* Describe: ADC. A/D转换器
10-
* Date: 2022/6/12
10+
* Date: 2022/7/11
1111
*******************************************************************************
1212
Please connect to Port A,Use ADC Unit to convert 0 ~ 12V analog voltage into
1313
16-bit data and display it on the screen. 请连接端口A,利用ADC单元将0 ~
1414
12V模拟电压转换成16位数据显示在屏幕上。
1515
*/
1616

1717
#include <M5Stack.h>
18-
1918
#include "M5_ADS1100.h"
2019

2120
ADS1100 ads;

examples/ADC_ADS1100_M5Core2/ADC_ADS1100_M5Core2.ino renamed to examples/Unit_ADC_M5Core2/Unit_ADC_M5Core2.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
* Visit for more information: https://docs.m5stack.com/en/unit/adc
77
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/adc
88
*
9-
* describe: ADC. A/D转换器
10-
* date: 2021/8/18
9+
* Product: ADC. A/D转换器
10+
* Date: 2022/7/11
1111
*******************************************************************************
1212
Please connect to Port A,Use ADC Unit to convert 0 ~ 12V analog voltage into
1313
16-bit data and display it on the screen. 请连接端口A,利用ADC单元将0 ~
1414
12V模拟电压转换成16位数据显示在屏幕上。
1515
*/
1616

1717
#include <M5Core2.h>
18-
1918
#include "M5_ADS1100.h"
2019

2120
ADS1100 ads;

library.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"name": "M5_ADS1100",
3-
"description": "Library for M5_ADS1100",
2+
"name": "M5-ADS1100",
3+
"description": "Library for Unit & Hat ADC",
44
"keywords": "ADS1100",
55
"authors": {
66
"name": "M5Stack",
77
"url": "http://www.m5stack.com"
88
},
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/m5stack/M5_ADS1100.git"
11+
"url": "https://github.com/m5stack/M5-ADS1100.git"
1212
},
1313
"version": "0.0.1",
1414
"frameworks": "arduino",
1515
"platforms": "espressif32"
16-
}
16+
}

library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name=M5_ADS1100
1+
name=M5-ADS1100
22
version=0.0.1
33
author=M5Stack
44
maintainer=M5Stack
5-
sentence=Library for M5_ADS1100
5+
sentence=Library for Unit & Hat ADC
66
paragraph=See more on http://M5Stack.com
77
category=Device Control
8-
url=https://github.com/m5stack/M5_ADS1100
8+
url=https://github.com/m5stack/M5-ADS1100
99
architectures=esp32
1010
includes=M5_ADS1100.h

0 commit comments

Comments
 (0)