Virtual Environment setup

Virtual environment (venv shortly) is a python mechanism where it is possible to create a space for your project and specific packages required by it.

Cases when Virtual Environment is useful

  • when you want to develop a project which will require specific version of libraries and you don’t want to mess with version which your python is using globally;
  • when you want to test your project with cooperation with different python versions and packages version
    • especially when from different reasons your target environment forces you to use specific python version or packages version
      • for example when you are developing module for legacy system
  • due to cleaning reasons – with venv you can just move whole folder with virtual env to the OS trash space and that’s it – to remove all dependencies you don’t have to manually uninstall each library
  • portability – you can easily

Working model with virtual environment

  1. (only once) installation of virtual environment
  2. activation
  3. usage (calling the code like normal usage)
  4. deactivation

During daily work it is enough to perform steps 2-3-4;

Actions to install virtual environment

  1. create new folder for venv
create new folder for your virtual env
create new folder for your virtual env

2. open command line or powershell (or shell on Linux / macOS) and run following commands:

  • go to folder above your virtual environment

cd <path>

  • establish new virtual environment

python -m venv .\my_venv\

After starting this command you should wait about 10 sec to execute.

When finished content of your folder will look like this:

new virtual environment after creating
new virtual environment after creating

  • perform activation of virtual environment – depending on OS it can be performed in following ways:
    • Linux
      • source my_venv/bin/activate
    • Windows
      • my_venv\Scripts\activate

Since now your command prompt will have prefix with the name of python environment. This will inform you that you are working on virtual environment.

Your command prompt will look like this:

command line (here Powershell) after activation of virtual environment
command line (here Powershell) after activation of virtual environment

3. Now you can start to work on jour project – just create own folder (for example MyNewProject) in the path of your virtual environment – like here:

creating own path inside virtual environment
creating own path inside virtual environment

Inside your project you can develop your application, install web framework use git version control system, etc.

  • You can see list of currently installed packages in your virtual environment over command:

pip list

  • If you want to install new libraries – just run:

pip install <your package name>

! be sure that your virtual environment is active – otherwise libraries will be installed globally

4. After finishing your work with virtual environment – just call following command:


That’s it regarding working with virtual environment. enjoy!

Professional vs amateur software project

programming process
programming process

Most significant differences

Number of team member

Documentation and proper communication is crucial point.

  • Some team members can work remotely or on other part of the world!
    • clarifying even small issues can be a challenge when working hours are different.
  • It is worth in such cases to schedule regular meetings, in order to assure continuously information exchange process
    • Very important is to create a team which puts stress on transparency and sharing which activities are done by each team member.
    • Agile methodologies like SCRUM are supporting such processes very well; Inside SCRUM there are special meetings for it like daily SCRUM, Sprint review, Sprint planning.

Documentation is a key feature

Especially with long lasting project with many team members.

Some employee can be ill/change company/ etc. and this will mean that knowledge collected by them can be suddenly unavailable.

Docs will help to introduce new team members – this will require less time to put him on current track.

Usage of coding standards

Bigger projects with a lot of code (many thousands lines) are easier to read and maintain where the code was written conform with special standard.

Coding standards are expressing the way:

  • variables and functions naming;
  • a way of structuring the code (especially in C or Java);

Examples of such standards: clang-format, MISRA, PEP8 (for Python);

  • It is worth to use automated tools to check instantly the code standard inside IDE – like cppcheck, pc-lint, or pylint, flake8 (both last ones for python);

Usage of code-review processes

Automated checking tools (for coding standards ) are not assuring that the logic of implementation was done in a right way. To assure it there are processes where other team members are reviewing created code. This spreads good practices and knowledge across whole team.

Usage of version control system – for instance Git

Very important is also to create processes of working with such tool, for example “git-flow”. More info you can find here.

Build processes independent from IDE

  • To establish continuous integration processes
  • Allows that team members are using different IDEs
  • Example of such tool is CMake

Testing and debugging methods

