# Modulation Basics

Modulasi dalam konteks telekomunikasi adalah sebuah proses pengubahan sebuah gelombang pembawa (carrier waveform) untuk membawa informasi (berupa sinyal baseband atau sinyal pemodulasi). Modulasi frekuensi adalah salah satu dari tiga jenis modulasi analog, yaitu: modulasi amplitudo, modulasi frekuensi, dan modulasi fasa.

Namun, modulasi frekuensi dan modulasi fasa umumnya dapat disembut “modulasi sudut”, menyisakan hanya dua jenis modulasi analog: sudut dan amplitudo. Penyatuan frekuensi dan fasa sebagai modulasi sudut disebabkan fasa dan frekuensi yang berhubungan erat, dan hubungan antara fasa dan frekuensi sudut dapat didefinisikan dengan persamaan berikut:

$\displaystyle \omega(t) = \frac{d\phi(t)}{dt}$

di mana $\omega(t)$ adalah frekuensi sudut dan $\phi(t)$ adalah fasa.

Gelombang pembawa umumnya didefinisikan sebagai gelombang sinusoidal sehingga dapat direpresentasikan dengan persamaan berikut:

$\displaystyle c(t) = A_c \cos(\phi_i(t)) = A_c \cos(\omega_ct)$

di mana $c(t)$ adalah nilai sesaat dari gelombang pembawa sinusoidal, $A_c$ adalah amplitudo dari gelombang pembawa, $\phi_i(t)$ adalah fasa sesaat dari gelombang pembawa, dan $\omega_c$ adalah frekuensi sudut dari gelombang pembawa.

# Frequency Modulation Waveform Generation

Modulasi frekuensi merupakan sebuah jenis modulasi sudut, sesuai dengan namanya, mengubah sudut dari sebuah gelombang pembawa ($c(t)$) untuk membawa informasi dari sinyal baseband ($m(t)$). Cara termudah untuk menghasilkan sinyal FM adalah dengan menggunakan Voltage Controlled Oscillator (VCO). Tegangan dari sinyal baseband $m(t)$ digunakan untuk mengatur frekuensi dari keluaran VCO (keluaran gelombang FM).

Gelombang sinyal baseband mengatur frekuensi sesaat dari gelombang FM, jika sinyal baseband 0, frekuensi sesaat dari gelombang FM menjadi sama dengan frekuensi pembawa $f_c$, saat sinyal baseband bukan nol, frekuensi sesaat ($f_i(t)$) dari sinyal FM dapat diekspresikan dengan persamaan:

$\displaystyle f_i(t) = f_c + K_{VCO} m(t)$

di mana $K_{VCO}$ adalah sensitivitas modulasi atau gain dari VCO yang memiliki satuan Hz/V, dan $K_{VCO}m(t)$ adalah deviasi frekuensi sesaat.

Karena fasa dapat dihasilkan dari persamaan frekuensi sudut, nilai fasa sesaat dapat direpresentasikan dengan persamaan:

$\displaystyle \theta_i(t) = \int_{0}^{t} \omega_i(\tau) d\tau = \omega_ct + 2\pi K_{VCO} \int_{0}^{t} m(\tau) d\tau$

Dengan mendapatkan fasa sesaat, persamaan sinyal FM didapatkan dengan memasukkan nilai fasa sesaat pada persamaan gelombang pembawa, sehingga menghasilkan persamaan:

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + 2\pi K_{VCO}\int_{0}^{t} m(\tau) d\tau\bigg)$

# Sinusoidal Analysis of FM Wave

Secara matematis, untuk menganalisa sinyal FM, umumnya sinyal baseband yang digunakan adalah sinyal satu frekuensi, yaitu sinyal sinusoidal dengan persamaan sebagai berikut:

$\displaystyle m(t) = A_m \cos(\omega_mt)$

