Skip to content

Latest commit

 

History

History
109 lines (88 loc) · 4.98 KB

README.md

File metadata and controls

109 lines (88 loc) · 4.98 KB

ESP-IDF Component for Cloud Firestore

GitHub Build workflow status GitHub release GitHub issues GitHub top language License: MIT Twitter follow

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

To use this component you need ESP-IDF installed on your machine, see espressif getting started guide on how to do that natively or you can simply use PlatformIO.

How to use this component with PlatformIO:

  1. Install PlatformIO Extension for vscode
  2. Create a new project using ESP-IDF framework
  3. Under the root of the project create a new directory called components
  4. Clone this repo under the components directory
$ cd components
$ git clone https://github.com/kaizoku-oh/firestore.git
  1. To avoid exposing sensitive data in the code we'll store them in environment variables that'll be when building the project.

Add your WiFi SSID, WiFi password, Firebase project ID, Firebase API key as environment variables like the following:

Window (Powershell)

# Set local environment variables
> $env:WIFI_SSID = '"TYPE_YOUR_WIFI_SSID_HERE"'
> $env:WIFI_PASS = '"TYPE_YOUR_WIFI_PASSWORD_HERE"'
> $env:FIRESTORE_FIREBASE_PROJECT_ID = '"TYPE_YOUR_FIREBASE_PROJECT_ID_HERE"'
> $env:FIRESTORE_FIREBASE_API_KEY = '"TYPE_YOUR_FIREBASE_API_KEY_HERE"'

# OPTIONAL: To read and verify the values of the variables that you just set:
> Get-ChildItem Env:WIFI_SSID
> Get-ChildItem Env:WIFI_PASS
> Get-ChildItem Env:FIRESTORE_FIREBASE_PROJECT_ID
> Get-ChildItem Env:FIRESTORE_FIREBASE_API_KEY

Linux (Bash)

# Set local environment variables
$ export WIFI_SSID='"TYPE_YOUR_WIFI_SSID_HERE"'
$ export WIFI_PASS='"TYPE_YOUR_WIFI_PASS_HERE"'
$ export FIRESTORE_FIREBASE_PROJECT_ID='"TYPE_YOUR_FIREBASE_PROJECT_ID_HERE"'
$ export FIRESTORE_FIREBASE_API_KEY='"TYPE_YOUR_FIREBASE_PROJECT_ID_HERE"'

# OPTIONAL: To read and verify the values of the variables that you just set:
$ echo $WIFI_SSID
$ echo $WIFI_PASS
$ echo $FIRESTORE_FIREBASE_PROJECT_ID
$ echo $FIRESTORE_FIREBASE_API_KEY

Don't know where to get your Project ID and API key? Easy:

  • Open you firebase console
  • Go to Project settings
  • Scroll down to SDK setup and configuration
  • Select the Config option and you'll be presented with something like this:

From there you can copy your projectId and apiKey.

const firebaseConfig = {
  apiKey: "YOUR_FIRESTORE_FIREBASE_API_KEY",
  authDomain: "XXXXXXXXXXXXXXXXXXXXXXXX",
  databaseURL: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  projectId: "YOUR_FIRESTORE_FIREBASE_PROJECT_ID",
  storageBucket: "XXXXXXXXXXXXXXXXXXXXXXXX",
  messagingSenderId: "XXXXXXXXXXXXXX",
  appId: "XXXXXXXXXXXXXXXXXXXXXX"
};
  1. Finally you can build project, upload the firmware to the board and start a serial monitor all with a single combined command:
$ pio run --target upload --target monitor

TODO

  • Add contribution guide
  • Refactor code and remove repeated parts
  • Add doxygen comments
  • Add anonymous authentication
  • Add CI/CD
  • Add thread safety

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Resources