A Telegram BOT for this awesome all-in-one board.
Dependencies: BSP_B-L475E-IOT01 mbed es_wifi jsmn
Telegram Bot for DISCO_L475VG_IOT01
This application embeds aTelegram chatbot into the DISCO_L475VG_IOT01 board.
The Bot answers to the users queries about:
- Real time environmental data taken from the on board sensors.
- Environmental data history of the latest 24 hours stored on board.
- Camera images taken from the Arducam-mini-2mp (optional).
This software uses:
- A modified version of the wifi library provided by ST in order to enable the TCP-SSL connection.
- An open source json parser jsmn (https://github.com/zserge/jsmn).
- A web service (http://now.http.org) to initialize the RTC.
- A web service (https://image-charts.com) to publish temperature,humidity and pressure charts.
- A modified version of the Arducam driver (https://os.mbed.com/users/dflet/)
Compilation
Import in your compiler and modify the following defines:
- WIFI_SSID
- WIFI_PASSWORD
- TELEGRAM_BOT_APIKEY
Please follow the Telegram bots documentation (https://core.telegram.org/bots) to better understand how the Telegram API works and how to create your bot.
In order to support the Arducam-Mini-2MP set WITH_ARDUCAM_2640 #define to 1.
Screenshots
Security
The Inventek wifi module creates the ssl connection but does not authenticate the server's certificate ( AT cmd P9=0 ).
For more details http://www.inventeksys.com/IWIN/programming-certificates-tcp-ssltls/
main.cpp@0:1fc46da4a976, 2018-01-23 (annotated)
- Committer:
- dvddnr
- Date:
- Tue Jan 23 13:06:11 2018 +0000
- Revision:
- 0:1fc46da4a976
- Child:
- 1:60fbd0835b9d
h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dvddnr | 0:1fc46da4a976 | 1 | #include "mbed.h" |
dvddnr | 0:1fc46da4a976 | 2 | |
dvddnr | 0:1fc46da4a976 | 3 | // Sensors drivers present in the BSP library |
dvddnr | 0:1fc46da4a976 | 4 | #include "stm32l475e_iot01_tsensor.h" |
dvddnr | 0:1fc46da4a976 | 5 | #include "stm32l475e_iot01_hsensor.h" |
dvddnr | 0:1fc46da4a976 | 6 | #include "stm32l475e_iot01_psensor.h" |
dvddnr | 0:1fc46da4a976 | 7 | #include "stm32l475e_iot01_magneto.h" |
dvddnr | 0:1fc46da4a976 | 8 | #include "stm32l475e_iot01_gyro.h" |
dvddnr | 0:1fc46da4a976 | 9 | #include "stm32l475e_iot01_accelero.h" |
dvddnr | 0:1fc46da4a976 | 10 | |
dvddnr | 0:1fc46da4a976 | 11 | DigitalOut led(LED1); |
dvddnr | 0:1fc46da4a976 | 12 | |
dvddnr | 0:1fc46da4a976 | 13 | int main() |
dvddnr | 0:1fc46da4a976 | 14 | { |
dvddnr | 0:1fc46da4a976 | 15 | float sensor_value = 0; |
dvddnr | 0:1fc46da4a976 | 16 | int16_t pDataXYZ[3] = {0}; |
dvddnr | 0:1fc46da4a976 | 17 | float pGyroDataXYZ[3] = {0}; |
dvddnr | 0:1fc46da4a976 | 18 | |
dvddnr | 0:1fc46da4a976 | 19 | BSP_TSENSOR_Init(); |
dvddnr | 0:1fc46da4a976 | 20 | BSP_HSENSOR_Init(); |
dvddnr | 0:1fc46da4a976 | 21 | BSP_PSENSOR_Init(); |
dvddnr | 0:1fc46da4a976 | 22 | |
dvddnr | 0:1fc46da4a976 | 23 | BSP_MAGNETO_Init(); |
dvddnr | 0:1fc46da4a976 | 24 | BSP_GYRO_Init(); |
dvddnr | 0:1fc46da4a976 | 25 | BSP_ACCELERO_Init(); |
dvddnr | 0:1fc46da4a976 | 26 | |
dvddnr | 0:1fc46da4a976 | 27 | while(1) { |
dvddnr | 0:1fc46da4a976 | 28 | |
dvddnr | 0:1fc46da4a976 | 29 | led = 1; |
dvddnr | 0:1fc46da4a976 | 30 | |
dvddnr | 0:1fc46da4a976 | 31 | sensor_value = BSP_TSENSOR_ReadTemp(); |
dvddnr | 0:1fc46da4a976 | 32 | printf("\nTEMPERATURE = %.2f degC\n", sensor_value); |
dvddnr | 0:1fc46da4a976 | 33 | |
dvddnr | 0:1fc46da4a976 | 34 | sensor_value = BSP_HSENSOR_ReadHumidity(); |
dvddnr | 0:1fc46da4a976 | 35 | printf("HUMIDITY = %.2f %%\n", sensor_value); |
dvddnr | 0:1fc46da4a976 | 36 | |
dvddnr | 0:1fc46da4a976 | 37 | sensor_value = BSP_PSENSOR_ReadPressure(); |
dvddnr | 0:1fc46da4a976 | 38 | printf("PRESSURE is = %.2f mBar\n", sensor_value); |
dvddnr | 0:1fc46da4a976 | 39 | |
dvddnr | 0:1fc46da4a976 | 40 | led = 0; |
dvddnr | 0:1fc46da4a976 | 41 | |
dvddnr | 0:1fc46da4a976 | 42 | wait(1); |
dvddnr | 0:1fc46da4a976 | 43 | |
dvddnr | 0:1fc46da4a976 | 44 | led = 1; |
dvddnr | 0:1fc46da4a976 | 45 | |
dvddnr | 0:1fc46da4a976 | 46 | BSP_MAGNETO_GetXYZ(pDataXYZ); |
dvddnr | 0:1fc46da4a976 | 47 | printf("\nMAGNETO_X = %d\n", pDataXYZ[0]); |
dvddnr | 0:1fc46da4a976 | 48 | printf("MAGNETO_Y = %d\n", pDataXYZ[1]); |
dvddnr | 0:1fc46da4a976 | 49 | printf("MAGNETO_Z = %d\n", pDataXYZ[2]); |
dvddnr | 0:1fc46da4a976 | 50 | |
dvddnr | 0:1fc46da4a976 | 51 | BSP_GYRO_GetXYZ(pGyroDataXYZ); |
dvddnr | 0:1fc46da4a976 | 52 | printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]); |
dvddnr | 0:1fc46da4a976 | 53 | printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]); |
dvddnr | 0:1fc46da4a976 | 54 | printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]); |
dvddnr | 0:1fc46da4a976 | 55 | |
dvddnr | 0:1fc46da4a976 | 56 | BSP_ACCELERO_AccGetXYZ(pDataXYZ); |
dvddnr | 0:1fc46da4a976 | 57 | printf("\nACCELERO_X = %d\n", pDataXYZ[0]); |
dvddnr | 0:1fc46da4a976 | 58 | printf("ACCELERO_Y = %d\n", pDataXYZ[1]); |
dvddnr | 0:1fc46da4a976 | 59 | printf("ACCELERO_Z = %d\n", pDataXYZ[2]); |
dvddnr | 0:1fc46da4a976 | 60 | |
dvddnr | 0:1fc46da4a976 | 61 | led = 0; |
dvddnr | 0:1fc46da4a976 | 62 | |
dvddnr | 0:1fc46da4a976 | 63 | wait(1); |
dvddnr | 0:1fc46da4a976 | 64 | |
dvddnr | 0:1fc46da4a976 | 65 | } |
dvddnr | 0:1fc46da4a976 | 66 | } |