
Timezone: Europe/London
The ESP32 is a powerful microprocessor chip. Successor to the ESP8266, it is available in various types of development board.
My favourite is the Adafruit ESP32 Feather V2 but there are lots of others available, with various different features.
The main spec for the Adafruit ESP32 Feather V2 is as follows:
Dual core 240MHz Xtensa® processor
8 MB Flash and 2 MB PSRAM, Integrated 520 KB SRAM
USB Type C port instead of the usual Micro B
Designed for low power usage: verified with a PPK to draw 70uA
from the Lipoly battery in deep sleep and 1.2mA in light sleep.
Integrated 802.11b/g/n HT40 Wi-Fi transceiver, baseband, stack and
LWIP, with a tuned PCB antenna.
Integrated dual-mode Bluetooth (classic and BLE)
Real Time Clock.
Built-in battery charging when powered over USB-C
LiPoly battery monitor with two 200K resistor dividers
Reset and User (I38) buttons to reset the board and as a separate input.
A programmable micro LED and a NeoPixel mini RGB LED with controllable power pin.
It has plenty of programmable GPIO pins too.
Ultra-low noise analog amplifier
Hall sensor
10x capacitive touch interface
32 kHz crystal oscillator
3x UARTs
3x SPI
2x I2C
12x ADC input channels
2x I2S Audio
2x DAC
PWM/timer input/output available on every GPIO pin
Coming in at around £20.00 I think they are excellent value.
The feather can run Arduino or Micropython.
Micropython does take up some of the dynamic ram but I have run some pretty large programmes on them without any problems.
As an example:
Free memory check on startup, with micropython installed: 110,096
After loading programs, including supporting libraries, which run in at 1364 lines of code @ 49,659 bytes, free memory 50,176
So the program when loaded takes up 59,920 bytes
The feather has 320K of DRAM for program use, but this is divided equally between the runtime heap and statically allocated DRAM.
So out of our 160K I've used around 60K, and we have about 5K left. I will assume the other 95K is taken up by micropython and the operating system.
All in all, not bad really, and I've had an ESP running this program constantly for over a year without problems.
However, a margin of 5K is pretty slim, but having said that, the program periodically downloads chunks of data from the net, at roughly 4K a chunk and it hasn't complained.
I suspect those chunks go to the heap before being written to file and memory freed.
I mention above I've had this programme running for over a year constantly, however there is a caveat.
In the past I've had problems with even small programmes running constant loops crashing after a few days.
I never really found out why, but I put this down to bad programming and perhaps the DRAM filling up or an incrementing variable becoming too large for its storage allocation.
The aforementioned program does not suffer from these kinds of overheads because 95% of every day it is in Deepsleep.
Basically, once an hour, it wakes up, does its stuff, then hibernates.
This is a real bonus, because waking from deepsleep is pretty much the same as a reboot, so it wakes up completely refreshed.
This is not without its drawbacks though, because as you have probably already guessed, it will lose all it stored variables.
There is a way around this though. You can write data readings, and anything you like really, to file. There is plenty of storage space, 8Mb to be precise.
It has an RTC, so you can keep a clock going for accurate timing, and you can store variables in the RTC memory, as this is kept alive during deepsleep.
I've only ever been able to store numeric variable there though, and 32 8 bit integers, or 16 32 bit integers or floats seems to be the limit.
Also, don't rely on the clock if you need really precise timing, as I've found it can gain up to several seconds an hour.