It is a simple IoT solution for plant life monitoring and maintenance, based on STM32NUCLEO boards and expansion modules.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IKS01A1 mbed
GreenYourLife, A Plant Life Monitoring and Maintenance System
Elaborated By Engineers, Designed For The World
Introduction
A healthy ecosystem is one where all the actors in it work in synergy: each of them playing a part that serves the other. Plants play an important part in regulating our quality of life. In the modern world, they would often times be placed in buildings and houses, as decorations or as medicinal and therapeutic purposes. Whatever the reason, GreenYourLife is here to help you manage them.
GreenYourLife is an Internet of Things (IoT) solution that will allow you to perform the following:
- Follow your plant's well-being on your connected device (smartphone, etc.)
- Maintain your plant's well-being automatically
We've developed an indoor plant monitoring system with the STM32NUCLEO development board. The system will collect the plant's environmental data (air temperature, air humidity and soil moisture) and transfer them to your connected device. The data collected will then be stored on a cloud server, where you can follow the progress of your plant life.
How it works
Plant maintanence
Our concept of maintanence is the automatic catering of the plant's needs. In this version, we focus on water supply. Future versions may indeed include more than that.
On-board sensors on the STM32NUCLEO will obtain measurements of 3 main parameters on the plant surrounding:
- Air temperature
- Air humidity
- Soil moisture
Based on these values, the software then acts upon the water pump: activating it when in need of water and deactivating it if not.
Plant monitoring
Plant monitoring, for us, is the follow-up of the plant's health by monitoring environment quality and plant nutritions. In this version, we only monitor the three parameters listed above. Future version may include more advanced and smarter monitoring technique.
The STM32NUCLEO device acts as a Bluetooth server and awaits connection from any client (smartphone, etc.). Upon connection, the server updates the plant environment parameters at a fixed interval. The client application will then transfer these received characteristics to the cloud.
Details
Hardware
The target platform is the STM32NUCLEO L476RG development board with two additional modules:
- the IDB05A1 Bluetooth LE expansion board, which uses a BlueNRG coprocessor
- and the IKS01A1 MEMS sensor expansion board
There are several additional materials that constitute the system:
- a Funduino Soil Moisture Sensor, hooked up to 5V at pin PB_1
- a relay, hooked up to 3.3V at pin PC_8 and controlled by a PWM pulse
- a DC water pump
Software
We have used the ARM mbed platform for general code bring-up. We've used the following libraries:
- mbed library by ARM
- BLE_API library by the Bluetooth Low Energy team
- X_NUCLEO_IDB0XA1 library by the ST Microelectronics team
- X_NUCLEO_IKS01A1 library by the ST Microelectronics team
The acquired data on the client device is then sent to a cloud server that we hosted on ThingSpeak, so that people can remotely access the data. It is available at the GreenYourLife channel .
Reference
Diff: GreenBuildingService.h
- Revision:
- 0:7dce5e74ad91
- Child:
- 5:b98f4f7cee5a
diff -r 000000000000 -r 7dce5e74ad91 GreenBuildingService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GreenBuildingService.h Sat Nov 26 13:38:23 2016 +0000 @@ -0,0 +1,87 @@ +/************************ STM32NUCLEO IOT Contest ****************************** + * + * Green Building IoT Solution for + * Plant Life Monitoring And Maintenance + * + * Authored by + * Dien Hoa Truong + * Muhammad Haziq Bin Kamarul Azman + * + * for the + * eSAME 2016 STM32NUCLEO IoT Contest in Sophia-Antipolis + * + * + * GreenBuildingService.h | Green Building Service header + * + ******************************************************************************/ + +#ifndef __BLE_GREEN_BUILDING_SERVICE_H__ +#define __BLE_GREEN_BUILDING_SERVICE_H__ + +#include "ble/BLE.h" + +/** + * @class GreenBuildingService + * @brief Custom service derived from mbed's BLE Environmental Service. This service provides air temperature, humidity and soil moisture measurement. + */ +class GreenBuildingService { +public: + + static const uint16_t UUID_GREEN_BUILDING_SERVICE = 0xEB00; /**< Green Building service UUID */ + static const uint16_t UUID_PLANT_ENVIRONMENT_CHAR = 0xEB01; /**< Plant environment characteristic UUID */ + + /** Plant environment data type + * + */ + typedef struct + { + uint8_t airTemperature; /**< Air temperature value */ + uint8_t airHumidity ; /**< Air humidity value */ + uint8_t soilMoisture ; /**< Soil moisture value */ + } PlantEnvironmentType_t; + + /** + * @brief GreenBuildingService constructor. + * @param ble Reference to BLE device. + */ + GreenBuildingService(BLE& _ble) : + ble(_ble), + plantEnvironmentCharacteristic(GreenBuildingService::UUID_PLANT_ENVIRONMENT_CHAR, + &plantEnvironment , + GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) + { + static bool serviceAdded = false; // Ensure only single service is added + if (serviceAdded) { + return; + } + + GattCharacteristic *charTable[] = { &plantEnvironmentCharacteristic }; // Compile characteristics + + GattService greenBuildingService(GreenBuildingService::UUID_GREEN_BUILDING_SERVICE, + charTable , + sizeof(charTable) / sizeof(GattCharacteristic *)); // Create GATT service + + ble.gattServer().addService(greenBuildingService); // Register service with GATT server + + serviceAdded = true; + } + + /** + * @brief Update plant environment characteristic. + * @param newPlantEnvironmentVal New plant environment measurement. + */ + void updatePlantEnvironment(PlantEnvironmentType_t newPlantEnvironmentVal) + { + plantEnvironment = (PlantEnvironmentType_t) (newPlantEnvironmentVal); + ble.gattServer().write(plantEnvironmentCharacteristic.getValueHandle(), (uint8_t *) &plantEnvironment, sizeof(PlantEnvironmentType_t)); + } + +private: + BLE& ble; /*< Local BLE controller reference */ + + ReadOnlyGattCharacteristic<PlantEnvironmentType_t> plantEnvironmentCharacteristic; /*< Plant environment read-only characteristic */ + + PlantEnvironmentType_t plantEnvironment; /*< Local var for plant environment */ +}; + +#endif /* #ifndef __BLE_GREEN_BUILDING_SERVICE_H__*/ \ No newline at end of file