Skip to content

Commit

Permalink
Merge pull request #293 from dtischler/main
Browse files Browse the repository at this point in the history
Sony HVAC
  • Loading branch information
dtischler authored Aug 14, 2023
2 parents 6e46ef4 + f2a3c96 commit 9d1e33e
Show file tree
Hide file tree
Showing 29 changed files with 138 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* [Container Counting with a Nicla Vision & FOMO](container-counting-nicla-vision.md)
* [Traffic Monitoring using the Brainchip Akida Neuromorphic Processor](brainchip-akida-traffic-monitoring.md)
* [Community Guide – Using Edge Impulse with Nvidia DeepStream](nvidia-deepstream-community-guide.md)
* [Smart HVAC System with an Arduino Nicla Vision](arduino-nicla-vision-smart-hvac.md)
* [MLOps with Edge Impulse and Azure IoT Edge](mlops-azure-iot-edge.md)
* [Smart HVAC System with a Sony Spresense](sony-spresense-smart-hvac-system.md)

## Prototype and Concept Projects

Expand Down Expand Up @@ -134,3 +134,4 @@
* [Sensecap A1101 - Soil Quality Detection Using AI and LoRaWAN](sensecap-a1101-lorawan-soil-quality.md)
* [Acute Lymphoblastic Leukemia Classifier](ai-leukemia-classifier.md)
* [Smart Diaper Prototype with an Arduino Nicla Sense ME](arduino-nicla-sense-smart-diaper.md)
* [Smart HVAC System with an Arduino Nicla Vision](arduino-nicla-vision-smart-hvac.md)
2 changes: 1 addition & 1 deletion brainchip-akida-traffic-monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if __name__ == '__main__':
break
```

We will use Edge Impulse Studio to build and train our demo model. This requires us to create an account and initiate a new project at https://studio.edgeiimpulse.com.
We will use Edge Impulse Studio to build and train our demo model. This requires us to create an account and initiate a new project at https://studio.edgeimpulse.com.

![New Project](.gitbook/assets/brainchip-akida-traffic-monitoring/new_project.png)

Expand Down
2 changes: 1 addition & 1 deletion environmental-audio-monitoring-syntiant-tinyml-part-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Software components:

Hardware components:
- [3D printed components for the wearable](https://www.printables.com/model/511919-syntiant-tinyml-wearable)
- [Syntiant TinyML board](https://www.digikey.com/en/products/detail/syntiant-corp/SYNTIANT-TINYML/15293343?s=N4IgTCBcDaIM4E8B2AXAlgQ1SAugXyA)
- [Syntiant TinyML board](https://www.digikey.com/en/products/detail/syntiant-corp/SYNTIANT-TINYML/15293343)
- [Vibration motor module](https://www.amazon.com/ZYM119-Vibration-Switch-Vibrator-Circuit/dp/B09M84JF6B/ref=sr_1_5?crid=1JOJC8SZS6KR7&keywords=vibration+motor+module&qid=1683818656&sprefix=vibration+motor+module%27%2Caps%2C941&sr=8-5)
- [3.7V LiPo battery](https://www.adafruit.com/product/1578). I used one with 500mAh
- Veroboard/stripboard
Expand Down
4 changes: 2 additions & 2 deletions running-faucet-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ We will use Edge Impulse Studio to train and build a TensorFlow Lite model. We n
- **Faucet** - faucet is running, with a variety of background activities.
- **Noise** - just background activities.

We can import this dataset to the Edge Impulse Studio project using the Edge Impulse CLI Uploader. Please follow the instructions here to install Edge Impulse CLI: [https://docs.edgeimpulse.com/docs/cli-installation. T](https://docs.edgeimpulse.com/docs/cli-installation.)he datasets can be downloaded from here: https://cdn.edgeimpulse.com/datasets/faucet.zip.
We can import this dataset to the Edge Impulse Studio project using the Edge Impulse CLI Uploader. Please follow the instructions here to install Edge Impulse CLI: [https://docs.edgeimpulse.com/docs/edge-impulse-cli/cli-installation](https://docs.edgeimpulse.com/docs/edge-impulse-cli/cli-installation). The datasets can be downloaded from here: [https://cdn.edgeimpulse.com/datasets/faucet.zip](https://cdn.edgeimpulse.com/datasets/faucet.zip).

```
$ unzip faucet.zip
Expand Down Expand Up @@ -99,7 +99,7 @@ The Edge Impulse Studio and Blues Wireless Notecard both support Arduino librari

