Chapter 3

Building a Weather Station with TensorFlow Lite for Microcontrollers

About this chapter

This chapter will teach us how to implement a simple weather station with machine learning (ML) to predict the occurrence of snowfall based on the temperature and humidity of the last three hours. In the first part, we will focus on dataset preparation and show how to acquire historical weather data from WorldWeatherOnline. After preparing the dataset, we will show how to train a neural network with TensorFlow and quantize the model to 8-bit with TensorFlow Lite. In the last part, we will deploy the model on the Arduino Nano 33 BLE Sense and Raspberry Pi Pico with TensorFlow Lite for Microcontrollers to predict the occurrence of snowfall from the temperature and humidity recorded over the last three hours.

Devices

| Arduino Nano 33 BLE Sense (Rev1 and Rev2) | Raspberry Pi Pico | SparkFun RedBoard Artemis Nano | | ----------- | ---------------------------------------------------------------- | -- | | ✅ | ✅ | ✅ |

Hardware components

| Sensor | Breadboard | Jumper wires | LEDs | Resistors | Extra | | --------| -----------| ------------ | ---- | --------- | ----- | | 1x AM2302 module with the DHT22 | 1x half-size | 3x | - | - | - |

Software (SW) Environments

| ML | Embedded programming | | --------| -------------------- | | Google Colaboratory | Arduino IDE (or Arduino Web Editor) |

Source code

Recipe Source code There's more
Importing weather data from WorldWeatherOnline
Preparing the dataset
Training the model with TensorFlow
Evaluating the model's effectiveness
Quantizing the model with the TensorFlow Lite converter
Reading temperature and humidity with the Arduino Nano
Reading temperature and humidity with the DHT22 sensor and the Raspberry Pi Pico
Preparing the input features for the model inference
On-device inference with TensorFlow Lite for Microcontrollers

Tidak ada komentar:

Posting Komentar

                         BAHAN PRESENTASI UNTUK MATA KULIAH ELEKTRONIKA  2020/2021 Oleh : Muhammad Shadiq Az Zhuhri 2110953011 Dosen Pengam...