Inspired by the Zero Gecko Starter Kit roadtest review of  baldengineer , I'm going to try if I can get the weather station example log its data to an SD card.

The example shows its data to the lcd screen by default. I wonder if it's possible to log to a microSD in stead.

 

 

We already have the weather station up and running, and we have a working SD card example.

But there are roadblocks: baldengineer has made an attempt to do this, and he ran out of memory space.

I've made  some calculations based on the memory footprint of both examples,and they exceed the available resources significantly:

 

The SD Card code, in debug, takes:

 

Running size tool

arm-none-eabi-size "STK3200_sd_card.axf"

   text   data    bss    dec    hex filename

  19828    180   2716  22724   58c4 STK3200_sd_card.axf

      

 

The Weather Station footprint:

Running size tool

arm-none-eabi-size "STK3200_weatherstation_2.axf"

   text   data    bss    dec    hex filename

  26024    140   2552  28716   702c STK3200_weatherstation_2.axf

      

 

These are the resources available on the starter kit's processor:

Silicon Labs EFM32 Zero Gecko Microcontroller with 32 KB Flash and 4KB RAM - EFM32ZG222F32

      

The 32 KB Flash needs to cover what is (if we naively combine the two compilations) 19828 + 180 + 26024 + 140 = 46172

The 4KB RAM has to host 180 + 2716 + 140 + 2552 = 5588

 

 

In this blog I will try to get an example that measures and logs all the measurements done by the weather station.

I will not try to replicate the motion detection or LCD part. That is part of the weather station's GUI, and I'm trying to replace that by a logging mechanism.

 

If I get a code base that fits the resource available in the kit, I'll try to include some additional power save measures.

No guarantees here - the footprint above is way over the controllers capabilities, so we'll have to reduce both code and memory significantly.

 

 

Update: working data logger + wiring diagram

 

You can follow the steps I took to get to a working example in the comments below.

The example I have attached here is functional, but not optimized for energy and sturdiness.

 

sdlog.png

 

What should happen for energy optimization:

  1. The processor should go in low power mode in between measurements
  2. Complete power-off of the SD card when not writing
  3. Buffer measurements and write to SD card when buffer is full

 

What should happen for sturdiness and user experience:

  1. A mechanism to safely remove the SD card while not being written (maybe a button push when you want to remove the SD card, a led blinking slow when the card can be removed, and the led flashing fast when the buffer is reaching its limit while the SD card is out
  2. Management for file full
  3. timestamp

 

Size statistics with full debug configuration:

arm-none-eabi-size "STK3200_weatherstation_sd_logger.axf"

   text   data    bss    dec    hex filename

  32536    120   1384  34040   84f8 STK3200_weatherstation_sd_logger.axf

 

Size stats with release target and size optimization:

 

arm-none-eabi-size "STK3200_weatherstation_sd_logger.axf"

   text   data    bss    dec    hex filename

  16924    116   1380  18420   47f4 STK3200_weatherstation_sd_logger.axf

 

 

The wiring

 

Photo+03-12-14+01+00+17.jpg Scan.jpg

 

 

 

The project is attached here. Good luck