Maker Feather AIOT S3 Data Logging To Firebase

Maker Feather AIOT S3 Data Logging To Firebase

Introduction

The Maker Feather AIOT S3 is a development board that combines the power of the ESP32 microcontroller with built-in Wi-Fi connectivity and the capability to interface with various sensors and peripherals. It is designed for Internet of Things (IoT) applications and offers a convenient platform for collecting and logging data.

 

Data logging refers to the process of recording and storing data over time. With the Maker Feather AIOT S3, you can easily log data from sensors connected to the board and send it to Firebase, a cloud-based platform provided by Google.

 

Firebase is a powerful backend platform that offers a suite of services for building web and mobile applications. It includes a Realtime Database, which is a NoSQL cloud-hosted database that allows you to store and sync data in real-time. By integrating the Maker Feather AIOT S3 with Firebase, you can log sensor data and store it securely in the cloud.

 

Logging data to Firebase enables you to access and analyze the collected information from anywhere with an internet connection. It provides a scalable and reliable solution for managing and processing sensor data, making it ideal for IoT projects and applications that require remote monitoring, data analysis, or real-time updates.

 

By leveraging the capabilities of the Maker Feather AIOT S3 and Firebase, you can create data logging applications that enable efficient data collection, visualization, and analysis. Whether you're building environmental monitoring systems, smart home devices, or industrial automation solutions, the combination of the Maker Feather AIOT S3 and Firebase offers a powerful platform for data logging and management.

 

What is Firebase?

Firebase is a comprehensive mobile and web development platform provided by Google. It offers a wide range of tools and services that simplify the development process, allowing developers to build high-quality applications quickly and efficiently.

 

Firebase provides a variety of services that can be used individually or combined to create powerful applications. Some of the key features and services offered by Firebase include:

  1. Realtime Database: Firebase Realtime Database is a cloud-hosted NoSQL database that allows you to store and sync data in real time. It enables developers to build real-time collaborative applications, chat systems, live data updates, and more.

  2. Authentication: Firebase Authentication provides a secure and easy-to-use authentication system for your applications. It supports various authentication methods, such as email/password, social logins (Google, Facebook, etc.), and anonymous authentication.

  3. Cloud Firestore: Cloud Firestore is a flexible and scalable NoSQL document database offered by Firebase. It offers powerful querying and indexing capabilities, real-time updates, offline support, and seamless integration with other Firebase services.

  4. Cloud Storage: Firebase Cloud Storage provides a simple and cost-effective solution for storing and serving user-generated content, such as images, videos, and other files. It offers secure file uploads and downloads, scalability, and integration with other Firebase services.

  5. Cloud Functions: Firebase Cloud Functions allows you to run server-side code in a serverless environment. You can write functions that respond to events from Firebase services or HTTP requests, enabling you to automate tasks, process data, and build serverless backends.

  6. Hosting: Firebase Hosting provides fast and secure web hosting for your applications. It allows you to deploy web applications, static content, and dynamic content with ease. Firebase Hosting includes features like SSL support, CDN caching, and easy deployment workflows.

  7. Analytics: Firebase Analytics provides detailed insights into user behavior and app usage. It helps you understand your users, track key metrics, and make data-driven decisions to optimize your application.

  8. Cloud Messaging: Firebase Cloud Messaging (FCM) enables you to send push notifications to your users across multiple platforms, including Android, iOS, and web. It helps you engage and re-engage users by sending targeted and personalized notifications.

 

 

Overview

The overview of the project is as shown in the figure below

The workflow for the project is as shown below 

  • The Maker Feather AIOT S3 authenticates as a user with email and password.
  • Upon successful authentication, the Maker Feather AIOT S3 obtains the user UID.
  • The database has security rules that limit user access to their corresponding UID nodes.
  • The Maker Feather AIOT S3retrieves temperature and humidity from the SHT40 sensor.
  • The Maker Feather AIOT S3 captures the epoch time as a timestamp alongside the sensor readings.
  • The Maker Feather AIOT S3 sends temperature, humidity, and timestamp to the database.
  • Periodically, new readings are added to the Firebase Realtime Database, creating a record of all readings.

 

