Software apps and online services
Hand tools and fabrication machines
Usually, we should ventilate our rooms very often to let fresh air inside. If we haven't ventilated our room for long, then we will be tired due to loss of oxygen. Nowadays, people who are going to the office everyday do not have time to ventilate their rooms in the evening. So, they do not get good sleep at night. Finally they aren’t productive at the office anymore. Not only health issues but also fungus will start to grow on room walls..
Another problem is, some people let their windows open and forget to close. So, cold air(from outside) enters the room continuously. To keep rooms warm, the room heater runs forever until they get noticed by occupants. Also, these days it is hard to predict rain timings due to climatic change. Thus there is a risk of rainwater coming inside.
At some places(especially at offices, universities, etc.), I have seen that the room heater is turned on and the control knob is set at maximum temperature. And it is unnoticed for several months so this increases electricity usage.
Some others simply turn off their room heaters before they go to the office. When they return back to home, First they have to ventilate and then they can turn on their room heaters. But people feel lazy to do all this work and also room heating takes time to heat up the whole room. Similarly, room lighting faces similar kinds of issues.Solution
To make automatic actions, first we have to determine the context of the user. In this project, PSoC 62S2 is going to predict nine different user contexts. They are: Studying, Moving around the room, Working with computers, Using Faucet, Opening/Closing doors, Eating, Raining, Windy and Anomaly detection. Thanks to Infineon for providing two PDM MEMS microphones, Digital barometric pressure sensor and one Piezoelectric MEMS analog microphone with automatic wake-on-sound mode.
A Machine learning neural network is trained for barometric pressure measurement and different sounds coming from computer keyboards keystrokes, foot sound, running water from faucet, reading etc. The trained tiny neural network is deployed into PSoC 62S2 and it predicts different user contexts based on input sound. With user context information, we can maintain the user desired room temperature and lighting. Also, occupancy status information can also be derived from user context.
Again thanking Infineon for having built-in temperature sensor and absolute orientation sensor in IoT sense expansion kit. The temperature sensor is used to measure indoor temperature. The orientation sensor sensor is used to sense window orientation. Additionally an air quality sensor could be into our project. This air quality sensor is connected to PSoC 62S2 via Bluetooth low energy(BLE). Using Occupancy status, indoor temperature, indoor air quality and window orientation data the living room is ventilated with fresh air and heated for comfortable living.
The user preferences are given with the help of the OLED Display and CapSense Slider and buttons.Development
1.Installing ModusToolbox Software on Debian:
sudo apt update
sudo apt upgrade
Download ModusToolbox from Infineon.
Unzip downloaded file to home directory:
sudo tar xvzf /path-to-Downloads-Directory/ModusToolbox_184.108.40.20672-linux-install.tar.gz -C /Path-to-your-home-Directory/
Install necessary dependencies:
sudo apt install make
sudo apt install git
sudo apt install perl coreutils diffutils
sudo apt install libncurses5 libusb-1.0-0 libxcb-xinerama0
Go to home directory:
sudo vim .profile
Add the following line at end of the file:
Save and exit. Now source the file:
Go to tool_2.4 directory:
Execute following scripts:
Allow access for serial UART to current user :
sudo usermod -a -G dialout,plugdev $USER
Now, reboot your system
If you got this error this error: "ModusToolbox is not installed in the default location and the CY_TOOLS_PATHS variable is not set" then do the following:
Open Makefile of your project and insert the following line:
1. Install Virtualbox
2. Install Windows 10 Evaluation/Student as Guest OS in Virtual Box
3. Add Virtual Guest Addition
4. Add Virtualbox extension
5. Add current user to vboxusers group
sudo adduser $USER vboxusers
6. Reboot your system
7. Connect PSOC board to the PC
8. Open Virtualbox, Select Windows 10 and its settings
9. Open USB and Select USB 3.0. Add PSOC Board and Click Ok
10. Now start your virtual machine
11. Install SensiML Data Capture Lab in Windows 10
3. Setup Raspberry Pi 4
1. Install Pi Imager
2. Selsct "Raspberry Pi OS Lite (32-bit)" and Configure your network. Then, Flash the memory card
3. Start your raspberry pi and update
sudo apt update
sudo apt upgrade
4. Install bluez 5.64 (Linux Bluetooth Stack) - First Install Dependencies
sudo apt install autotools-dev automake libtool libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev python3-docutils
Now Install bluez:
sudo wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.64.tar.xz
sudo tar xf bluez-5.64.tar.xz
sudo cd bluez-5.64
sudo ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var
sudo make && sudo make install
5. Reboot raspberry pi
6. Install PIGPIO
sudo apt install python-setuptools python3-setuptools
sudo make install
7. Configure GPIO Pin for DS18B20
sudo nano /boot/config.txt
Add "dtoverlay=w1-gpio, gpiopin=21"
8. Reboot Raspberry pi
4. Wiring Diagram
1. PSOC 6
Download the code files into to your pc. Import the project in Modustoolbox. Compile and Program PSOC 6.
2. Raspberry Pi
Download the code files in to your raspberry pi. The folder "things" contains python application.
3. Connect Pi With PSOC
In Raspberry pi, Turn on Bluetooth and set it pair-able and discover-able using "bluetoothd" sevice. Start "bluetoothd" using following command
Turn on, Set Pair-able and Discover-able
Start the python application with following command
sudo python3 main.py 00:A0:5F:DE:A4:7D
Successful Connection Sample Images:
At Raspberry Pi Side:
At PSOC Side:
4. Project In Action
In PSOC, The application runs based on Freertos. From CY8CKIT-028-SENSE, the digital microphones are used to record sound signals and fed into trained neural network. The neural network outputs current user context. Based on user context, PSOC 6 sends commands to Raspberry Pi via Bluetooth Low Energy. Then, the table lamp and faucet lamps are fully controlled autonomously.
In CY8CKIT-028-SENSE, 128x64 oled display act as user interface. User can view current living place status and interact with user interface to set desired room temperature using CAPSENSE Buttons and Slider. By Touching any one of the cap-sense button, a help page displayed.
There are three sensors connected to Raspberry Pi. They are, Temperature, MQ2 Sensor and Magnetic reed switch. Magnetic reed switch detects window position. There are two actuators connected to Raspberry Pi. They are, Table Lamp and Faucet Lamp.
Raspberry Pi send Air Quality sensor value, room Temperature and Window Position sends to PSOC for every 10 Seconds. PSOC 6 process these data and makes appropriate actions. The required actions to be carried out are showed on running display.
If the Air Quality is bad, then it shows,
That is, The room should be ventilated.
So, It asks user to open the window
When the window is opened then, the room heater should be turned off. Otherwise, it consumes lot of electricity.
When room air quality is improved then it asks user to close the window. Turn on the room heater only if there occupants living in the room. When a user enter in the room then room heater is turned on and room temperature is raised to desired level.Demo Video