Monday, May 14, 2018

MCP3008 - Analog to Digital Converter with SPI Interface

MCP3008 is an 8-channel, 10-bit analog to digital converter from Microchip.

Figure. MCP3008 pins.

It can be used as 8 single ended analog inputs or 4 differential input pairs. Power supply is 2.7 V to 5 V and its operating temperature is -40 °C to +85 °C. It has an SPI interface which can be operated in mode 0 or mode 3.

Friday, March 9, 2018

DIY Smart Surveillance Camera Using Raspberry Pi Camera and C++

Let us make a smart surveillance camera using a Raspberry Pi single board computer. Normally, it records the videos at 5x speed analyzing continuously and producing video files daily or hourly. Once human bodies are detected in the captured images, it will highlight them with green rectangles and change the recording speed to normal. A passive infrared sensor (PIR sensor) is also used to detect human bodies.

The example program discussed here is just to show the feasibility and it can be improved further. A few examples are sending email to your email address if something happened, recognition of faces of family members, recording videos at different speeds depending on time.

Figure. Connecting a PIR sensor.

Tuesday, January 23, 2018

UDP/TCP Socket Programming with wxWidgets

  1. Introduction
  2. UDP
  3. TCP
  4. References


In this article, UDP and TCP socket programming using wxWidgets is discussed. For that wxWidgets needs to be installed in your machine. Installing wxWidgets on Windows and Linux platforms can be seen at the following link.
Sockets are used to send and receive data on a network such as the Internet. Almost all modern operating systems support socket layer to transfer data using TCP or UDP. But programming sockets on different platforms usually involves platform specific tweaks. wxWidgets support socket classes which allow you to use sockets for transferring data without concerning about the platform. These classes can be used in various ways and some of them are discussed in the following sections.

Thursday, November 23, 2017

OpenCV with wxWidgets

  1. Introduction
  2. Linux
  3. Windows
  4. References


In this article, using OpenCV with wxWidgets is discussed with examples. For that, OpenCV and wxWidgets need to be installed in your system. Installing and using them on Linux and Windows platforms can be found at the following links.


Building an application using OpenCV and wxWidgets in Linux terminal is simple. As an example, a simple program called wxcvsimple.cpp (online) is discussed below. At the start of the program, in OnInit() method of the Application,
is called. Then, wxStaticBitmap variables are declared in MyFrame class, a derived class of wxFrame, to display images. The following code can be used to initialize wxStaticBitmap in the constructor of MyFrame class.

Monday, November 20, 2017

OpenCV on Linux using g++, CMake, Qt, Code::Blocks

  1. Introduction
  2. Using GCC ၊ CMake
  3. Using Qt
  4. Using Code::Blocks
  5. References


To install OpenCV on your Linux machine, you need to have the following packages as prerequisites [Ope17g].
  • GCC 4.4.x or later
  • CMake 2.6 or higher
  • Git
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
  • [optional] libtbb2 libtbb-dev
  • [optional] libdc1394 2.x
  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
To install the required packages, you can enter the following commands in terminal.

Monday, October 30, 2017

Cross-platform C++ programming with wxWidgets

  1. Introduction
  2. Windows Setup
  3. Linux Setup
  4. Mac Setup
  5. References


wxWidgets is a C++ library for creating cross-platform applications. It enables developers to create GUI code to compile and run on several computer platforms such as Windows, OS X, Linux and UNIX with minimal or no code changes.

wxWidgets is free and open source software which satisfies those who wish to produce for GPL and proprietary software without license costs [wxW98]. On the other hand, Qt is available for free under LGPLv3 license but has some limitations for commercial use unless you pay the license fee [Qt17].

wxWidgets uses Native platform , therefore GUI has more native look and feel [wxW12]. Qt extends the C++ language but wxWidgets does not extend the C++ language which is less surprising to developers expecting standard C++.

wxWidgets produces small and efficient binary applications. Therefore, it is suitable for embedded systems. In term of library size, Qt library is \(\approx 200\) MB where wxWidgets library is \(\approx 30\) MB.

wxWidgets not only works for C++, but also has bindings for python, perl, php, java, lua, lisp, erlang, eiffel, C# (.NET), BASIC, ruby and even javascript [wxW15a]. wxWidgets is one of the most complete and mature GUI toolkits. There are a lot of utility classes also.

wxWidgets is used by a huge range of organisations and individuals all over the world. Some of the better-known organisations who have used wxWidgets include NASA, AMD, Xerox, and Open Source Applications Foundation (OSAF). wxWidgets applications that you may be familiar with include AVG AntiVirus, Audacity, Filezilla, Code::Blocks, CodeLite.

Wednesday, September 13, 2017


Pixy ( is a vision system that can be used to add computer vision to your Arduino, Raspberry Pi, or BeagleBone project. Once you have taught it the color to detect, it can send you the position and size of the detected objects.

Thursday, August 3, 2017

KiCad Getting Started Guide in Myanmar Language

KiCad is a suite of free software to design PCBs.[KiCad on Wikipedia]. I have been using it to make PCBs and it is OK so far. It is also easy to use. It comes with tools to check design rules and to produce Gerber files for manufacturing. I have written a getting started guide for KiCad in Myanmar language to take note about my experience and methods. And I combined them with English version guide which can be found on its website [Getting Started in KiCad, March 5, 2017]. My Myanmar version getting started guide for KiCad book can be found at

Tuesday, June 6, 2017

Flash content protection for LPC824

In this article, I would like to discuss about evaluation of LPC824 low cost 32-bit ARM Cortex-M0 microcontroller using OM13071 LPCXpresso824-MAX Development board. LPC824M201JHI33 is used in the board. Its size is only 5 x 5 x 0.85 mm in HVQFN package.

In order to evaluate it, MCUXpresso Integrated Development Environment (IDE) is downloaded and installed. Other tools for it can be found at this link . After launching MCUXpresso and assigning a workspace folder, example projects can be imported by clicking Quick Start Panel (near bottom left corner) -> Import projects from file system ... -> Browse LPC open resources as shown in the following figure.

Wednesday, May 31, 2017

Programming serial port in C++ with wxWidgets for Windows and Linux

I have developed a class library 'Serial.h' to use serial port (com port) on both Windows and Linux. This cross-platform 'Serial' class is written in C++. A simple example for C++ console program using the class is demonstrated. As an another example, using it with wxWidgets for GUI application is also presented. The source code can be found at

Figure. A wxWidgets GUI application using 'Serial' class with Visual Studio 2017