Basics project 085e Ai Thinker A6 GSM GPRS module, ESP32 Development board – Temperature and Humidity
Basics: Project 085e
Project name: Ai Thinker A6 GSM GPRS module, ESP32 Development board – Temperature and Humidity
Tags: Arduino, A6 GSM GPRS module, GSM GPRS module, A6, Ai Thinker, ESP32 development board, Temperature and Humidity
In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):
1. Ai Thinker A6 GSM GPRS module 1 pc
2. Arduino IDE ( you can download it from here )
3. Jumper cables F-F
4. Micro USB cable 1 pc
5. Micro SIM card 1 pc (unlocked)
6. GSM GPRS antenna 1 pc
7. 5 VDC 2A power wall adapter 1pc
8. ESP32 development board with WiFi and Bluetooth and USB A / micro USB B cable 1 pc
9.DHT11 Humidity and temperature module 1pc
We will learn how to use the Ai Thinker A6 GSM GPRS module with ESP32 Development board to get temperature and humidity over SMS.
There are three serial ports on the ESP32 known as U0UXD, U1UXD and U2UXD all work at 3.3V TTL Level. There are three hardware supported serial interfaces on the ESP32 known as UART0, UART1 and UART2. Like all peripherals, the pins for the UARTs can be logically mapped to any of the available pins on the ESP32. However, the UARTs can also have direct access which marginally improves performance. The pin mapping table for this hardware assistance is as follows.
Having said that, the UART drivers that we recommend to use don’t have this level of optimization built into them and as a result, you are pretty much free to use any pins you choose.
Understanding the UART
UART stands for Universal Asynchronous Receiver/Transmitter. It’s not a communication protocol like SPI and I2C, but a physical circuit in a microcontroller, or a stand-alone IC. A UART’s main purpose is to transmit and receive serial data. Introduction to UART Communication In UART communication, two UARTs communicate directly with each other. The transmitting UART converts parallel data from a controlling device like a CPU into serial form, transmits it in serial to the receiving UART, which then converts the serial data back into parallel data for the receiving device. Only two wires are needed to transmit data between two UARTs. Data flows from the Tx pin of the transmitting UART to the Rx pin of the receiving UART.
UARTs transmit data asynchronously, which means there is no clock signal to synchronize the output of bits from the transmitting UART to the sampling of bits by the receiving UART. Instead of a clock signal, the transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the receiving UART knows when to start reading the bits. When the receiving UART detects a start bit, it starts to read the incoming bits at a specific frequency known as the baud rate. Baud rate is a measure of the speed of data transfer, expressed in bits per second (bps).
Both UARTs must operate at about the same baud rate. The baud rate between the transmitting and receiving UARTs can only differ by about 3% before the timing of bits gets too far off. Both UARTs must also must be configured to transmit and receive the same data packet structure.
Understanding the DHT 11 21 22 module
You can read more about it here.
Understanding the ESP32 development board
You can read more about it here.
Understanding the A6 GSM GPRS module
You can read more about it here.
You can find A6 datasheet, manuals, AT commands, schematics here.
Signals and connections of the DHT 11 21 22 module
There are two different versions of the DHT11 you might come across. One type has four pins, and the other type has three pins and is mounted to a small PCB. The PCB mounted version is nice because it includes a surface mounted 10K Ohm pull up resistor for the signal line. Here are the pin outs for both versions:
We are going to use DHT11 with three pins in this project.
Signals and connections of the ESP32 Development board with WiFi and Bluetooth
You can find more information (datasheets, schematics, pins descriptions, functional desgn descriptions) about each board (made by Espresiff Systems) by pressing Getting started link close to each board here.
Let’s check our development board – ESP32 DEVKITV1 with ESP-WROOM-32 module from Espressif Systems:
ESP32-WROOM-32 – ESP32-WROOM-32 module soldered to the development board. Optionally ESP32-WROOM-32D, ESP32-WROOM-32U or ESP32-SOLO-1 module may be soldered instead of the ESP32-WROOM-32.
USB-UART Bridge – A single chip USB-UART bridge provides up to 3 Mbps transfers rates.
BOOT button – Download button: holding down the Bootbutton and pressing the EN button initiates the firmware download mode. Then user can download firmware through the serial port.
EN button – Reset button: pressing this button resets the system.
Micro USB Port – USB interface. It functions as the power supply for the board and the communication interface between PC and the ESP module.
TX0, TX2 – transmit pin. GPIO pin
RX0, RX2 – receive pin. GPIO pin
3V3 (or 3V or 3.3V)- power supply pin (3-3.6V).
GND – ground pin.
EN – Chip enable. Keep it on high (3.3V) for normal operation.
Vin – External power supply 5VDC.
Signals and connections of the A6 GSM GPRS module
A6 GPS/GPRS IC pinout:
EN – module power control enable pin (can control power switch, default high level enable)
VCC_IN – External power supply (3.4V-4.2V ) maximum power supply current 2A
PWR – used for turning module ON/OFF programmatically. For doing this you must pull it HIGH for a moment (less than 500 ms or around).
INT – used to control the module to enter low-power mode, high exit low level access, in this mode the standby current <1mA ( in this mode the serial port cannot be used)
GND – ground pin. this module has 2 ground pins
U_RXD – serial port for AT commands (receive pin)
U_TXD – serial port for AT commands (transmit pin)
H_TXD – firmware update pin (transmit pin), pin power level 2.8V
H_RXD – firmware update pin (receive pin), pin power level 2.8V
R232_TX – RS232 level control (transmit pin)
R232_RX – RS232 level control (receive pin)
MIC- – microphone –
MIC+ – microphone+
REC- – loudspeaker –
REC+ – loudspeaker +
A6 GSM GPRS module ESP32 development board
GND G (GND)
U_RXD TX0 (GPIO17)
U_TXD RX0 (GPIO16)
ESP32 development board DHT11 sensor
3V3 VIN (3.3VDC)
D2 (GPIO2) SIGNAL (DATA)
Step by Step instruction
The ESP32 is currently being integrated with the Arduino IDE like it was done for the ESP8266. There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language.
1. Installing ESP32 add-on in Arduino IDE (Windows 10 OS)
Download and install the latest Arduino IDE Windows Installer from arduino.cc
Open Arduino IDE. Go to File -> Preferences.
Type https://dl.espressif.com/dl/package_esp32_index.json into the Additional Board Manager URLs field as shown below. Then, click on OK button.
Please note: if you already have the ESP8266 boards URL, you can separate the URLs with a comma.
Open the Boards Manager. Go to Tools -> Board -> Boards Manager…
Search for ESP32 and click on Install button for the ESP32 by Espressif Systems.
That’s it. It should be installed after a few seconds. Click on Close button to close.
2. Uploading sketch to ESP32 development board
- Do wiring.
- Attach GSM GPRS antenna to A6 GSM GPRS module.
- Insert a active unlocked SIM card to SIM card slot of A6 GSM GPRS module.The workings of the SIM card socket can take some getting used to. To unlock the latch, push the top part of the assembly towards micro USB connector, and then lift it up. Place the SIM card into the bottom part of the socket with the SIM’s notch pointing away from the micro USB connector. Then fold the arm back into the body of the socket, and gently push it forward towards the “LOCK” position.
- We power up A6 GSM GPRS module with external power supply 5VDC 2A through micro USB port.
- Plug your ESP32 development board into your PC USB port.
- Open Arduino IDE.
- Open Boards manager. Go to Tools -> Board -> Boards Manager… (in our case it’s the DOIT ESP32 DEVKIT V1)
- Select COM port that the board is attached to (if you don’t see the COM Port in your Arduino IDE, you need to install the ESP32 CP210x USB to UART Bridge VCP Drivers).
- Open sketch . Compile and upload it to your ESP32 development board. If everything went as expected, you should see a “Done uploading” message. (You need to hold the ESP32 on-board Boot button while uploading).
- Open the Serial Monitor at a baud rate of 9600.
- Press the ESP32 on-board EN button to reboot it.
- When you send the message Status from your smartphone to A6 GSM GPRS module you will get the reply – Temperature and Humidity readings.
Please note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD: U0UXD is used to communicate with the ESP32 for programming and during reset/boot; U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though; U2UXD is unused and can be used for your projects.
We have learnt how to use the Ai Thinker A6 GSM GPRS module with ESP32 Development board to get temperature and humidity over SMS.
Thank you for reading and supporting us.
- Attached on the beginning of the project.
- Adafruit_Sensor library included. Download, unzip and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.
- DHT-sensor library included. You will need to unzip and add the DHT-sensor-library-master library to libraries in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries OR You can install it in Arduino IDE too: select Sketch-> Include library->Manage your libraries->type DHT in Filter your search line and you will see DHT sensor library by Adafruit->More info->select version->install. If it will be problem with compilation – remove 2 files from the library – DHT_U.cpp and DHT_U.h. You can read more about it here.
- See attachments on the beginning of this project description