CoyoteUgly
2018. 8. 23. 17:58
ESP32, adc
esp-idf\components\driver\include\driver\gpio.h
esp-idf\components\driver\include\driver\adc.h
esp-idf\components\esp_adc_cal\include\esp_adc_cal.h
0. 참고 사이트
1. 모듈
analog rotation sensor
2. 보드 연결
3.3V 전원 연결

3. 소스 설명
여타의 소스에서는 vTaskDelay 인자로 상수만 사용하였는데
여기에서는 다음과 같은 인자를 사용합니다.
정확히 의미하는 바는 잘 모르겠습니다.
vTaskDelay ( pdMS_TO_TICKS(500) );
esp-idf/components/freertos/include/freertos/projdefs.h:80:
#define pdMS_TO_TICKS( xTimeInMs ) ( ( ( TickType_t ) ( xTimeInMs ) * configTICK_RATE_HZ ) / ( TickType_t ) 1000 )
제가 가진 모듈로 동작을 확인하기 위해
일부 소스를 변경하였습니다.
//static const adc_atten_t atten = ADC_ATTEN_DB_0; // 1/1
static const adc_atten_t atten = ADC_ATTEN_DB_11; // 1/3.6
//esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_12, DEFAULT_VREF, adc_chars); esp_adc_cal_value_t val_type = esp_adc_cal_characterize(unit, atten, ADC_WIDTH_BIT_10, DEFAULT_VREF, adc_chars); |
4. 소스
5. 결과 확인
- analog rotation sensor 이기 때문에 voltage 값은 무시하세요.
- rotation sensor의 위치에 따라 0 ~ 4095의 raw ADC 값으로 표현되었습니다.

I (0) cpu_start: App cpu up. I (209) heap_init: Initializing. RAM available for dynamic allocation: I (216) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (222) heap_init: At 3FFB32F0 len 0002CD10 (179 KiB): DRAM I (228) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM I (234) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (241) heap_init: At 40088CA4 len 0001735C (92 KiB): IRAM I (247) cpu_start: Pro cpu start user code I (265) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. eFuse Two Point: NOT supported eFuse Vref: NOT supported Characterized using Default Vref Raw: 4095 Voltage: 4774mV Raw: 4095 Voltage: 4774mV Raw: 4095 Voltage: 4774mV Raw: 4095 Voltage: 4774mV Raw: 4095 Voltage: 4774mV Raw: 4095 Voltage: 4774mV Raw: 3465 Voltage: 4774mV Raw: 2864 Voltage: 4774mV Raw: 2601 Voltage: 4774mV Raw: 2447 Voltage: 4774mV Raw: 1360 Voltage: 4774mV Raw: 788 Voltage: 6496mV Raw: 525 Voltage: 5218mV Raw: 124 Voltage: 1341mV Raw: 0 Voltage: 142mV |