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
GreenBuildingService.h@5:b98f4f7cee5a, 2016-12-05 (annotated)
- Committer:
- kaiserhaz
- Date:
- Mon Dec 05 15:06:52 2016 +0000
- Revision:
- 5:b98f4f7cee5a
- Parent:
- 0:7dce5e74ad91
Added licence statement to GreenBuildingService.h.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaiserhaz | 0:7dce5e74ad91 | 1 | /************************ STM32NUCLEO IOT Contest ****************************** |
kaiserhaz | 0:7dce5e74ad91 | 2 | * |
kaiserhaz | 0:7dce5e74ad91 | 3 | * Green Building IoT Solution for |
kaiserhaz | 0:7dce5e74ad91 | 4 | * Plant Life Monitoring And Maintenance |
kaiserhaz | 0:7dce5e74ad91 | 5 | * |
kaiserhaz | 0:7dce5e74ad91 | 6 | * Authored by |
kaiserhaz | 0:7dce5e74ad91 | 7 | * Dien Hoa Truong |
kaiserhaz | 0:7dce5e74ad91 | 8 | * Muhammad Haziq Bin Kamarul Azman |
kaiserhaz | 0:7dce5e74ad91 | 9 | * |
kaiserhaz | 0:7dce5e74ad91 | 10 | * for the |
kaiserhaz | 0:7dce5e74ad91 | 11 | * eSAME 2016 STM32NUCLEO IoT Contest in Sophia-Antipolis |
kaiserhaz | 0:7dce5e74ad91 | 12 | * |
kaiserhaz | 0:7dce5e74ad91 | 13 | * |
kaiserhaz | 5:b98f4f7cee5a | 14 | * GreenBuildingService.h | Green Building Service header |
kaiserhaz | 5:b98f4f7cee5a | 15 | * |
kaiserhaz | 5:b98f4f7cee5a | 16 | * See LICENCE.txt for information on copyrights |
kaiserhaz | 0:7dce5e74ad91 | 17 | * |
kaiserhaz | 0:7dce5e74ad91 | 18 | ******************************************************************************/ |
kaiserhaz | 0:7dce5e74ad91 | 19 | |
kaiserhaz | 0:7dce5e74ad91 | 20 | #ifndef __BLE_GREEN_BUILDING_SERVICE_H__ |
kaiserhaz | 0:7dce5e74ad91 | 21 | #define __BLE_GREEN_BUILDING_SERVICE_H__ |
kaiserhaz | 0:7dce5e74ad91 | 22 | |
kaiserhaz | 0:7dce5e74ad91 | 23 | #include "ble/BLE.h" |
kaiserhaz | 0:7dce5e74ad91 | 24 | |
kaiserhaz | 0:7dce5e74ad91 | 25 | /** |
kaiserhaz | 0:7dce5e74ad91 | 26 | * @class GreenBuildingService |
kaiserhaz | 0:7dce5e74ad91 | 27 | * @brief Custom service derived from mbed's BLE Environmental Service. This service provides air temperature, humidity and soil moisture measurement. |
kaiserhaz | 0:7dce5e74ad91 | 28 | */ |
kaiserhaz | 0:7dce5e74ad91 | 29 | class GreenBuildingService { |
kaiserhaz | 0:7dce5e74ad91 | 30 | public: |
kaiserhaz | 0:7dce5e74ad91 | 31 | |
kaiserhaz | 0:7dce5e74ad91 | 32 | static const uint16_t UUID_GREEN_BUILDING_SERVICE = 0xEB00; /**< Green Building service UUID */ |
kaiserhaz | 0:7dce5e74ad91 | 33 | static const uint16_t UUID_PLANT_ENVIRONMENT_CHAR = 0xEB01; /**< Plant environment characteristic UUID */ |
kaiserhaz | 0:7dce5e74ad91 | 34 | |
kaiserhaz | 0:7dce5e74ad91 | 35 | /** Plant environment data type |
kaiserhaz | 0:7dce5e74ad91 | 36 | * |
kaiserhaz | 0:7dce5e74ad91 | 37 | */ |
kaiserhaz | 0:7dce5e74ad91 | 38 | typedef struct |
kaiserhaz | 0:7dce5e74ad91 | 39 | { |
kaiserhaz | 0:7dce5e74ad91 | 40 | uint8_t airTemperature; /**< Air temperature value */ |
kaiserhaz | 0:7dce5e74ad91 | 41 | uint8_t airHumidity ; /**< Air humidity value */ |
kaiserhaz | 0:7dce5e74ad91 | 42 | uint8_t soilMoisture ; /**< Soil moisture value */ |
kaiserhaz | 0:7dce5e74ad91 | 43 | } PlantEnvironmentType_t; |
kaiserhaz | 0:7dce5e74ad91 | 44 | |
kaiserhaz | 0:7dce5e74ad91 | 45 | /** |
kaiserhaz | 0:7dce5e74ad91 | 46 | * @brief GreenBuildingService constructor. |
kaiserhaz | 0:7dce5e74ad91 | 47 | * @param ble Reference to BLE device. |
kaiserhaz | 0:7dce5e74ad91 | 48 | */ |
kaiserhaz | 0:7dce5e74ad91 | 49 | GreenBuildingService(BLE& _ble) : |
kaiserhaz | 0:7dce5e74ad91 | 50 | ble(_ble), |
kaiserhaz | 0:7dce5e74ad91 | 51 | plantEnvironmentCharacteristic(GreenBuildingService::UUID_PLANT_ENVIRONMENT_CHAR, |
kaiserhaz | 0:7dce5e74ad91 | 52 | &plantEnvironment , |
kaiserhaz | 0:7dce5e74ad91 | 53 | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
kaiserhaz | 0:7dce5e74ad91 | 54 | { |
kaiserhaz | 0:7dce5e74ad91 | 55 | static bool serviceAdded = false; // Ensure only single service is added |
kaiserhaz | 0:7dce5e74ad91 | 56 | if (serviceAdded) { |
kaiserhaz | 0:7dce5e74ad91 | 57 | return; |
kaiserhaz | 0:7dce5e74ad91 | 58 | } |
kaiserhaz | 0:7dce5e74ad91 | 59 | |
kaiserhaz | 0:7dce5e74ad91 | 60 | GattCharacteristic *charTable[] = { &plantEnvironmentCharacteristic }; // Compile characteristics |
kaiserhaz | 0:7dce5e74ad91 | 61 | |
kaiserhaz | 0:7dce5e74ad91 | 62 | GattService greenBuildingService(GreenBuildingService::UUID_GREEN_BUILDING_SERVICE, |
kaiserhaz | 0:7dce5e74ad91 | 63 | charTable , |
kaiserhaz | 0:7dce5e74ad91 | 64 | sizeof(charTable) / sizeof(GattCharacteristic *)); // Create GATT service |
kaiserhaz | 0:7dce5e74ad91 | 65 | |
kaiserhaz | 0:7dce5e74ad91 | 66 | ble.gattServer().addService(greenBuildingService); // Register service with GATT server |
kaiserhaz | 0:7dce5e74ad91 | 67 | |
kaiserhaz | 0:7dce5e74ad91 | 68 | serviceAdded = true; |
kaiserhaz | 0:7dce5e74ad91 | 69 | } |
kaiserhaz | 0:7dce5e74ad91 | 70 | |
kaiserhaz | 0:7dce5e74ad91 | 71 | /** |
kaiserhaz | 0:7dce5e74ad91 | 72 | * @brief Update plant environment characteristic. |
kaiserhaz | 0:7dce5e74ad91 | 73 | * @param newPlantEnvironmentVal New plant environment measurement. |
kaiserhaz | 0:7dce5e74ad91 | 74 | */ |
kaiserhaz | 0:7dce5e74ad91 | 75 | void updatePlantEnvironment(PlantEnvironmentType_t newPlantEnvironmentVal) |
kaiserhaz | 0:7dce5e74ad91 | 76 | { |
kaiserhaz | 0:7dce5e74ad91 | 77 | plantEnvironment = (PlantEnvironmentType_t) (newPlantEnvironmentVal); |
kaiserhaz | 0:7dce5e74ad91 | 78 | ble.gattServer().write(plantEnvironmentCharacteristic.getValueHandle(), (uint8_t *) &plantEnvironment, sizeof(PlantEnvironmentType_t)); |
kaiserhaz | 0:7dce5e74ad91 | 79 | } |
kaiserhaz | 0:7dce5e74ad91 | 80 | |
kaiserhaz | 0:7dce5e74ad91 | 81 | private: |
kaiserhaz | 0:7dce5e74ad91 | 82 | BLE& ble; /*< Local BLE controller reference */ |
kaiserhaz | 0:7dce5e74ad91 | 83 | |
kaiserhaz | 0:7dce5e74ad91 | 84 | ReadOnlyGattCharacteristic<PlantEnvironmentType_t> plantEnvironmentCharacteristic; /*< Plant environment read-only characteristic */ |
kaiserhaz | 0:7dce5e74ad91 | 85 | |
kaiserhaz | 0:7dce5e74ad91 | 86 | PlantEnvironmentType_t plantEnvironment; /*< Local var for plant environment */ |
kaiserhaz | 0:7dce5e74ad91 | 87 | }; |
kaiserhaz | 0:7dce5e74ad91 | 88 | |
kaiserhaz | 0:7dce5e74ad91 | 89 | #endif /* #ifndef __BLE_GREEN_BUILDING_SERVICE_H__*/ |