di mana $A_m$ adalah amplitudo sinyal baseband dan $\omega_m$ adalah frekuensi sudut dari sinyal baseband. Jika persamaan di atas disubstitusikan dengan persamaan sinyal FM, dapat dihasilkan persamaan:

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + 2\pi K_{VCO}\int_{0}^{t} A_m \cos(\omega_m\tau) d\tau\bigg)$

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + \frac{K_{VCO}A_m}{f_m}sin(\omega_mt)\bigg)$

Deviasi frekuensi maksimum ($\Delta f$) didapatkan dari sensitivitas modulasi atau gain VCO dan amplitudo dari sinyal baseband. Perbandingan antara deviasi frekuensi maksimum ($\Delta f$) dengan frekuensi sinyal baseband ($f_m$) adalah indeks modulasi, $\beta$. Sehingga, persamaan FM dapat diturunkan sebagai berikut:

$\displaystyle x_{FM}(t) = A_c \cos \big(\omega_ct + \beta\sin(\omega_mt)\big)$

Pada artikel selanjutnya, saya akan membahas fungsi Bessel dan pengunaannya untuk menganalisa sinyal FM.

## Frequency Modulation Basics (English)

Modulation in telecommunications is a process of varying a carrier waveform (or carrier signal) to carry an information (or known as baseband signal). Frequency Modulation is one of the three analog modulation schemes, three of them being:

1. Amplitude Modulation
2. Frequency Modulation
3. Phase Modulation

Although the Frequency Modulation and Phase Modulation is usually referred as “Angle Modulation”, leaving only two kinds of analog modulation: angle and amplitude. This is because phase and frequency is tightly coupled, and the relationship of phase and angular frequency can be defined by the equation

$\displaystyle \omega(t) = \frac{d\phi(t)}{dt}$

A carrier frequency is usually defined as a sinusoidal wave, thus can be represented in the following equation

$\displaystyle c(t) = A_c \cos(\omega_ct)$

where $c(t)$ is the instantaneous value of the carrier cosine wave, $A_c$ is the amplitude of the carrier, and $\omega_c$ is the carrier angular frequency

Frequency Modulation is a type of Angle Modulation, in which the name implies, changes the angle of the carrier waveform to contain the information of the baseband signal $m(t)$. The simplest way to generate an FM signal is through a Voltage Controlled Oscillator. The baseband signal $m(t)$ is used to control the output frequency of the VCO (the FM wave).

The baseband signal controls the frequency of the FM wave, when the baseband signal is zero, the frequency of the output signal is the same as the carrier frequency $f_c$ when the baseband signal is nonzero, the instantaneous frequency of the output signal is expressed by

$\displaystyle f_i(t) = f_c + K_{VCO} m(t)$

where $K_{VCO}$ is the modulation sensitivity of the VCO expressed in units of Hz/V, and $K_{VCO}m(t)$ represents the instantaneous frequency deviation ($\Delta f$).

Since the phase and angular frequency relationship is defined previously, we can derive the instantaneous phase as follows:

$\displaystyle \theta_i(t) = \int_{0}^{t} \omega_i(\tau) d\tau = \omega_ct + 2\pi K_{VCO} \int_{0}^{t} m(\tau) d\tau$

With the instantaneous phase defined, we can write the FM output signal as follows:

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + 2\pi K_{VCO}\int_{0}^{t} m(\tau) d\tau\bigg)$

Mathematically, to analyze the FM signal, a single tone message is usually used, by approximating the baseband signal as a sinusoidal wave shown below:

$\displaystyle m(t) = A_m \cos(\omega_mt)$

where $A_m$ is the amplitude of the baseband signal and $\omega_m$ is the angular frequency of the baseband signal. Substituting the sinusoidal baseband signal to the FM output signals, we find:

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + 2\pi K_{VCO}\int_{0}^{t} A_m \cos(\omega_m\tau) d\tau\bigg)$