### Set up Blues Wireless Notecard and Notehub

Before starting to run the application we should set up the Notecard. Please see the easy-to-follow quick-start guide [here](https://dev.blues.io/quickstart/notecard-quickstart/notecard-and-notecarrier-b/) to set up a Notecard with a Notecarrier-B to test that everything works as expected. The application code does the Notecard setup at boot-up to make sure it is always in the known state. We also need to set up Notehub, which is a cloud service that receives data from the Notecard and allows us to manage the device, and route that data to our cloud apps and services. We can create a free account at [https://notehub.io/sign-up, ](https://notehub.io/sign-up)and after successful login, we can create a new project.
Before starting to run the application we should set up the Notecard. Please see the easy-to-follow quick-start guide [here](https://dev.blues.io/quickstart/notecard-quickstart/notecard-and-notecarrier-b/) to set up a Notecard with a Notecarrier-B to test that everything works as expected. The application code does the Notecard setup at boot-up to make sure it is always in the known state. We also need to set up Notehub, which is a cloud service that receives data from the Notecard and allows us to manage the device, and route that data to our cloud apps and services. We can create a free account at [https://notehub.io/sign-up, ](https://notehub.io/)and after successful login, we can create a new project.

![](.gitbook/assets/running-faucet-detection/notehub_create_new_project.jpg)

Expand Down
132 changes: 132 additions & 0 deletions sony-spresense-smart-hvac-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
description: Use a computer vision model running on a Sony Spresense to determine occupancy in rooms, and adapt HVAC zone output accordingly.
---

# Smart HVAC System with a Sony Spresense

Created By:
Jallson Suryo

Public Project Link:
[https://studio.edgeimpulse.com/public/215243/latest](https://studio.edgeimpulse.com/public/215243/latest)

GitHub Repo:
[https://github.com/Jallson/Smart_HVAC](https://github.com/Jallson/Smart_HVAC)

## Introduction

A common problem found in HVAC systems is that energy is wasted, because the system uses more energy than necessary, or the system cannot quickly adjust to the changing needs in a dynamic environment. To tackle the problem, we need a system that manages its power intensity based on what is necessary for each zone in real-time for a given environment. The power intensity necessary for each zone can be derived from the following data: number of people, time or duration spent inside, and/or the person's activity.

## Our Solution

To overcome this challenge, a Smart HVAC System that can optimize energy consumption by adjusting the power intensity in different zones inside an office or a residential space (zones with more people, more activity, and longer time durations will need more cooling/heating and vice versa) could be created. The zone heat mapping will be generated using data obtained from a Sony Spresense microcontroller (with Edge Impulse's FOMO Machine Learning model embedded) that's mounted like a surveillance camera inside the space.

![](.gitbook/assets/sony-spresense-smart-hvac-system/image17.jpg)

## Description

The project uses Edge Impulse's FOMO to detect multiple objects and its coordinates using a compact microcontroller with an on-board camera (the Sony Spresense). The object detection ML model will use the top view of miniature figures with standing and sitting positions as objects. The data captured will be divided into Training and Test data. Then the Impulse with Image and Object Detection as learning blocks and grayscale color blocks will be created.

The accuracy result for this training and test model is above 90%, so there is a higher degree of confidence when counting the number of objects (persons) and tracking their centroid coordinates.

The ML model is then deployed to the Spresense. The number of objects in each zone is displayed on an OLED display. The Spresense also communicates to an Arduino Nano via I2C which we are using for the fan speed controller.

This system will increase fan intensity on areas/zone that need more cooling/heating, which means more activity/people in a certain zone will increase fan intensity in that zone. The total HVAC power output can also be adjusted based on the total number of people in the space.

The project is a proof of concept (PoC) using a 1:50 scale model with an office interior with several partitions and furniture and miniature figures. The space is divided into 4 zones, and each zone has a small fan installed. The OLED display is used in this PoC to show the output of this simulation.

![](.gitbook/assets/sony-spresense-smart-hvac-system/image20.jpg)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image18.jpg)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image21.jpg)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image04.jpg)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image05.jpg)

Sony Spresense, aluminium extrusion frame, and 3D printed miniature model (1:50)

System Diagram, prototyping in breadboard, and Smart HVAC System with custom design PCB

### Hardware Components:

- Sony Spresense
- Arduino Nano
- 2x TB6612 Motor drivers
- 4x DC 5V mini fan 3cm
- 0.96inch OLED display
- Aluminium extrusion as a camera stand
- 3D printed (case, office interior 1:50 miniature)
- Powerbank & battery for Sony Spresense

### Software & Online Services:

- Edge Impulse Studio
- Arduino IDE

## Steps

### 1. Prepare Data / Photos

In this project we will use a smartphone camera to capture the images for data collection for ease of use. Take pictures from above in different positions with backgrounds of varying angles and lighting conditions to ensure that the model can work under slightly different conditions (to prevent overfitting). Lighting and object size are crucial aspects to ensure the performance of this model.

> Note: Keep the size of the objects similar in size in the pictures. Significant difference in object size will confuse the FOMO algorithm.
### 2. Data Acquisition and Labelling

Open [studio.edgeimpulse.com](http://studio.edgeimpulse.com), login (or create an account first), then create a new Project.

Choose the **Images** project option, then **Classify Multiple Objects**. In Dashboard > Project Info, choose Bounding Boxes for labelling method and Sony Spresense for target device. Then in Data acquisition, click on Upload Data tab, choose your photo files, auto split, then click Begin upload.

Click on Labelling queue tab then start drag a box around an object and label it (person) and Save. Repeat until all images are labelled.

![](.gitbook/assets/sony-spresense-smart-hvac-system/image06.png)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image07.png)

Make sure that the ratio between Training and Test data is ideal, around 80/20.

### 3. Training and Building Model using FOMO Object Detection

Once you have the dataset ready, go to Create Impulse and set 96 x 96 as the image width - height (this helps in keeping the ML model small). Then choose Fit shortest axis, and choose **Image** and **Object Detection** as learning and processing blocks.

Go to Image parameter section, select color depth as Grayscale, then press Save parameters. Then click on Generate and navigate to Object Detection section, and leave training settings for the Neural Network as it is — in our case the defaults work quite well, then we choose **FOMO (MobileNet V2 0.35)**. Train the model by pressing the Start training button. You can see the progress on the right side.

If everything is OK, then we can test the model. Go to Model Testing on the left, then click Classify all. Our result is above 90%, then we can move on to the next step -- deployment.

![](.gitbook/assets/sony-spresense-smart-hvac-system/image08.png)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image09.png)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image24.png)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image11.png)

