Like I said, this project is a advanced bettering of the project "Presence Detector with an Alarma 1.0 (for Dinohedges)" Word Dinoseto means something like Dinohedge, that is, a dinosaur made of hedge in Vigo city (Galicia, Spain). We have added a module HM-10 which permits to control the presence detector through BLE (Bluetooth Low Energy) thanks to an app created by means of App Inventor2; but we also can sustitute this module for a HC-06 that it's the traditional bluetooth. For controlling the HM-10 with a Android mobile, Bluetooth 5 capabilities are needed. I used an Samsung Galaxy A50 mobile. Also you have to have the mobile ubication anabled. I have attached now all the necessary complete Arduino code and updated apk file with new funtionalities, like an object recognizer based on Artificial Intelligence.
The aim is to create an presence detector with the shape of a kind of dinosaur made of hedges ("setos" in Spanish) called Dinoseto, famous in Vigo city (Spain, Galicia, Pontevedra.) And here I comment the prototype.
Connect directly an Adafruit TTL serial to USB cable to an HM-10 to configurate with AT commands. Open also a Serial Monitor like the one of Arduino IDE. Help yourself if necessary with Huamao web (the web navigator can advise you not to go to the web, but I had no problems.)
I used this AT commands:
- AT+BAUD4 (115200);
- AT+ROLE0 (peripheral);
- AT+NAME(AlarmBLE for example);
- AT+PASS (6 numbers);
- AT+TYPE1 (Authentication, no need PIN. Nevertheless on reallity it asks for pin);
- AT+IMME0 (When power on, module will start work immediately);
- AT+RESET (Restart);
- AT+CHAR0xFFE2 (Optional. Switch off FFE2 characteristic. Adds write possibility to FFE1 characteristic)
- I also used the "nRF connect for mobile app" downloaded from Google Play Store. For detecting my HM-10 BLE module and proving the functioning of reading and writing that belong to the "unknown service" and its characteristics. That is, I send a string to the HM-10 module and it appears at the other end on the serial monitor of Arduino IDE. I send an string from the serial monitor through the HM-10 and it appears on the nRF connect for mobile app.
Go to extensions, use the documentation and resources and download the BLE extension: edu.mit.appinventor.ble-20181124.aix
Also you can use a base to create your first BLE app.
The BLE extension have to be imported to your app on the Blocks tab ---> Extensions ---> Import Extensions.
I have created the app for the project and have to say that although the BLE extesion is very useful, it seem to give some problems with some blocks when you open the.aia file again on another session. The issue was no more than I had two BLE extensions loaded. One that came with the project in what I based mine, and the one that I loaded for update the extesion. Solution is to erase the old from the.aia file, that is a kind of.zip file.
The.apk file works properly. I have attached it on the "Schematics and circuit diagrams" headland. It has two screens in the new version. The picture below is of an early version.
Download it from Arduino IDE through an USB cable. Before, take off the HM-10 module to avoid disturbances with serial communication. Once downloaded, put on the HM-10 BLE module again.
Maybe we could use the sleep mode of the HM-10 and awake it by UART.