Hardware

The hardware setup for this project is quite simple since we will be using the Adafruit Sensirion SHT40 Temperature & Humidity Sensor and the Adafruit FeatherWing 128x32 OLED Board. The OLED is optional since it used to display the sensors value only. Using other OLED is also possible. Just connect to the appropriate pin. 

 

Once the hardware part is done, we can move to the software part. 

 

Software

The software part is divided into 2 parts. First we would look on to setup the Firebase and next we would look into the code.

 

Firebase

1) Create Firebase Project

1) Go to Firebase and sign in using a google accout. Click the Get Started button.

 

2) Click the "Create a Project"

 

3) Give a name to the project and click both 2 and 3. And click continue button.

 

4) Enable the google analytics (this is optional)

 

5) Choose the analytic location and check the I accept button. And click "Create project"

 

6) Now the project is ready. Click Continue. 

 

2) Configure Authentication Methods

To enable email and password authentication, the initial step involves configuring authentication methods for your application.

"User identity is crucial for most applications, as it facilitates user login and identification (in this case, for the Maker Feather AIOT S3). By identifying the user, the application can securely store user data in the cloud and deliver a consistent personalized experience across all the user's devices." For more detailed information on authentication methods, you can refer to the documentation.

 

1) On the left sidebar click "Build" and choose "Authentication".

 

2) Go to to Sign-in-method and choose "Email/Password"

 

3) Enable the authentication method and click Save

 

4) The authentication with email and password is now enabled.

 

5) Now, we can need to add a user. On the Authentication tab, select the Users tab at the top. Then, click on Add User

 

6) Provide an email address for the authorized user, which can be your Google account email or any other email of your choice. Alternatively, you can create a new email specifically for this project. Set a password that grants you access to sign in to your application and utilize the database. Remember to securely store the password in a safe location, as you will require it in the future. Once you have completed the process, click on the "Add user" button.

 

7) A new user was successfully created and added to the Users table.

Observe that Firebase generates a distinct UID (User ID) for every registered user. The user UID serves the purpose of user identification and enables us to manage access to the project or database, granting or denying permissions accordingly. Additionally, a column is dedicated to recording the date of the last sign-in. Currently, this field remains empty as we have yet to sign in using that particular user.

 

3) Get Project API Key

1) On the Project Overview, clcik the gear icon and choose Project settings.

 

2) Copy the Web API Key and saved it at other place because we will need it later.

 

4) Set up Realtime Database

Now its time to create the realtime database and set up the rules.

1) On the left sidebar, go to "Build" and choose "Realtime Database" and choose "Create Database".

 

2) Next choose the database location. Choose the one closest to your location.

 

3) For the security rules of the database, select Start in test mode. 

 

4) The database is now created. Copy and save the database url since we need it later in Maker Feather code.

 

5) Remember previously we set the rules. Go back to the Rules tab and choose Edit rules, paste the following rules and click Publish.

 

The following rules provide access to a node that corresponds to the authenticated user's UID. This ensures that each authenticated user can only access their own data. Specifically, the user can only access nodes that reside under a parent node with a matching user UID. It is important to note that if there are other data published in the database that is not located under a node associated with the user's UID, the user will not be able to access that data. These rules enforce data segregation, ensuring that each user can only access their own designated data within the database.

 

The Code 

For the code we will be using the Visual Studio Code. 

 

 

We need to add the following library to the project.

Adafruit SHT40 Temperature and Humidity Sensor

Adafruit GFX Library

Adafruit_SSD1306

Firebase ESP Client

 

Follow the steps below to add the library. Go to PIO Home icon and choose the Libraries tab. Search for "adfruit sh". Select the Adafruit SHT4x Library.

 

 

 

Then, click Add to Project and select the project you’re working on.

Repeat this step to add the remaining library.

 

And this is the complete code

 

Demo

 

 

 

Hardware Components

Adafruit Sensirion SHT40 Temperature & Humidity Sensor - STEMMA QT / Qwiic Out Of Stock

Maker Feather AIoT S3

S$28.50 S$28.50

x 1 unit(s)