### 4. Deploy and Build an Arduino Program

![](.gitbook/assets/sony-spresense-smart-hvac-system/image15.png)

You should have the Arduino IDE installed on your computer for the following step. On the navigation menu, choose **Deployment** on the left, search for and select Arduino Library in the Selected Deployment box, and then click **Build** Once the Edge Impulse Arduino Library is built, downloaded and unzipped, you should download the *spresense_camera_smartHVAC_oled.ino* code which [can be found here](https://github.com/Jallson/Smart_HVAC/blob/main/spresense_camera_smartHVAC_oled.ino) and place it inside the unzipped folder from Edge Impulse. Once the *.ino* code is inside Edge Impulse unzipped folder, move it to your Arduino folder on your computer. Now you can upload the *.ino* code to your Spresense board via the Arduino IDE.

![](.gitbook/assets/sony-spresense-smart-hvac-system/image19.png)

The *.ino code* is a modified version of the Edge Impulse example code for object detection on Spresense. The modification adds capability to display person count on each room to the OLED screen and act as the controller to the Arduino Nano I2C peripheral. The code distinguishes the four rooms using four quadrants and by knowing the X, Y coordinates of the object’s centroid we can locate the person. The Arduino Nano adjusts the fan motor using PWM based on the number of persons present in the room.

The code for the Arduino Nano peripheral *Nano_SmartHVAC_I2C_Peripheral.ino* can be [downloaded here](https://github.com/Jallson/Smart_HVAC/blob/main/Nano_SmartHVAC_I2C_Peripheral.ino).

Here is a quick prototype video showing the project:

{% embed url="http://youtube.com/watch?v=LLYOtY7svDQ" %}

## Conclusion

Finally, we have successfully implemented this object detection model on an Sony Spresense, and use the data captured from the camera to automatically control the HVAC system's fan power intensity and display the occupancy number and power meter for each zone. I believe this Proof of Concept project can be implemented in a real-world HVAC system, so that the goal of optimizing room temperature and saving energy can be achieved for a better, more sustainable future.

## Resources

Additional 3D-printed case design for Sony Spresense for this project:

![](.gitbook/assets/sony-spresense-smart-hvac-system/image22.png)

![](.gitbook/assets/sony-spresense-smart-hvac-system/image23.png)

0 comments on commit 9d1e33e

Please sign in to comment.