element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • 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 Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Data Logging over SPI onto SD Shield
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 416 subscribers
  • Views 488 views
  • Users 0 members are here
Related

Data Logging over SPI onto SD Shield

e14 Contributor
e14 Contributor over 13 years ago

So I have a project that has run into a snare on me. I have to data log 4 thermocouples for a period of time and want to record that data onto an SD card.

 

So I am using an Arduino Uno with (4) Adafruit MAX31855 Breakout boards and an SD Shield from https://www.manylabs.org/product/G0119/

 

So individually I can read the 4 Thermocouple boards in serial over the SPI bus using 4 pins for Chip Select. And it dosent seem to matter which ones I have changed them around to no effect (6, 7, 8, and 9). Same with the SD shield I can read and write to the card no problem at all, but chip select is hard wired to pin 10 on this matching the board default. I should note when I tested these independantly,  I used the default pins on the board for MOSI (11), MISO (12), and SCLK (13) for both setups. I am also using a real world clock board but thats not related as it communicates over I2C.

 

This is where my snare comes in, if I plug the SD shield into the Uno and plug then plug the thermocouple chip select pins, clock, and slave out pins (in the same spots) to the header pins on the SD shield. The logging and code works fine but all 4 of the Thermocouples all read out as zero *C. It is not a wiring issue beause if I purposely disconnect a chip select pin out, the serial print out on that specific thermocouple gives me my error loop. The other 3 continue to read at zero so everything is wired correctly. Everything is dancing, I just cant seem to get it all going on the same page of music. Any tips?

 

EDIT: Oh, btw, I am using an auxiliary power as well as USB. I know the 500 mAh over USB isnt going to cut it. Code is also added now too. The 1st file is the code that simply reads out the thermocouple temperatures in the serial monitor. And the 2nd is that code with the attempt to data log it. you'll note the TC chip select pins are moved around, but it dosent matter they wont work even where they were originally.

Attachments:
TC Data Logging Attempt.ino.zip
Read TCs (Serial).ino.zip
  • Sign in to reply
  • Cancel
  • e14 Contributor
    e14 Contributor over 13 years ago

    So after digging further into this and changing libraries to SdFat.h the issue seems to be the SPI speed. With the SD card initialized the thermocouples are zero, with the single line commenetd out in the program that initializes the crad in the setup loop, they all read fine. The code is attached.

     

    So continuing to dig into the Adafruit_MAX31855.h library and I found that in Adafruit_MAX31855.h the function that triggers the thermcouples to readout is:

     

    uint32_t Adafruit_MAX31855::spiread32(void) {

      int i;

      uint32_t d = 0;

     

     

      digitalWrite(sclk, LOW);

      _delay_ms(1);

      digitalWrite(cs, LOW);

      _delay_ms(1);

     

     

      for (i=31; i>=0; i--)

      {

        digitalWrite(sclk, LOW);

        _delay_ms(1);

        d <<= 1;

        if (digitalRead(miso)) {

          d |= 1;

        }

     

     

        digitalWrite(sclk, HIGH);

        _delay_ms(1);

      }

     

     

      digitalWrite(cs, HIGH);

      Serial.println(d, HEX);

      return d;

    }

     

     

     

    The question is how do I change this function to interface with the SPI_HALF_SPEED or SPI_FULL_SPEED as utilized by the SdFat.h library?

     

    THANKS!

    Attachments:
    4-Channel TC Logger 2.21.13.txt.zip
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube