🫑 A retrofitted wired audio doorbell with added WiFi connectivity 🔔
Measure raw ADC value using the ESP32-C3 ADC CH0
This code outputs the reading of the raw ADC value using the ESP32-C3 ADC CH0 of GPIO0 pin.
Serial output from the firmware.
#define BATTERY_ENABLE_PIN 6 #define BATTERY_MEASURE_PIN 0 // ADC1_CH0, GPIO0 void setup() { Serial.begin(115200); Serial.println(); pinMode(BATTERY_ENABLE_PIN, OUTPUT); digitalWrite(BATTERY_ENABLE_PIN, HIGH); } void loop() { digitalWrite(BATTERY_ENABLE_PIN, LOW); delayMicroseconds(10); int sum = 0; for (int i = 0; i < 100; i++) { sum = sum + analogRead(BATTERY_MEASURE_PIN); } float adcValue = sum / 100.0; Serial.print("Raw ADC Value: "); Serial.println(adcValue); delay(2000); digitalWrite(BATTERY_ENABLE_PIN, HIGH); Serial.println(); delay(2000); }
# Description: Makefile for the demo code # Usage: make [lint] [compile] [upload] [clean] BOARD := esp32:esp32:esp32c3:CDCOnBoot=cdc PORT ?= /dev/cu.usbmodem1410* BUILD = build .PHONY: default lint compile upload clean default: lint compile upload clean lint: cpplint --extensions=ino --filter=-legal/copyright,-runtime/int,-readability/todo,-whitespace/line_length *.ino compile: clean lint arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./ upload: arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD) clean: rm -rf build