$\displaystyle x_{FM}(t) = A_c \cos\bigg(\omega_ct + \frac{K_{VCO}A_m}{f_m}sin(\omega_mt)\bigg)$

The peak frequency deviation ($\Delta f$) is obtained from the modulation sensitivity of the VCO and the amplitude of the baseband signal. The ratio of the peak frequency deviation ($\Delta f$) and the modulating frequency ($f_m$) is called the modulation index, $\beta$. Thus, we can see the usual FM equation as follows:

$\displaystyle x_{FM}(t) = A_c \cos \big(\omega_ct + \beta\sin(\omega_mt)\big)$

In the next article, I will be talking about the Bessel function and how to use them to analyze a Frequency Modulation wave.

When designing a PCB Prototype, the components you want to use are often not found in your favorite CAD software’s library, which made you have to add the component on your own. This short article will discuss how to make a library with all those components. For example, I’m going to make a library to help designing my LoRa APRS project design which I am improving. I have a LoRa module named “HDP14A ver 1.2”, an unusual module compared to the popular ones such as HopeRF or Ai-Thinker. To create this module, I have to make my own library. I will show you have to make it in KiCad 5

Picture 1. Physical Shape Of LoRa Module HPD14A ver 1.2

# Create Project

Open KiCad and start by making a new Project using the ‘ctrl+N’ Shortcut. Give it a name and assign it to a folder of your choice. After opening that Project, click on ‘Symbol Library Editor’ as in Picture 2

# New Library

After opening the Symbol Library Editor, you can make a new library on your own. To make one, click on File > New Library. As an example, I will make a Library and named it with lora-aprs.lib. After clicking on Save, you can choose to save it as a library for this project only, or as a global library

# Create a Component

After making a Library, the next process is to create the component. You can do that by clicking on ‘Create New Symbol’ button, or by going to Symbol > New Symbol. You will then be asked to choose what Library is going to be used to save this new component you will create. After selecting the appropriate Library, press the OK button

After creating the components and naming it (mine is HPD14A), the next process is to add pins on the symbol. You can do that by going to Place > Pin to add pins on a new component. Adding pins can be done as shown in Picture 5. You can add the pin orientation, number, and name of the said pin. In addition, you can also change the type of the pin connection if it is an Input, Output, Bidirectional, Power, etc. After successfully adding a pin, you can configure its position and add a square with Place > Rectangle to make it available to be used

Picture 6 shows the completed result, a LoRa module symbol with 16 pins. The pins on the symbol are grouped according to each of its function. When you’re satisfied with the result, you can save it with Ctrl+S. This component will then be accessible for your project, so you can immediately use it for PCB design

Saat merancang prototipe PCB, seringkali komponen yang Anda gunakan tidak terdapat library nya di software CAD favorit Anda, sehingga Anda perlu menambahkannya sendiri. Artikel singkat ini akan membahas bagaimana cara membuat library untuk komponen-komponen tersebut. Sebagai contoh saya akan membuat library untuk membantu merancang board dari project LoRa APRS yang sedang saya kembangkan. Saya memiliki modul LoRa dengan nama “HDP14A ver 1.2”, modul ini tidak lazim seperti model yang lebih populer seperti buatan HopeRF ataupun Ai-Thinker. Untuk mencoba menggunakan modul ini, saya perlu membuat library sendiri. Saya akan menunjukkan cara membuat symbol library di KiCad 5 untuk komponen ini.

# Create Project

Buka program KiCad dan mulai dengan membuat sebuah Project baru dengan menggunakan shortcut Ctrl+N. Beri nama Project Anda dan letakkan di folder yang Anda inginkan. Setelah membuka Project tersebut, tekan tombol Symbol library editor seperti pada Gambar 2.

# New Library

