Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ESP8266 Home Automation Projects

You're reading from   ESP8266 Home Automation Projects Leverage the power of this tiny WiFi chip to build exciting smart home projects

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781787282629
Length 196 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Constantin Tambrea Constantin Tambrea
Author Profile Icon Constantin Tambrea
Constantin Tambrea
Catalin Batrinu Catalin Batrinu
Author Profile Icon Catalin Batrinu
Catalin Batrinu
Arrow right icon
View More author details
Toc

Working offline


If your data is more sensitive and you don't want to share it across the Wi-Fi network or you don't have Wi-Fi connectivity, a solution is to store your data on an SD card.

Let's see how data can be stored on an SD card.

Necessary hardware that will be used:

  • Wemos D1 mini:
  • microSD card shield:
  • microSD card:

Since the microSD card is a shield for the Wemos D1 mini, it is easy to stack them; you just need to solder the pins that are coming into the package:

Let's determine the size of the SD card with the following sketch.

Include the SPI.h and the SD library:

#include <SPI.h> 
#include <SD.h> 

Set up variables using the SD utility library functions:

Sd2Card card; 
SdVolume volume; 
SdFile root; 
const int chipSelect = D8; 

In the setup function, we will determine if the card is inserted or not and the card details will be read over SPI:

void setup() 
{ 
  Serial.begin(115200); 
  Serial.print("\nInitializing SD card..."); 

Use the initialization code from the utility libraries...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image