diff --git a/examples/Unit/ADC_ADS1100/ADC_ADS1100.ino b/examples/Unit/ADC_ADS1100/ADC_ADS1100.ino deleted file mode 100644 index aef161e..0000000 --- a/examples/Unit/ADC_ADS1100/ADC_ADS1100.ino +++ /dev/null @@ -1,79 +0,0 @@ -/* -******************************************************************************* -* Copyright (c) 2021 by M5Stack -* Equipped with Atom-Lite/Matrix sample source code -* 配套 Atom-Lite/Matrix 示例源代码 -* Visit for more information: https://docs.m5stack.com/en/products -* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/products -* -* Product: ADC. A/D转换器 -* Date: 2021/8/18 -******************************************************************************* - Please connect to Port A,Use ADC Unit to convert 0 ~ 12V analog voltage into -16-bit data and display it on the Serial. 请连接端口,利用ADC单元将0 ~ -12V模拟电压转换成16位数据显示在串口上。 -*/ - -#include -#include "M5_ADS1100.h" - -ADS1100 ads; - -void setup(void) { - M5.begin(); // Init M5Atom. 初始化M5Atom - Wire.begin(26, 32); // Initialize pin 26,32. 初始化26,32引脚 - - // The address can be changed making the option of connecting multiple - // devices 地址可以改变,以连接多个设备 - ads.getAddr_ADS1100( - ADS1100_DEFAULT_ADDRESS); // 0x48, 1001 000 (ADDR = GND) - - // The ADC gain (PGA). ADC增益(PGA) - ads.setGain(GAIN_ONE); // 1x gain(default) - // ads.setGain(GAIN_TWO); // 2x gain - // ads.setGain(GAIN_FOUR); // 4x gain - // ads.setGain(GAIN_EIGHT); // 8x gain - - // Device operating mode. 设备工作模式 - ads.setMode(MODE_CONTIN); // Continuous conversion mode (default) - // ads.setMode(MODE_SINGLE); // Single-conversion mode - - // Data rate. 数据速率 - ads.setRate(RATE_8); // 8SPS (default) - // ads.setRate(RATE_16); // 16SPS - // ads.setRate(RATE_32); // 32SPS - // ads.setRate(RATE_128); // 128SPS - - ads.setOSMode( - OSMODE_SINGLE); // Set to start a single-conversion. 设置开始一次转换 - - ads.begin(); // Sets up the Hardware. 设置硬件 -} - -void loop(void) { - byte error; - int8_t address; - - address = ads.ads_i2cAddress; - - Wire.beginTransmission(address); - error = Wire.endTransmission(); - if (error == 0) // If the device is connected. 如果连接上设备 - { - int16_t result; - - Serial.println("Getting Differential Reading from ADS1100"); - Serial.println(" "); - result = ads.Measure_Differential(); - Serial.print("Digital Value of Analog Input between Channel 0 and 1: "); - Serial.println(result); - char data[20] = {0}; - sprintf(data, "%d", result); - Serial.println("-----------"); - } else { - Serial.println("ADS1100 Disconnected!"); - Serial.println("-----------"); - } - - delay(1000); -} \ No newline at end of file diff --git a/examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino b/examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino deleted file mode 100644 index 0d124be..0000000 --- a/examples/Unit/AMeter_ADS1115/AMeter_ADS1115.ino +++ /dev/null @@ -1,96 +0,0 @@ -/* -******************************************************************************* -* Copyright (c) 2021 by M5Stack -* Equipped with Atom-Lite/Matrix sample source code -* 配套 Atom-Lite/Matrix 示例源代码 -* Visit for more information: https://docs.m5stack.com/en/products -* 获取更多资料请访问:https://docs.m5stack.com/zh_CN/products -* -* Product: Ameter_ADS1115. 电流计 -* Date: 2021/8/19 -******************************************************************************* - Please connect to Port ,Measure current and display. - 请连接端口,测量电流并显示到串口上 - Pay attention: EEPROM (0x51) has built-in calibration parameters when leaving -the factory. Please do not write to the EEPROM, otherwise the calibration data -will be overwritten and the measurement results will be inaccurate. 注意: EEPROM -(0x51)在出厂时具有内置的校准参数。请不要写入EEPROM,否则校准数据会被覆盖,测量结果会不准确。 -*/ - -#include -#include "M5_ADS1115.h" - -Ammeter ammeter; - -float page512_volt = 2000.0F; - -int16_t volt_raw_list[10]; -uint8_t raw_now_ptr = 0; -int16_t adc_raw = 0; - -int16_t hope = 0.0; - -ammeterGain_t now_gain = PAG_512; - -void setup(void) { - M5.begin(); // Init M5Atom. 初始化M5Atom - Wire.begin(); - - ammeter.setMode(SINGLESHOT); - ammeter.setRate(RATE_8); - ammeter.setGain(PAG_512); - hope = page512_volt / ammeter.resolution; - // | PAG | Max Input Voltage(V) | - // | PAG_6144 | 128 | - // | PAG_4096 | 64 | - // | PAG_2048 | 32 | - // | PAG_512 | 16 | - // | PAG_256 | 8 | - - Serial.printf("2A"); -} - -void loop(void) { - M5.update(); // Check the status of the key. 检测按键的状态 - if (M5.Btn.wasPressed()) { - ammeter.setMode(SINGLESHOT); // Set the mode. 设置模式 - ammeter.setRate(RATE_8); // Set the rate. 设置速率 - ammeter.setGain(PAG_512); - now_gain = PAG_512; - hope = page512_volt / ammeter.resolution; - - for (uint8_t i = 0; i < 10; i++) { - volt_raw_list[i] = 0; - } - } - - float current = ammeter.getCurrent(); - - volt_raw_list[raw_now_ptr] = ammeter.adc_raw; - raw_now_ptr = (raw_now_ptr == 9) ? 0 : (raw_now_ptr + 1); - - int count = 0; - int total = 0; - - for (uint8_t i = 0; i < 10; i++) { - if (volt_raw_list[i] == 0) { - continue; - } - total += volt_raw_list[i]; - count += 1; - } - - if (count == 0) { - adc_raw = 0; - } else { - adc_raw = total / count; - } - - Serial.printf("Hope volt:%.2f mAn\n", page512_volt); - - Serial.printf("Cal volt:%.2f mA\n", current); - - Serial.printf("Cal ADC:%.0f\n", adc_raw * ammeter.calibration_factor); - - Serial.printf("RAW ADC:%d\n\n", adc_raw); -} \ No newline at end of file