element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs EFM32™︎ Zero Gecko Starter Kit w/ Sensor Card: logging to SD card
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 1 Dec 2014 12:02 AM Date Created
  • Views 410 views
  • Likes 4 likes
  • Comments 4 comments
  • RoadTest
  • low_power
  • silabs
  • cortex
  • embedded
  • efm32
  • arm
  • sdcard
  • feature_tutorial
Related
Recommended

EFM32™︎ Zero Gecko Starter Kit w/ Sensor Card: logging to SD card

Jan Cumps
Jan Cumps
1 Dec 2014

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.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

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.

 

image

 

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

 

imageimage

 

 

 

The project is attached here. Good luck

Attachments:
STK3200_weatherstation_sd_logger.zip
  • Sign in to reply
  • Jan Cumps
    Jan Cumps over 8 years ago

    Wiring info:

    image

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    Success. I've attached the project to the original blog post.

    Here's the content of the log file after 8 samples:

     

     

    temperature;humidity;uv
    21125000;00040455;00000000
    21114000;00040737;00000000
    21104000;00040722;00000000
    21104000;00040699;00000000
    21104000;00040707;00000000
    21104000;00041080;00000000
    21125000;00040989;00000000
    21114000;00040981;00000000

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    I have the minimalist weather station running.

     

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

       text   data    bss    dec    hex filename

       8636    116    240   8992   2320 STK3200_weatherstation_sd_logger.axf

     

    There's no energy optimization yet, and no SD card logging.

     

    int main(void)
    {
    
    
      int              objectDetect;
    
    
      I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT;
      uint32_t         rhData;
      bool             si7013_status, si1147_status;
      int32_t          tempData;
      uint16_t         uvData;
      uint32_t         vBat = 3300;
      bool             lowBatPrevious = true;
      bool             lowBat = false;
    
    
      /* Chip errata */
      CHIP_Init();
    
    
      /* Misc initalizations. */
      gpioSetup();
      adcInit();
    
    
      /* Misc timers. */
      RTCDRV_Init();
      RTCDRV_AllocateTimer(&periodicUpdateTimerId);
    
    
      /* Initialize I2C driver, using standard rate. */
      I2CDRV_Init(&i2cInit);
    
    
      si7013_status = Si7013_Detect(I2C0, SI7013_ADDR);
      si1147_status = Si1147_Detect_Device(I2C0, SI1147_ADDR);
      /*configure prox sensor to enter low power state*/
      Si1147_ConfigureDetection(I2C0, SI1147_ADDR, true);
      RTCDRV_StartTimer(periodicUpdateTimerId, rtcdrvTimerTypePeriodic,
                        PERIODIC_UPDATE_MS, periodicUpdateCallback, NULL);
    while (1)
      {
        if (updateMeasurement)
        {
          performMeasurements(&rhData, &tempData, &uvData, &objectDetect, &vBat);
          updateMeasurement = false;
          if (lowBatPrevious)
              lowBat = (vBat <= LOW_BATTERY_THRESHOLD);
          else
              lowBat = false;
          lowBatPrevious = (vBat <= LOW_BATTERY_THRESHOLD);
        }
    //    EMU_EnterEM2(false);
      }

     

     

    It seems that it's not possible to attach files to comments.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 8 years ago

    As a first exercise, I have created a new project based on the weatherstation example:

    image

    I have removed all code related to the user interface: buttons, screen, gesture, and the majority of timers.

    This gives me a project with the following size in Debug configuration:

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

       text   data    bss    dec    hex filename

       8756    116    236   9108   2394 STK3200_weatherstation_sd_logger.axf

    I am now going to rework that stripped down example so that it actually does some measurements at regular times.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube