-
Notifications
You must be signed in to change notification settings - Fork 3
Logging Data to the SD Card
- How to Log Data to the SD Card
- Setting Up Your Hardware
- Downloading Your Code
- Initializing Your Sensors
- Uploading Your Code
- Testing Your Code
- Troubleshooting
This guide is to help you get familiar with the process of logging data from sensors to the SD card. To do this, we will demonstrate this with the Adafruit Feather M0 Adalogger board that has a build in SD card chip reader. We will also be using the DS3231 Precision Real Time Clock (RTC) Featherwing board as well as the Featherwing Tripler Mini Kit.
Before you start, make sure you have installed both Arduino and Loom.
The first step you need to do is make sure your hardware is properly setup. If you are not using the same boards, make sure to wire it up correctly and ask for help if you are unsure about anything.
If you are using the same setup, the process is as simple as plugging the Feather M0 and RTC Featherwing board into the Tripler Mini Kit. The positions you plug the boards in does not matter. If you choose to stack the two boards or put them side to side will have the same result.
If you followed our Arduino and Loom download guide, you should have all the libraries installed. Open Arduino and open the SD programming file by going to File > Examples > Loom > Logging Platforms > SD.
You will initialize all of your sensors within the config.h file. Assuming you are using the same hardware, you will not need to edit the SD.ino file at all.
Your initial SD config file should look like the picture above. What we need to do is initialize all of the sensors we will be using (in our case, it would only be the RTC). This example will not be using the "PCF8523" component. Delete the following from your code:
{\
'name':'PCF8523',\
'params':'default'\
}\
To do this, you will need to look up the instantiation documentation in the Loom Github. Once in the Loom documentation, you will need to navigate through the repository for the correct sensor you are using. If you aren't sure where your sensor is, be sure to ask!
Above is the image of the RTC config in the Github Repository. You can find it through the pathway Loom > examples > RTC > BasicRepeatingRTC_DS3231 > config.h. We will be using the DS3231 part of the instantiation. Copy and paste the following code that can be found from the picture above:
{\
'name':'DS3231',\
'params':[11,true]\
},\
IMPORTANT: If you are pasting the code at the bottom of your config file, remove the comma in the last line. You will also need to insert a comma before the ' \ 'of the last line of the previous component.
Your code should look something like this.
Once you have initialized your sensors, you should be able to test it! Connect your board with your computer with a USB cable and make sure the LED on the board lights up. If it does, upload the code using the arrow in the top left corner. Note, compiling the code will take a few minutes. This is to be expected. Make sure you wait until it states "successful compile".
You will see a bunch of orange text at the bottom of your screen saying "invalid library". You may ignore that and wait until it compiles.
Once your code is uploaded, you may want to see if your code is working. In the top right corner of the Arduino program, click the Serial Monitor button (magnifying glass). Near the top of the monitor, it should have a list of text and in it, it should say the RTC has been initialized. The display should also constantly update with new values at the bottom. If it does, congratulations! You successfully initialized the RTC and are recording data.
If it does not, refer to our troubleshooting section.
There are several reasons why this might happen. First, you have to determine if it's a hardware or software issue. In some cases, one of the boards may not work properly. To test if it's hardware, use a multimeter to test the power and ground pins of the boards. If everything looks fine, it might be a software issue.
If it's a software issue, it may have to do with the way you initialized the component. Ensure that you copy and pasted the code from the Github exactly as it appears. However, there are special syntax that may mess up the program. For example, a comma needs to appear at the end of every component except the last one. If you are unsure about the syntax, be sure to ask someone.
If you have waited more than 10 minutes, your board may have "hanged" meaning the computer is trying to upload the code to a port on the board that doesn't exist. If this happens, double click the reset button on the Featherboard. The LED should start to blink. If it does, go to the Tools bar at the top of Arduino and then go to Port and click the Port that lists the Featherwing. Doing this allows the board to "create" another port for the program to use to upload the code.
Be sure you have installed Arduino and Loom by following the listed guides.
If you have asked someone and they couldn't find it, the sensor might not be documented in the Github repository. Loom is continuously under development so there may be a chance that your sensor may be added in the near future!