EMECSthon example project which shows how to use bluetooth with Nucleo board. A humidity sensor is read and a water pump activated from an App by the user.
- Development Board NUCLEO-F303RE
- Bluetooth module HC06
- Hygrometer (user choice)
- Water pump (user choice)
- MOSFET (user choice)
- Resistors: 1k and 100k
- Some cables
The realization of the project consists of two parts: hardware and software.
-
Hardware: the circuit to be built will be detailed and has no complications.
-
Software: the Nucleo board will be programmed from the MBED environment and from the Arduino IDE, so that the user can choose to use the one with which he feels most comfortable.
- Connect Bluetooth module
HC06 | Nucleo F303 |
---|---|
VCC | 5V |
GND | GND |
TX | D2 (RX) |
RX | D8 (TX) |
- Connect Hygrometer
Hygrometer | Nucleo F303 |
---|---|
VCC | 3.3V |
GND | GND |
A0 | A0 |
MBED platform is used to program the MCU
-
Create empty MBED project here
-
Import
main.cpp
(or copy it) -
Compile
Arduino IDE can be used as well to program the MCU
-
Download Arduino IDE here.
-
Go to Files -> Preferences and enter the link 'https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/STM32/package_stm_index.json' into the "Additional Boards Manager URLs".
-
Go to Tools -> Board, look for 'STM32 Core' package and install it.
-
Go to Tools -> Board, select Nucleo-64.
-
Go to Tools -> Board part number and select Nucleo F303RE.
-
Go to Tools -> Port and select the corresponding port of the Nucleo Board
-
Open the files provided
-
Compile and download them on the board
The design of the App can be done at the user's choice. In this case, Appinventor will be used for its simplicity and speed.
-
Create empty AppInventor project here.
-
Import the corresponding .aia file.
-
Connect your phone to the same Wi-Fi network as your laptop.
-
Download MIT AI2 Companion on your phone
-
Go to Connect -> AI Companion in your laptop
-
Connect your phone using the numerical code or the QR code
Two diferent programs have been created. One of them to read the humidity sensor and receive that information on an App. The second one to activate or desactivate a water pump to water the plants.
These two programs are designed to see the functionality of bluetooth with the Nucleo board. That is why the watering has not been automated, which would be very easy to implement.