(tbd)
During measurement, we collect the following data:
| Data | Size |
|---|---|
| Timestamp | 4 byte |
| Temperature | 2 byte |
| Air Pressure | 2 byte |
| Humidity | 2 byte |
| Battery Voltage | 2 byte |
| Wind speed | 1 byte |
That's up to 13 byte per measurement. But we don't need the timestamp and the battery voltage every time (it's sufficient to save these e.g. once per hour).
So when we measure data every 15 minutes, we produce (4 x 7) + 6 = 34 bytes per hour (= 816 bytes per day, =300kB per year).
The initial idea was to save data on a (micro) SD card. But during development several problems came up:
- the SD card has a really large peak current during power-on (>500mA) - this can be problematic on low battery
- the SD card usually requires a minimum voltage of 2.7V. When we plan to run on battery "as long as possible" (e.g. around 1.7V) we won't be able to write any more
- there's a really annoying leak current of around 50uA, even when switching off GND via a N-Ch MOSFET (e.g. BS170)
So we now use a dedicated NOR-flash memory chip (AT45DB081E-SHN). It only draws 400nA (!) during deep sleep, runs with 1.7-3.6V, has no mechanical interfaces (think of corrosion!) and so on.
The capacity of this flash memory is 8 MBit = 1 MB, so we can save data for more than three years. Data retention is specified with 20 years in industrial environments (-40 to +85 °C).
The SD Card connector anyway remains. If a card insertion is detected (this is signalled by connecting a pin on the connector to GND), we run a function to mount that SD card and copy the contents of the flash memory to the SD card. An "empty" connector doesn't use any power.
-
Format a MicroSD card with FAT32 filesystem. Other filesystems (FAT16, VFAT, ...) will not work. Under Windows, use the
formatutility on the shell to explicitly choose the filesystem type:format e: /FS:FAT32 -
Prepare an empty file called
CAVELOG.DATwith a size of 1MB (data) + 128 Bytes (headers + spare) = 1.048.704 bytes. You find such a file in the repository, or create your own:dd if=/dev/zero of=CAVELOG.DAT bs=1048704 count=1Copy this file on the SD card.
-
Insert MicroSD into SD slot. CaveLogger will detect the card, wake up and present a menu. Select
<COPY>to copy data from flash memory on SD card. -
When copied successfully, leave the menu by selecting
<EXIT>.
(to be done...)
The circuit uses around 1.5μA during idle time. The duty cycle draws around 5mA for around 5 seconds. Most power is drawn when sending data via LoRaWAN, we estimate 20mA for 1 second (###TODO###). So within a 15 minute loop, we draw:
- idle: 15min * 1.5μA = 0.375μAh
- power-on: 5sec * 5mA = 6.95μAh
- sending: 1sec * 20mA = 5.56μAh
- total: 12.9μAh = 113mAh per year
(missing: power can be saved by only sending data every 2 or 4 measurements; writing data to the flash chip requires some additional power once or twice a day - depending on how often data is written)
When we use 2 AA batteries (to get a voltage of 3.0V) we should have at least 1.500-2.000mAh available - more than enough for some years, even in a cold cave. Self-discharge is propably a bigger problem, so we should prefer industrial-grade cells.
A CR2032 is used as backup battery for the real-time clock. The flash memory doesn't need power to retain its data.
| Name | Description | Price | Datasheet |
|---|---|---|---|
| AT45DB081E-SHN | NOR Flash Memory, 8 MBit, SPI, 1.7V | 1,75 € | Datasheet |
| EPSON RX6110SA B | Real Time Clock (RTC) with SPI, ultra low power (130nA) | 1,99 € | Datasheet |
| ATmega 328P-PU | 8 Bit AVR Microcontroller, 32kb flash | 2,25 € | Datasheet |
| BMP280 | Sensor for temperature and pressure. Check for SPI pins on the breakout board! | 1,15 € | Datasheet |
| HopeRF RFM95W | LoRa transceiver, based on SX1276 chipset (868MHz version for EU) | 6-10 € | Website Datasheet |
| SSD1306 | OLED display 128x64 px, I²C (for debugging/development only) | ~2 € | - |
| Wind sensor | Replacement part for anemometer | 20 € | - |
_______
[RESET] PC6 1 | ( ) | 28 PC5 TWI (I²C) SCL
PD0 2 | | 27 PC4 TWI (I²C) SDA
FLASH SPI CS PD1 3 | | 26 PC3
INT0 (RTC INT1) PD2 4 | | 25 PC2 OLED POWER
WIND IN PD3 5 | | 24 PC1 LED
WIND OUT PD4 6 | | 23 PC0 BME280 SPI CS
VCC 7 | | 22 GND
GND 8 | | 21 AREF
PB6 9 | | 20 AVCC
RFM95 DIO1 PB7 10 | | 19 PB5 SPI SCK
RFM95 DIO0 PD5 11 | | 18 PB4 SPI MISO
RFM95 SPI CS PD6 12 | | 17 PB3 SPI MOSI
RTC SPI CS PD7 13 | | 16 PB2
Button_1 PB0 14 |_______| 15 PB1 Button_2
You need to flash the circuit with 3.3V (the RFM95 will be killed with 5V). I recommend to modify an USBASP to work with 3.3V output.
All required libraries are included. The following adjustments have been made to the original source:
-
- adjusted
pffconf.hto disable all features exceptPF_USE_WRITEandPF_FS_FAT32
- adjusted
-
- defined all configuration settings in
lmic-config.h(instead ofproject_config/lmic_project_config.h), disabling all features not required - ported hardware driver (HAL) to AVR (
lmic-hal-avr.c) to be independend of Arduino (a bit "quick&dirty", highly depending on current chipset and layout)
- defined all configuration settings in
-
I2C Master Interface by Peter Fleury
We use the software driver (
i2cmaster.S) because this allows a faster I²C clock speed than the hardware driver (because of our limited clock speed of 1MHz). Additionally, this enabled us to work around a bug in the PCB layout v1.0 (see issue #1), where SDA and SCL pins are swapped.
- Das Klima der Schrattenhöhle - äußerst interessante wissenschaftliche Arbeit zur Klimamessung in Höhlen
- Hitzedraht-Anemometer (mit Schaltplan)
- Umbau Windrad von Reed auf Hallsensoren
- The Art of Designing Remote IoT Devices - Technologies and Strategies for a Long Battery Life