Platform dependent parts should be splittet from remaining parts.

  • In such way most of code can run on the PC instead on target HW.
    • In this way it is possible to introduce unit-tests which can run in continuous integration process;

Continuous integration is automated building and testing process executed in a scheduled way. For example every night to obtain instant info about nr of bugs in the code.


As you can see there is a bit of points which are describing professional way of creating code. Of course it is not recommended to preform instant revolution inside your project. It is much better to perform evolution and make step by step improvement to achieve very efficient way of developing your application.

Feel free to share your opinion in the comment section.

Infos collected in this articles are based on my own experience and also on points posted here;

Logic Analyzer – basics, how to use

Table of content:

  1. Introduction and potential use cases for Logic Analyzers;
  2. How to handle logic analyzer
    1. from HW side
    2. from SW side
  3. Usage examples

Introduction and use cases

Logic Analyzer is a tool which is extremely useful (almost necessary) during debugging of digital communication. With this component we are able to decode what happens during message exchanging between two IC’s.

You can imagine that you are implementing inside your project handling of a new protocol to your new chip, but you are observing that your device is not working in a proper way. First what to you will do is starting to analyze what your code is doing. Unfortunately it may be insufficient. Especially in cases that you can’t find any bug in the code.

In such situations the best idea is to connect logic analyzer between your two devices and listen in (overhear) the communication process. This way you can assure that your microcontroller (or any kind other device) is sending proper messages. In similar way you can check that other communication member is responding in a proper way.

Generally logic analyzer is a method to check on HW side that communication works ok.

Disadvantages of Logic Analyzer

  • Logic analyzer is not able to measure analog signals
    • for such purposes you should use oscilloscope;
  • Logic Analyzers are designed to operate with specified maximal frequency
    • if your communication uses higher frequency signals you have to buy another (most expensive also) logic analyzer

Presentation usage of Logic Analyzer

In this article I want to present clone of Salae Logic analyzer.

Logic Analyzer
Logic Analyzer

Key features of presented logic analyzer:

  • price – about 10$
  • number of channels: 8 inputs
  • 24MHz sampling frequency
    • it is possible to reduce sampling frequency (between 25kHz and 24MHz)
  • 2 LEDs (red for power indication, green for connected CH1)
  • max nr of samples 1G
  • possibility to chose method of sampling:
    • rising edge
    • falling edge
    • high level
    • low level
  • powered over USB
  • ability to decode following protocols:
    • UART (RS232)
    • SPI
    • I2C
    • CAN
    • 1Wire
    • Manchester
    • … many more over additional plugins
  • at purchasing you receive USB cable and connecting cables

In case of decoded protocols we are receiving not only the course of the signal, but also data are already translated either to ASCII or HEX form.

Hardware connection

In order to perform measurement we have to connect:

  • GND of the logic analyzer with GND of measured device;
  • Suitable channel to measured line.
    • When we need to measure more signals at the same time we have to also connect other channels.

When multiple channels are measured from different devices then GND have to be common.

Example with schematic will be presented later in this article.

Software usage

In order to be able to see results of a measurement we have to install proper program to handle data acquisition.

Logic analyzer presented here can be operated over to different programs:

  • Salae Software
    • This is official software of company SALAE. In this article I will show you how to use it.
    • Curiosity – SW was developed in Python with GUI Qt framework.
  • Open Source – Sigrok
    • This is free software which is also operable with this logic analyzer. In next article I plan to describe how to work with Sigrok.

Installation process

Here you have link to download Salae software. After installation you can find launcher in specified folder or in windows 10 just type “Logic” to search pan.

Searching of Salae SW on windows machine
Searching of Salae SW

Using the program

After connecting logic analyzer to the PC open “Logic” program. After it you should see following screen:

Salae Logic - after opening
Salae Logic – after opening

In order to present functionalities I will introduce you two logic analysis examples:

  1. UART communication sent from Arduino Leonardo to PC;
  2. Temperature measurement over 1-Wire communication (usage DS18B20 sensor);

1. Analysis of UART communication

