Capsicum

🫑 Retrofit a wired doorbell to add WiFi and make it connected 🔔

power 16340
wireless WiFi
mcu ESP32-C3
ongoing since Oct 2023

Measure battery voltage

esp32c3 access point measure battery voltage medium

View the battery voltage through an access point


Details

  1. Upload the firmware with make
  2. Remove the USB-C cable used for firmware upload
  3. Turn on the power switch
  4. Connect to access point batt with password 12345678
  5. Browser to http://192.168.4.1 on the browser
  6. View hello world

Code

Download code
// The code turns ON the MOSFET for 2 seconds
// and then turns it OFF for 2 seconds.
// The LED is also turned ON and OFF to indicate the state of the MOSFET.
// The serial monitor is used to print the state of the MOSFET.

#define LED 3
#define BATTERY_ENABLE_PIN 6
#define BATTERY_MEASURE_PIN 0

void setup() {
  Serial.begin(115200);
  Serial.println();

  pinMode(LED, OUTPUT);
  pinMode(BATTERY_ENABLE_PIN, OUTPUT);
}

void loop() {
  // FIX: BATTERY_ENABLE_PIN voltage does not change whether it is HIGH or LOW
  pinMode(BATTERY_ENABLE_PIN, LOW);  // Turn ON the MOSFET
  digitalWrite(LED, HIGH);
  Serial.print("MOSFET is ON");
  delay(2000);

  pinMode(BATTERY_ENABLE_PIN, HIGH);  // Turn OFF the MOSFET
  digitalWrite(LED, LOW);
  Serial.print("MOSFET is OFF");
  delay(2000);
}

Makefile

# 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 *.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

References