Setelah membuka program Symbol library editor Anda dapat membuat library baru. Cara membuat library baru adalah dengan menekan tombol FileNew Library. Sebagai contoh, saya membuat library dengan nama sesuai dengan nama project, yaitu lora-aprs.lib. Setelah menekan tombol Save, Anda dapat memilih untuk menyimpan library ini sebagai library untuk project ini saja atau sebagai library global.

# Create a Component

Setelah berhasil membuat library, proses selanjutnya adalah membuat komponen, membuat komponen dapat dilakukan dengan menekan tombol Create New Symbol, atau melalui menu Symbol > New Symbol. Setelah itu Anda akan diminta untuk memilih library mana yang akan dipakai untuk menyimpan komponen baru yang akan Anda buat. Anda bisa memilih library yang telah dibuat dan menekan tombol OK.

Setelah membuat komponen dan menamakannya sesuai dengan nama modul yang saya pakai: HPD14A, proses selanjutnya adalah menambahkan pin pada simbol tersebut. Anda dapat menggunakan menu Place > Pin untuk mulai menambahkan pin pada komponen baru. Selain itu, Anda juga dapat menggunakan Place > Rectangle untuk membuat kotak pada simbol tersebut. Anda bisa mengatur simbol yang Anda buat dengan meletakkan posisi pin sesuai yang Anda inginkan.

Penambahan pin dapat dilihat seperti pada Gambar 5. Anda dapat memasukan orientasi pin, nomor pin, dan nama pin. Selain itu, Anda juga dapat mengganti jenis koneksi pin tersebut, apakah berupa Input, Output, Bidirectional, Power, dll. Setelah berhasil menambahkan pin, Anda dapat mengaturnya supaya memiliki posisi yang sesuai, dan menambahkan kotak dengan Place > Rectangle untuk menghasilkan simbol yang siap pakai.

Gambar 6 menunjukkan hasil simbol yang sudah selesai, yakni simbol modul LoRa dengan 16 pin. Pin pada simbol dikelompokkan sesuai dengan fungsi masing-masing pin. Setelah Anda puas dengan bentuk dari simbol yang telah dibuat, Anda dapat menyimpannya dengan Ctrl + S. Komponen ini akan dapat diakses pada project Anda, sehingga Anda dapat memulai membuat desain PCB dengan modul ini.

# Cloning the Library via GitHub

Library can be accessed through Github, where almost everyone can share their library and contribute to the open source library in GitHub. If there are new additions in the library, the version renewal using Git will be much easier and won’t take much hard disk space, as only the additional files will be downloaded and not the entire files. to download Sparkfun library in GitHub, make sure you have the git package and execute the command below:

\$ git clone https://github.com/sparkfun/SparkFun-KiCad-Libraries.git

Access “Environment Variable Configuration” in Preferences > Configure Paths. Add new Environment Variable using the “Add” button, then give the name “KICAD_SPARKFUN_SYMBOL” and show the folder location using the “Browse” button.

After adding Environment Variable, open Eeschema (Schematic Editor) and open Preferences > Manage Symbol Libraries. Press “Browse Libraries…” and select all desired library before pressing open

Open Pcbnew (PCB Layout Editor) and open Preferences > Manage Footprint Libraries. Then, press “Browse Libraries…” and select all .pretty folders which you want to add before pressing “OK”

## Installing KiCad: Open Source PCB Designer Suite (English)

KiCad is an open-source software to create schematics, PCB layouts, and Gerber. KiCad can be used in Windows, Linux, and macOS, and licensed under GNU GPL v3. KiCad is made by Jean Pierre Charras, a professor in Grenoble University. KiCad is also sponsored by CERN and had several KiCad developments done under CERN employees. If you’re interested to develop KiCad, you can do it through CERN

I’m interested to try this application to do simple projects as a hobby. KiCad became the optimal choice because it is open source, which allows anyone to use it. Aside from that, KiCad also has a library which is updated weekly, accessible via GitHub. Adafruit which produces many modules and even development boards also used KiCad to create their products

# Ubuntu Installation

