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
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
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
Add Pins on Symbol
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
KiCad has an open source library, which is one of the advantage of it. Every week, KiCad’s library is updated through GitHub from KiCad. This article is dedicated to show how to install additional libraries for KiCad, and adding third-party libraries such as Digi-Key or Sparkfun Electronics for example. Digi-Key and Sparkfun’s libraries can be accessed through the links below:
As an example, this article will show how to add Sparkfun library on KiCad 5.0.0 for Ubuntu 18.04
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:
After you finish the download, you can see several folders which contained Library and other supplementary folders, and also additional files. The result of downloading the library is as shown in Picture 1
Adding the Library in KiCad
After downloading the library, the next thing is to open KiCad program to add the downloaded library. But before that, make a new Project by using File > New > New Project
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”
That’s all about adding libraries to KiCad. Next time, I’ll talk about creating a simple PCB design using KiCad. Have fun trying KiCad!
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
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
I plan to start a series of articles using KiCad. I’ll talk about adding library through KiCad GitHub after this. Have fun trying KiCad!
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
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 to , 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 of second to transmit, which is a function of Bandwidth and Spreading Factor can be shown with the equation below:
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 to . Aside from that, Bandwidth can also represent chip rate from LoRa signal modulation
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
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 . 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
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
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
Spread Spectrum Technology
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 Spread Spectrum
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 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
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
# Sending AT commands to Bluetooth HC-05
bluetooth = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=5)
result = bluetooth.read(100)
result = bluetooth.read(100)
To use the program above, change “/dev/ttyS0” into “/dev/ttyACM0” if using PL011 Hardware UART from Raspberry Pi. Only use “/dev/ttyS0” if you’re using mini UART. Set baudrate according to the module’s baudrate or put in 38400 if you want to enter Full AT Command mode
To change the name and baudrate, Bluetooth module can be configured in a Semi AT Command mode, which is why my set of processes are to press a button, run attest.py script, and let go of the button when it finished
That’s all from me this time, leave a comment if you have a problem in setting up the Bluetooth
Do you want to try playing around with Raspberry Pi? Maybe you have encountered several problems such as no monitor to configure Raspberry Pi, no keyboard to write the commands, or no LAN cable. Maybe you have the same problem as mine, owning Raspberry Pi Zero W which can only be accessed through Wireless, USB using micro USB, or mini HDMI. If you have Raspberry Pi Zero and want to start playing around with Raspberry, please read this guide to start installing your Raspberry Pi!
Instalasi Operating System Raspbian Stretch Lite
Several things you need to start are as followed:
Raspberry Pi Zero Wireless (make sure it’s not a Raspberry Pi without WiFi)
Micro SD Card (Class 10 is better so the Read/Write Disk operations are better)
2A Handphone Charger
Laptop with SD Card Reader (Micro-SD Adapter, if necessary)
Wireless Router or Mobile WiFi Hotspot
The first thing you need to do is to put in your SD Card into your computer, then format it if you have installed Raspbian on that SD Card. You can format it using SD Card Formatter (sdcard.org).
For a comparison, Picture 2 shows the formatting using quick format Windows dan SD Card Formatter. Windows Formatter can only format the F:\ partition in SD Card, while SD Card Formatter can format all of SD Card.
After doing Quick Format using SD Card Formatter, you can add Raspbian OS in SD Card. First thing you need to do is to download ZIP File from Raspbian OS Stretch Lite. Download from the Raspberry Pi official website for Raspbian Stretch Lite, with kernel Linux 4.9. There are two variants of Raspbian Stretch, which are the Desktop and Lite variants. Lite is the version without GUI, while the Desktop one had GUI so it can be connected to a monitor and keyboard and used like a normal computer.
After you have Raspbian Stretch Lite and a formatted SD Card, the next process is to flash Raspbian Stretch Lite on SD Card Formatter. My most favorable method is by using the Etcher program. This program can be downloaded from Etcher.io and it’s easy to use
Picture 3. Choosing Raspbian Stretch Lite to flash on SD Card using Etcher program
SSH Server dan WiFi Setup
To access Raspberry Pi without monitor or keyboard, you need an SSH Server and a WiFi connection. On the computer you’re using to configure Raspberry Pi, make sure you have an SSH client so you can use PuTTY.
To turn on SSH, you need to create an “ssh” file on the boot partition in SD Card that you flashed using Raspbian OS. Make sure you made the ssh file without any extension (not even .txt). It didn’t need to contain anything, just ensure that there is a file named “ssh”
Picture 4. Installing SSH Server using SSH file without any extension in the SD Card for Raspbian
After adding the SSH server, the second thing you need to do is to create a “wpa_supplicant.conf” file on the boot partition. The content of this file is as follows:
Use Notepad to write those, and make sure you saved it as “wpa_supplicant.conf”, not in .txt extension. Picture 5 shows the result of creating “wpa_supplicant” file which is placed in the boot partition (F:\). Change NAMA_WIFI_ANDA with the SSID your WiFi is using, and PASSWORD_ANDA according to the WiFi password.
After installing the Raspbian OS and adding the necessary files according to the instructions above, eject the SD Card and plug it into Raspberry Pi Zero.
Accessing SSH Raspberry Pi from PC
After ensuring that the created files are according to this tutorial, turn on Raspberry Pi Zero for the first time using the SD Card which had been installed with Raspbian OS and configured to be accessed using SSH through WiFi. Check the IP Address of your Raspberry Pi to access it using Raspberry Pi. You can use your Router’s DHCP Table to know which IP address is your Raspberry Pi’s. An example of that is shown in picture 6.
After that, you can open PuTTY to access SSH from Raspberry Pi with the IP Address you obtained through your DHCP Router. You can login using
login as: pi
firstname.lastname@example.org's password: raspberry
Make sure you follow the instructions above, using “pi” as your login name and “raspberry” for your password. After that, you can access Raspberry Pi Zero through SSH to change your password. You can do that using the command:
You’ll be asked to fill the old password (raspberry) and fill in the new one. After you filled it, make sure the SSH Server from Raspberry Pi is turned on permanently. You can do that by using this command as root (sudo):
By accessing raspi-config, you’ll be shown the interface below like in Picture 7 on your PuTTY window screen. Direct the pointer to the “Interfacing Options” and press Enter.
After accessing Interfacing Options, choose P2 SSH to access SSH Server configuration. You’ll be asked “Would you like the SSH server to be enabled?” Choose Yes and press Enter. You’ll then see “The SSH server is enabled”. After you’re redirected to the front page, press Finish to exit. You’ll be able to access Raspberry Pi via SSH without using Monitor or Keyboard after this, but ensure that you have WiFi with the same SSID and Password as the configuration you had done
Still have more questions? Please ask in this blog post. Good luck experimenting with your Raspberry Pi.
Do you want to use Python 3.6 on Raspberry Pi? When you run Python in Raspberry Pi, the version called is usually v2.7. This blog post will discuss how to change the default Python 2.7 into Python 3.6.
Before I begin the tutorial, I want to explain one thing which is commonly seen in Linux tutorials, the ‘$’ and ‘#’ annotations. When writing a command in Linux Terminal’s common documents, both annotations are commonly used as prefixes. The reason for that is in Linux Terminal, when the user isn’t accessing root, will show the ‘$’ annotation. If the Terminal is showing ‘#’, then the user is accessing root. In the document which showed Linux commands, ‘#’ means the command must be accessed as root (or with sudo)
The first thing that can be done is to check if your default Python is on version 3.x or 2.x. You can use this command to make sure of that
$ python --version
There are a few things that must be done to change Python 2.7 into Python 3.6. The first thing is to ensure that several package dependencies must have been installed in Raspberry Pi. To make sure, you can use the command below
After executing those programs, you can download the source code for Python 3.6 from Python’s official website. Python 3.6 source code is provided in tar.xz, which means you have to unpack it. But before you download it with wget, make sure your file is in the /tmp/ directory, so it will be deleted after you reboot
$ cd /tmp/
$ wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
$ tar xf Python-3.6.4.tar.xz
After you finished extracting as in Picture 2, you can see that the source code is at /tmp/Python-3.6.4. To continue with the installation, access Python-3.6.4 directory
$ cd Python-3.6.4
After opening the directory, follow the process below to install Python 3.6.4:
# make altinstall
After installing Python 3.6, you’ll see that Python default is still the same as the previous Python (in my case, still 2.7.13). To change the default Python that is being used, you have to use update-alternatives. First, make sure that you know where to install Python 3.6. and that the installed Python 3.6 can be accessed. Use both these commands to know where Python 3.6 is
$ ls /usr/bin/python*
$ ls /usr/local/bin/python*
After knowing the position of executable Python 3.6, do update-alternatives to add Python 2.7.13 and Python 3.6.4 as Python alternatives. Picture 3 shows the output from command to find out where the executable files from Python2.7, Python3.5 dan Python3.6. Add all those executable Python-s as alternatives from Python
You will then find out the positions, which are /usr/bin/ for Python2.7 and Python3.5 and /usr/local/bin/ for Python3.6 which is just installed. Include the alternative /usr/bin/python using these commands:
After executing the commands above, you’ll be asked to input the number you want to use as your default Python. Type 1 if you want to use Python 2.7.13 because of one reason or another (for example, the library you’re using still uses Python 2.7). After selecting which version you want, you can check the default version using ‘python –version’ command dan the result will show like in Picture 5.
You can use the configuration commands below to select which version you want to use. You can do this if the newest Python version is available and you want to add it into Raspberry Pi. If you have any questions, don’t hesitate to ask them in this blog. Have fun experimenting!