The world is going through one of the worst energy crises in recent times. The 2008 economic meltdown and the consequent high oil and food prices were relatively short-lived. The Covid pandemic and then the Russia-Ukraine war have kept all energy prices very high for a long time.
This unprecedented long period of high energy prices and the supply shortage is exerting tremendous pressure on all economies – developed, developing, and poor countries are facing a serious cost-of-living challenge.
My country Bangladesh is going through a severe energy crisis. Every area in the country goes through 1-6 hours of load-shedding in urban areas and 11-13 hours in rural areas daily. Because of the high fuel prices in the international market, no one seems to see any solution to this energy crisis in the here and now. But household on-grid solar systems could bring an end to this crisis but it is not affordable for most people in Bangladesh.
In this situation, we have no luxury to waste electricity.
My solution is for reducing electricity consumption by reducing misuse and saving electricity.
The SolutionThe solution is very simple. Nordic Thingy:53 has some important sensors built in. I am leveraging those sensors to use in the smart home systems to reduce electricity misuse.
Its internal microphone can be used to detect the presence of any human in a room. If there is no one in a room possibly light and AC should be turned on in that room. Using the room temperature and humidity we can control the AC to reduce energy consumption. The light sensor can be used to determine the light requirement in a room and accordingly we can control the lighting appliances in the room. The gas sensor can be used to detect any gas leakage inside the room.
In my demo project, I am collecting the temperature, humidity, and air pressure of the room using thingy:53 and sending those values to a Raspberry Pi using BLE. Electrical appliances are connected to the Raspberry Pi through the Relay module. Based on the sensor information raspberry pi controls the appliances automatically.
Before getting started you should have a basic understanding of Bluetooth Low Energy (BLE). This Bluetooth Low Energy (BLE): A Complete Guide is an excellent guide for beginners. Then you should gain some knowledge on Bluetooth ATT and GATT. Follow this guide: Bluetooth ATT and GATT Explained (Connection-Oriented Communication). For a clear understanding of GATT development follow the Tutorial: How To Design A Bluetooth LE GATT Server For Your Application. These three tutorials will give you a good understanding of BLE development.
Nordic has excellent tools and guidelines for developing firmware for Nordic devices. We will use nRF SDK for developing our firmware. For preparing your development environment have a look at the getting started guide from nordic: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.1/nrf/getting_started.html.
The following webinar helped me a lot while developing the firmware. You must watch the video for a clear understanding of BLE firmware development.
As we are going to use Thingy:53 for our project and we need to develop firmware for thingy:53 you must read the Getting started with Thingy:53 guide.
Then you can start developing and the following guide can be a good guideline on that journey.
The following sample for thingy:53 helped me to write firmware. Even I started with the Peripheral LBS and I used it as a template for my firmware.
For reading the built-in sensor of Thingy:53 I took help from the following sample application provided by the Nordic.
Thingy:53: Zigbee weather station
I directly copied the sensor code from there and included it in my program.
For generating custom UUID I used the link: https://www.uuidgenerator.net/version4
The GitHub link for the complete project is provided in the code section. For the time limitation, I could not develop and provide the code for Raspberry Pi. But I wish to provide it soon.
I used Visual Studio Code for developing my program.
According to my directory organization, I modified the CMakeList.txt file as shown in the following screenshot.
I used custom UUID for the service and characteristics of every sensor reading.
The following table shows the custom UUIDs I have generated and used for the project.
While trying to upload the built firmware to the Thingy:53 I was getting an error like Error when fetching device versions: readFwInfo error (Origin: "Error when starting nrfdl_fw_read_info"). I was not sure why the error is coming. If it is for any software issue maybe Nordic team will solve it.
After several failed attempts I tried to upload using an external J-link debugger and I was in luck.
nRF programmer interface after connecting with the J-link debugger.
Due to time limitations, I could not complete the Raspberry Pi parts. I will complete that part soon and publish it here.
Comments