I tried to install it using Ubuntu 18.04 this time, you can see the installation manual from this link: KiCad Ubuntu

I’ll explain how to install KiCad PCB v5 in Ubuntu 18.04. First, you need to add this ppa:

# add-apt-repository -y ppa:js-reynaud/kicad-5

(Ubuntu 16.04) If you’re using Ubuntu 16.04, use apt-get update before installing KiCad:

# apt-get update
# apt-get install kicad

You will download around 391MB using that command, and installing KiCad will take around 4,970MB disk space. After that’s done, you can open KiCad through a terminal or a launcher

## Spreading Factor, Bandwidth, Coding Rate and Bit Rate in LoRa (English)

In the previous article, I discussed about several basic Spread Spectrum concepts while specifically talking about LoRa modulation and touching the topic regarding several parameters in LoRa. Those parameters in question are Spreading Factor, Bandwidth, and Coding Rate. The three parameters will determine how sensitive the LoRa receiver will perform and how fast the data transmission speed will be. I will shortly discuss them in this article, hoping that the readers will be able to understand the concept and implement it in a LoRa-based system

# Symbol

As discussed before, LoRa is a chirp spread spectrum modulation. The transmitted data, which is a symbol, will be represented by a chirp signal with a frequency range from $f_{min}$ to $f_{max}$, which is shown in Figure 1. In LoRa modulation, we can configure the symbol by changing the Spreading Factor and Bandwidth parameters. According to Application Note Semtech AN1200.22, one symbol will take $T_S$ of second to transmit, which is a function of Bandwidth and Spreading Factor can be shown with the equation below:

$\displaystyle T_S = \frac{2^{SF}}{BW}$

# Bandwidth

Bandwidth is the frequency range of the chirp signal used to carry the baseband data. In Figure 1, the Bandwidth can be seen from the width of frequency used between $f_{min}$ to $f_{max}$. Aside from that, Bandwidth can also represent chip rate from LoRa signal modulation

$R_C = BW$

The value of Spreading Factor (SF) determines how many chips used to represent a symbol. The higher the SF value is, the more chips used to represent a symbol, which means there will be more processing gain from the receiver side. This will allow receiver to accept data signals with negative SNR value

$\displaystyle R_S = \frac{BW}{2^{SF}}$

Spreading Factor shows how many chips used to represent a symbol, with an exponential factor of 2. 1 symbol may consist of N chip where $N = 2^{SF}$. A cyclic shift can be done to represent a bit and sent symbol. If there is N amount of chips, then the resulting symbol value may range from 0 to N-1, or that 1 symbol may represent SF bits

$\displaystyle R_b = SF * \frac{BW}{2^{SF}}$

# Coding Rate

LoRa modulation also adds a forward error correction (FEC) in every data transmission. This implementation is done by encoding 4-bit data with redundancies into 5-bit, 6-bit, 7-bit, or even 8-bit. Using this redundancy will allow the LoRa signal to endure short interferences. The Coding Rate (CR) value need to be adjusted according to conditions of the channel used for data transmission. If there are too many interference in the channel, then it’s recommended to increase the value of CR. However, the rise in CR value will also increase the duration for the transmission

$\displaystyle R_b = SF \frac{\big[\frac{4}{4+CR}\big]}{\big[\frac{2^{SF}}{BW}\big]}$

## Automatic Position Reporting System (English)

Automatic Position Reporting System or APRS is a digital communication protocol between a large number of amateur radio stations that covers a wide area. APRS can be used to send several tactical information, such as weather, location, messages, and several special events or emergencies in real time. APRS system is made by Bob Bruniga (WB4APR) from over 25 years ago, but this system is still actively used by many amateur radio stations

Like other amateur radio stations which still exists until now, APRS is already integrated through the internet. You can oversee many kinds of tactical information through APRS. One example of a website which shows APRS data is APRS.fi. In Picture 1, you’ll see many weather stations located in Tucson, Arizona, USA. One of the traditions for amateur radio stations in the United States is to provide public services, one of which is weather observation. Amateur radio station operators who owned weather stations use APRS to distribute the collected data

