Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

cakraawijaya/Whatsapp-Bot-based-Weather-monitoring-using-SPI-communication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Source Love License: MIT GitHub last commit Type

Whatsapp-Bot-based-Weather-monitoring-using-SPI-communication

Coming Soon...



Project Requirements

Part Description
Development Board • STM32F103C8T6
• Wemos D1 Mini
Code Editor Arduino IDE
Programmer Tools ST-Link/V2
Serial Communication Tools FTDI USB
Driver • ST-Link USB Driver
• CDM FTDI USB Driver
• CH340 USB Driver
Application Support Whatsapp Bot
IoT Platform • Twilio
• ThingESP
Communications Protocol • Serial Peripheral Interface (SPI)
• Hypertext Transfer Protocol (HTTP)
IoT Architecture 4 Layer
Programming Language C/C++
Arduino Library • SPI (default)
• ThingESP
Sensor • MH-RD: Raindrop Sensor (x1)
• LDR: Luminous Intensity Sensor (x1)
• LM35: Air Temperature Sensor (x1)
Other Components • Micro USB cable - USB type A (x1)
• Jumper cable (1 set)
• Breadboard (x1)



Download & Install

  1. Arduino IDE

    https://bit.ly/ArduinoIDE_Installer
    

  2. CDM FTDI USB Driver

    https://bit.ly/CDM_FTDI_USB_Driver
    

  3. ST-Link USB Driver

    https://bit.ly/STLink_USB_Driver
    

  4. STM32CubeProgrammer

    https://bit.ly/STM32_Cube_Programmer_Installer
    

  5. CH340 USB Driver

    https://bit.ly/CH340_USB_Driver
    



Project Designs

Block Diagram Infrastructure
block-diagram infrastructure
Pictorial Diagram Wiring
pictorial-diagram wiring



Basic Knowledge

Basically, a device can be communicated with other devices either wirelessly or by cable. Communication between commonly used hardware is Serial Communication. It can be known that there are three types of Serial Communication, which include: UART (Universal Asynchronous Receiver-Transmitter), SPI (Serial Peripheral Interface), and I2C (Inter Integrated Circuit). The Serial Peripheral Interface (SPI) is a synchronous serial communication used by microcontrollers to communicate with one or more peripheral devices in close proximity. It can also be used for communication between two microcontrollers. SPI Serial Communication allows a device to act as a master or slave. The Master is the primary device that has full authority over the control of the Slave, while the Slave is the secondary device that is under the authority of the Master device. SPI communication requires 3 lines namely MOSI, MISO, and SCK. MOSI (Master Output Slave Input) means that if configured as a master then the MOSI pin acts as an output, but if configured as a slave then the MOSI pin acts as an input. MISO (Master Input Slave Output) means that if configured as a master then the MISO pin acts as an input, but if configured as a slave then the MISO pin acts as an output. CLK (Clock) means that if configured as a master then the CLK pin acts as an output, but if configured as a slave then the CLK pin acts as an input.



