Table of contents
- Setup and reading sensor values
- Using iSDIO while reading the SD card
- Sending measurements from Arduino to Raspberry Pi
- Visualizing on Raspberry Pi — completion
Last time we measured temperature and humidity with DHT22.
This time I want to transmit the measurements — but first, I need to modify the FlashAir iSDIO library.
Using FlashAir's iSDIO and SD Card Functions Simultaneously
Check on Amazon Following the FlashAir Developers tutorial, you can use iSDIO for HTTP connections from a FlashAir card.FlashAir Developers: Arduino Tutorial
However, this tutorial disables the SD card access functionality.
If you use the tutorial's source code as-is, the standard Arduino SD library stops working — so you need to patch the library yourself.
- Download the tutorial source code and unzip it.
arduino_tutorial_06.zip - From the Arduino standard SD library, copy these files into the extracted "iSDIO" folder:
File.cpp, FatStructs.h, SdFatUtil.h, SdFile.cpp, SdVolume.cpp.
Also copy SD.cpp and SD.h, but rename them to SDExt.cpp and SDExt.h.

After copying, the iSDIO folder should look like this:

- Open SDExt.h, SdFat.h, and SdVolume.h in the iSDIO folder, and replace all occurrences of "Sd2Card" with "Sd2CardExt".
- Open File.cpp and SDExt.cpp in the iSDIO folder, and replace "SD.h" with "SDExt.h".
- Zip the iSDIO folder.
- In Arduino IDE, load the ZIP file via:
Sketch > Include Library > Add .ZIP Library
I've put the patched iSDIO library on GitHub:
GitHub - onthehand - iSDIO
Using the Patched iSDIO Library
To access FlashAir storage using the patched library:#include <SDExt.h>
void loop() {
File file = SD.open("file.txt", FILE_READ);
:
file.close();
delay(1000);
The key difference: include "SDExt.h" instead of "SD.h".
Also, add a delay after SD card access.
The reason isn't entirely clear, but accessing WiFi immediately after the SD card causes instability.
Everything else works the same as the standard SD.h library.
When using FlashAir's WiFi with the patched library, change the following from the official tutorial:
- Include "SDExt.h" instead of "utility/Sd2CardExt.h".
- Do not declare "Sd2CardExt card;" globally.
- Change all uses of the card object (e.g., "card.readExtMemory") to use "SD.card" instead (e.g., "SD.card.readExtMemory").
The card object is a member variable of the SD class.
Now that the SD class (SDExt class) is available, access it through the class rather than directly.
Accessing the card object directly from outside the class causes incorrect behavior.
Setup is finally complete. Next time: transmitting sensor data over WiFi.
No comments:
Post a Comment