Although it’s called Position Reporting System, APRS itself isn’t intended as a GPS Tracker system. The development of APRS is triggered by GPS development back then, but APRS is actually a two-way communication system for real-time tactical communication

Picture 1. Screenshot of Amateur Radio Stations’ activities in Tucson, Arizona, USA

After knowing about APRS systems and one of its applications, let’s talk about the components of an APRS system. In APRS systems, you may hear several terminologies such as:

1. Terminal Node Controller
2. Digipeater
3. APRS-IS iGate

Terminal Node Controller is the digital radio modem used in APRS. It’s usually based on Bell 202 Modem or Audio Frequency Shift Keying modem with baudrate of 1200 baud.

Digipeater is a digital repeater capable of resending data package which then allows many other stations could receive the information. Digipeater normally has a high power and placed on tall buildings to have a wide coverage area

APRS-IS iGate is an APRS connected to the internet so it can relay messages received through RF waveforms and entered them into APRS-IS server. From APRS-IS server, you can see the packages through several APRS websites or software

To enter the world of APRS, you have to own an amateur radio callsign. In Indonesia, you can register through “SDPPI Postel Kemkominfo”. You will have to enter a national exam for Amateur Radio (Ujian Nasional Amatir Radio) and if you passed, you will receive a certificate for that. Then, make sure you have the Permit to own an Amateur Radio Station (Izin Penguasaan Perangkat Radio Amatir). If you don’t want to do any transmission, tapping into APRS transmissions is allowed by anyone who has TNC and HT Radio

And that’s a small piece of information regarding APRS. I’ll add in more details on a different occasion

Sources:

## LoRa Modulation Basics (English)

LoRa is a spread spectrum modulation technology patented by Semtech. LoRa is a derivative of Chirp Spread Spectrum (CSS) which lowers data rate to improve sensitivity. If you want to place LoRa in the OSI Layer, implementation of LoRa modulation exists on the physical layer and can’t be bound to other layers above it. This allows LoRa to adapt with several robust connections. This article is made to discuss several LoRa basic concepts as a reference to develop LoRa-based systems

For someone well-versed in Telecommunication, the Shannon-Hartley Theorem is no longer something foreign. This theorem explains about the canal capacity of a communication link using specific bandwidth with noise in the canal. I won’t write in the full theorem and details, but from the derivation of the mathematical formula, we can find that by increasing bandwidth, the performance between link communication with Noise-to-Signal ratio level will improve. In Spread Spectrum technology, you’ll usually hear that Noise-to-Signal ratio compared to Signal-to-Noise ratio because the power of a signal is usually below the noise floor

Just like the Shannon-Hartley theorem, bigger bandwidth can compensate for SNR degradation in the radio canal. In a Spread Spectrum system, the sent data is multiplied with Spreading Code, also known as Chip Sequence. Chip Sequence usually has a frequency far higher than the information frequency which resulted in a wider bandwidth when both signals are multiplied. On the receiver side, the received signal will be multiplied with the same chip sequence signal to obtain the original data

LoRa modulation provides alternatives for Spread Spectrum communication which are low power and low cost compared to the conventional Spread Spectrum technique. LoRa modulation uses chirp signal, which is a signal with a frequency which varies over time. By using this method, the complexity for the receiver side will be reduced. The output signal from this modulation matches the bandwidth used by the chirp signal

In LoRa modulation, the data with a certain bit rate that we want to transmit will be multiplied with a chirp signal with a certain Chip Rate. The Chip Rate is far larger than the data signal we want to send, which then became the Bandwidth from modulated LoRa signal

Aside from Bandwidth, there is also Spreading Factor. If Bandwidth shows chip rate, Spreading Factor shows how much chip is used to represent a symbol. Other than that, Spreading Factor also shows how many bits contained in a symbol

