The place where random ideas get written down and lost in time.

2020-11-24 - Blinking LED -- Arduino/ESP32 approach

Category DEV

An even easier way to blink a LED is to not use a LED. An ESP32 or an Arduino Nano both have a LED onboard. All I need is the smallest program that would turn on the onboard LED on a timer/interrupt, and ideally keep the CPU sleeping/idle/suspended the rest of the time.

Some ESP32 dev boards come with a connector designed to power them from a battery, like the “Heltec Wifi Kit 32” ones I have.

The Arduino Nano dev boards have 4 leds (RX, TX, PowerOn, IO). The Power-On is always one when the device is powered. The trace leading to the LED can be cut. A quick online search indicates it can be powered by 3xAA (~ 6V) using the last 2 pins (GND / VIN). However the same research indicates on a Nano board, the FTDI/USB chip will use about 30-40 mA all the time, rendering the effort quite moot.

Another choice is the Digistump Digispark 1. It also has a green Power-On LED as well as an IO LED.

What about the Arduino? How do you “suspend” the Atmega328P in a Nano or the ATTiny?

  • From this thread: https://thekurks.net/blog/2018/1/24/guide-to-arduino-sleep-mode avr/sleep.h defines a sleep_enable() + set_sleep_mode(SLEEP_MODE_PWR_DOWN).
  • It also indicates the only way to wake it up is using an external RTC timer on an interrupt (for example an Adafruit DS3231 Precision RTC controlled via I2C).

The ESP32 for sure has APIs to put it in deep-sleep mode. It’s designed for that: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html 

  • esp_bluedroid_disable(), esp_bt_controller_disable(), esp_wifi_stop().
  • rtc_gpio_isolate(pins...) to disable pullups/pulldowns on IOs.
  • esp_light_sleep_start() or esp_deep_sleep_start().
  • esp_sleep_enable_timer_wakeup() ⇒ wake up from deep sleep using timer.

Can the ULP Processor be used to trigger the LED directly?


 Generated on 2025-01-09 by Rig4j 0.1-Exp-f2c0035