Arduino IDE Setup

  1. Open the Arduino IDE first, then open the project by clicking File -> Open :

    Master.ino

    Slave.ino


  2. Fill in the Additional Board Manager URLs in Arduino IDE

    Click File -> Preferences -> enter the Boards Manager Url by copying the following link :

    https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
    http://arduino.esp8266.com/stable/package_esp8266com_index.json
    

  3. Board Setup in Arduino IDE

    i

    How to setup the STM32F103C8T6 board

    • Click Tools -> Board -> Boards Manager -> Install STM32 MCU based boards.

    • Then click Tools -> Board -> STM32 boards groups -> Generic STM32F1 series.


    ii

    How to setup the Wemos D1 Mini board

    • Click Tools section -> Board -> Boards Manager -> Install esp8266.

    • Then click Tools -> Board -> ESP8266 Boards -> Wemos D1 Mini.


  4. Change the Board Speed in Arduino IDE

    i

    How to change the speed of STM32F103C8T6 board

    Click Tools -> Upload Speed -> 9600


    ii

    How to change the speed of Wemos D1 Mini board

    Click Tools -> Upload Speed -> 115200


  5. Change Board Part Number in Arduino IDE

    How to change Board Part Number of STM32F103C8T6 board

    Click Tools -> Board part number -> BluePill F103C8


  6. Change U(S)ART Support in Arduino IDE

    How to change U(S)ART Support of STM32F103C8T6 board

    Click Tools -> U(S)ART Support -> Enabled (generic 'Serial')


  7. Change Upload Method in Arduino IDE

    How to change Upload Method of STM32F103C8T6 board

    Click Tools -> Upload method -> STM32CubeProgrammer (SWD)


  8. Install Library in Arduino IDE

    Download all the library zip files. Then paste it in the: C:\Users\Computer_Username\Documents\Arduino\libraries


  9. Port Setup in Arduino IDE

    Click Port -> Choose according to your device port (you can see in device manager)


  10. Change the WiFi Name, WiFi Password, and so on according to what you are currently using.

  11. Before uploading the program please click: Verify.

  12. If there is no error in the program code, the next step is to use the STM32 programming tool according to the procedure. Then click: Upload. While Wemos D1 Mini can be done directly without using programming tools.

  13. If there is still a problem when uploading the program, then try checking the driver / port / programmer tool / others section.



ST-Link/V2 Setup

stlink-configuration

Notes:

• The JTAG or Serial Cable Debugging (SWD) interface module is basically used to communicate with the STM32 board.

• You can see the wiring between the ST-Link/V2 and the STM32 board in the picture above.

• To upload the program, besides using the ST-Link/V2, you can also use other programming tools such as: CP2102 USB, CH340 USB, PL2303 USB, or with FTDI USB.

• Based on experience, I admit that using the ST-Link/V2 is much better than other programming tools because the process is easier, faster, and more stable.



FTDI USB Setup

ftdi-configuration

Notes:

• Serial communication on this STM32 board is very possible, especially for Serial Monitor and Serial Plotter purposes. Tools that can be used for serial communication include: CP2102 USB, CH340 USB, FTDI USB, or with PL2303 USB.

• You can see the wiring between the FTDI USB and the STM32 board in detail in the picture above.

• Based on experience, I admit that using FTDI USB or CP2102 USB is much better than PL2303 USB or CH340 USB because they are known to be more stable in performance.



Twilio Setup

  1. Getting started with Twilio :

    • Go to the following url: Click Here.

    • Click Log in to access the service.

    • if you do not have an account, then click Sign up.


  2. Fill in all the required fields.

  3. Verify your phone number and email.

  4. Access the WhatsApp sandbox in the Settings menu and send the code to the provided WhatsApp number.



ThingESP Setup

  1. Getting started with ThingESP :

    • Go to the following url: Click Here.

    • Click Login to access the service.

    • if you do not have an account, then click Create Account.


  2. Fill in all required fields.

  3. Click Project in the sidebar -> then select Add New Project.

  4. After the project has been created, enter the Twilio WhatsApp Endpoint URL into ThingESP to connect.



Get Started

  1. Download and extract this repository.

  2. Make sure you have the necessary electronic components.

  3. Make sure your components are designed according to the diagram.

  4. Configure your device according to the settings above.

  5. Please enjoy [Done].



Demonstration of Application

Via Whatsapp: Weathersia Bot



Highlights

Device
device
Whatsapp Bot
wa-bot1 wa-bot2



Component Testing

You can download the component test file via the following link: Click Here



Appreciation

If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ⭐Star button at the top of the repository.



Disclaimer

This application is my own work and is not the result of plagiarism from other people's research or work, except those related to third party services which include: libraries, frameworks, and so on.



LICENSE

MIT License - Copyright © 2024 - Devan C. M. Wijaya, S.Kom

Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:

The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.

IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.