LoRa also has a mechanism called Forward Error Correction (FEC). FEC configuration can be done using the Coding Rate parameter. Just like a normal radio communication, noise can affect the performance of a system. By adding redundancy using FEC, the LoRa-based system designer can decrease the bit rate to increase the system’s reliability

To design a LoRa-based system, you have to pay attention to these three parameters to get an appropriate bit rate, decent enough range, and a nice reliability

Edit Aug 05/2018: The terminology in Spread Spectrum parameter had been corrected to make it more accurate

## Bluetooth HC-05 AT Commands (English)

Bluetooth is one of the simplest communication modules which can be bought at a relatively cheap price. HC-05 Bluetooth Module can be easily found in many online shop websites around fifty thousand rupiahs. Before we further out discussion, I’ll talk about several Bluetooth basic concepts

# Introduction

Bluetooth is a wireless technology standard for short-distance communication. Bluetooth uses 2.4 GHz frequency, which is a free-to-use frequency channel, with a low power limitation. Bluetooth standard encompasses quite a lot of protocols, one of which is RFCOMM Protocol. The Bluetooth Module which we usually find normally uses this protocol. RFCOMM Protocol is pretty popular because there is a lot of APIs available using this protocol. In addition, this protocol, commonly called as Emulation Port, can be integrated to many applications using RS-232 as its communication interface

# Generic Bluetooth RFCOMM Modules

After knowing several of Bluetooth basic concepts, it’s time to see how Bluetooth works directly. For this demonstration, I’ll try using Bluetooth Module: Tokopedia (Disclaimer: No intention of promoting).

The Bluetooth Module as depicted in Picture 1 is a Module based on Bluetooth Chip BC417. This module has several output pins such as STATE, RX, TX, GND, +5V, and EN. To use this module, it’s enough to connect the RX, TX, GND, and +5V pins.

The 5V pin, or VCC Pin, in this module is actually connected to the LDO Voltage Regulator in this Bluetooth Module Board. I tried to see what kind of Regulator is being used, but it’s pretty hard to find a datasheet for this SMD component. Before I talked about how AT programming commands are, I’ll test the serial port using this Bluetooth Module first

Connect the Bluetooth TX pin with RX Raspberry Pi, RX Bluetooth with TX Raspberry Pi, VCC with +5V Raspberry Pi and GND with GND Raspberry Pi. I’ll turn on the minicom to open the serial port (/dev/ttyS0) using baudrate 9600. The test display result should be as shown in Picture 2

# AT Commands Bluetooth

After finished testing the Serial communication, the next thing to try is the AT Commands. Several configurations such as Bluetooth name and PIN and also baud rate could be done through AT Commands. To do that, I made a short script in Python to execute this function. Before trying this script, make sure Raspberry Pi had been installed with Python and PySerial package (python-serial)

# apt-get install python-serial

Before I give the source code from AT Command Configuration, it’s important to know that entering AT commands can be done in three ways. The first is to give 3.3 Volt input to the 34th pin in the Bluetooth Module. This will make the module enter a Full AT Commands mode, where all AT Commands can be accessed and baudrate from the module is 38400. The second method is by pressing a button before the module turned on and make sure the button is still pressed as the configuration process continues (this is effectively similar to the first method), which makes the module enter a Full AT Commands mode. The third method is that after the module is turned on, press a button on the module and keep it pressed when doing the configuration. The module will then enter a Semi AT Command mode where the baudrate is still the normal serial communication baudrate (9600 baud default). If you forgot what baudrate you had set for your serial communication baudrate, it’s better to program your Bluetooth in Full AT Command mode

# attest.py
# Sending AT commands to Bluetooth HC-05

import serial
import time

bluetooth = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=5)

bluetooth.write('AT+NAME=JosefMTD\r\n')
print result