Skip to content

Commit 744acf4

Browse files
committed
2.1.3
1 parent adea0f5 commit 744acf4

File tree

9 files changed

+1066
-1
lines changed

9 files changed

+1066
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
ADC read voltage via GPIO1 simple test.
3+
Base on Wi_Fi LoRa 32 V3.2
4+
by Aaron.Lee from HelTec AutoMation, ChengDu, China
5+
成都惠利特自动化科技有限公司
6+
www.heltec.cn
7+
*/
8+
9+
void setup() {
10+
// Initialize serial communication at 115200 bits per second:
11+
Serial.begin(115200);
12+
13+
// Set the resolution of the analog-to-digital converter (ADC) to 12 bits (0-4095):
14+
analogReadResolution(12);
15+
16+
// Set pin 37 as an output pin (used for ADC control):
17+
pinMode(37, OUTPUT);
18+
19+
// Set pin 37 to HIGH (enable ADC control):
20+
digitalWrite(37, HIGH);
21+
}
22+
23+
void loop() {
24+
// Read the raw analog value from pin 1 (range: 0-4095 for 12-bit resolution):
25+
int analogValue = analogRead(1);
26+
27+
// Read the analog voltage in millivolts from pin 1:
28+
int analogVolts = analogReadMilliVolts(1);
29+
30+
// Print the scaled analog value (scaled by a factor of 490/100):
31+
Serial.printf("ADC analog value = %d\n", analogValue * 490 / 100);
32+
33+
// Print the scaled millivolts value (scaled by a factor of 490/100):
34+
Serial.printf("ADC millivolts value = %d\n", analogVolts * 490 / 100);
35+
36+
// Add a delay of 1 second between readings for clear serial output:
37+
delay(1000);
38+
}
39+
40+

0 commit comments

Comments
 (0)