To execute this exercise you will need:

  • Arduino Leonardo / Nano
    • or any other microcontroller capable to send UART messages like STM, AVR, PIC, 8051, etc.
  • UART TTL adapter;
  • Logic Analyzer
Exercise 1 - connection schema
Exercise 1 – connection schema
Exercise 1 - connection photo

Exercise 1 – connection photo

Perform following steps:

  1. Connect HW as on above schema and photo;
  2. Open Arduino studio and flash following program
    • hint: to perform this example you can also use Arduino Nano (or any clone of it);
    • copy code and paste to your Arduino IDE;
  3. Open terminal to observe UART communication and assure that everything works fine
    • Assure that settings are properly set (baudrate 9600, 8 data bit, no partity and one stop bit) – see photo below;
 Exercise 1 - Terminal settings
Exercise 1 – Terminal settings

Steps in Salae Software

1.Open Salae Logic;

2. Choose type of protocol (Async Serial for UART)

Exercise 1 -  Choose protocol type
Exercise 1 – Choose protocol type

3. In appeared window choose UART configuration – then click save

Exercise 1 -  Set UART properties
Exercise 1 – Set UART properties

4. Choose sampling rate and how long measurement should take. (click on green arrow next to Start button);

Exercise 1 -  Set sampling-rate and measurement duration
Exercise 1 – Set sampling-rate and measurement duration

in some cases when measured signals are to high frequency Salae Logic will suggest to increase sampling time;

5. at the final stage you can set how big should be presented measured signal (only to analyze comfort)

Set size of signal view
Set size of signal view

Start data acquisition;

  • click big green button Start;
  • you should observe result similar as on below photo:
Exercise 1 -  Measured Signal
Exercise 1 – Measured Signal

In order to zoom-in the view – press ctrl and mouse scroll mouse

Analyze the data

Exercise 1 -  Data Analysis
Exercise 1 – Data Analysis

It is possible also to choose type of decoding (like ASCII or HEX) – as in the picture above.

2. Temperature measurement – sensor DS18B20 over 1Wire

In the second exercise I will show You how to work with analyzing 1Wire communication;

To execute this exercise you will need:

  • Arduino Leonardo / Nano
    • or any other microcontroller capable to send UART messages like STM, AVR, PIC, 8051, etc.
  • DS18B20 temperature sensor;
  • Resistor 4.7kOhm (in case that you are not using any special kit / board with sensor where such resistor is already embedded)
  • Logic Analyzer
Exercise 2 -  connection schema
Exercise 2 – connection schema
Exercise 2 -  connection photo
Exercise 2 – connection photo

Perform following steps:

  1. Connect HW as on above schema and photo;
  2. Open Arduino studio and flash following program
    • hint: to perform this example you can also use Arduino Nano (or any clone of it);
    • copy code and paste to your Arduino IDE;
  3. Open terminal to in Arduino studio – you should receive communication messages like on below photo;
Exercise 2 -  Arduino terminal messages
Exercise 2 – Arduino terminal messages

Steps in Salae Software

1.Open Salae Logic;

If you have other analyzer already configured – click on settings window and click “Remove Analyzer”

Exercise 2 -  remove old analyzer
Exercise 2 – remove old analyzer

2. Choose type of protocol – Check 1Wire

Exercise 2 – choose 1Wire protocol

3. Choose channel 1

Exercise 2 -  choose channel
Exercise 2 – choose channel

4. Analog like in previous exercise:

  • choose sampling rate – 2Ms/s
  • measurement duration – 8s

and then click Start button

5. You should observe measurement like that:

Exercise 2 – results


That all for this presentations of possibilities to use Logic Analyzer.

If you have any question – feel free to share it in comment below.

Python GUI Kivy Tutorial – part 1 – install Kivy library and demo running

Kivy Logo

In order to create python application with user interface it is needed to use right libraries (packages). 

One of them is Kivy. Huge advantage of this package is that it is cross-platform. So programs written with it can be run on different operating systems.

Continue reading “Python GUI Kivy Tutorial – part 1 – install Kivy library and demo running”