How to Get M5Stack Battery Status with UIFlow 1.3.2 MicroPython

By | Coding Laboratory, Python Code

Recently I’ve got my hands on the M5Stack Core device. This device, not only brought possibilities of awesome ideas, but also bring me close to the world of MicroPython. For those who are unaware, MicroPython is software implementation of Programming language largely compatible with Python 3. In short, MicroPython is Python Compiler which can run on Microcontroller.

In this post, we will use MicroPython’s “machine” library for accessing i2c bus of the M5Stack Core. The battery circuit of M5Stack core is composed of IC IP5306, which provides i2c interface at 0x75 address with Battery Percentage of 0%, 25%, 50%, 75% and 100%.

To get started, UIFlow 1.3.2 firmware need to be flashed to the M5Stack Core device.

Flashing UIFlow 1.3.2 and connecting the M5Stack device in USB Mode

You can watch video till (2 Minutes 5 Sec) for Flashing and connecting the M5Stack device in USB Mode.

Running Program

While device is connected with your Computer/Laptop in USB Mode, run UI Flow Desktop IDE. It will prompt for Connecting the IDE with device. Set the correct com port and you should be good to go for running the program. Select Python Mode and use the following code to access i2c bus and get the device’s battery status

Run the code and voila! you can now get battery statistics on the screen.

Create a Database Connected WebApp (Part I)

By | Django

In this post we will install MySQL connector for Python for getting started with Database connected Application on Django.

On MAC OS X, following additional steps need to be done for installing the Database connector, others can skip directly to Installing MySQL connector for Python.

First we need to install mysql-client on the system, so that the MySQL driver can be installed properly using pip. To do so, install homebrew if not installed. Once homebrew is installed, install mysql-client binary by using following command

brew install mysql-client

It will install mysql-client on your system. To make mysql-client available over terminal, add the following to your .zshrc or .bashrc file.

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export PATH="/usr/local/opt/mysql-client/bin:$PATH"

Also add the following environment variable in your .zshrc or .bashrc file for SSL binary which get installed with mysql-client binary

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

Now restart your terminal, and you will be good to go.

Installing MySQL Connector for Python

Install MySQL Connector by passing following command to the terminal.

pip install mysqlclient

In second part, we will use mysqlclient package to connect our Application with the database.

Turn your First Project to Hello World!

By | Django

As we seen in last post, the application shows default Django page and not the “Hello World!” string. Isn’t it sad?

In this post we will see how to create a “Hello World!” page inside Django application.

Step1: Create View

Create a new file named inside HelloWorld directory and use this code :


Step2: Set the URL Pattern

Open the file and use this code :


Final Step: Run the server

python runserver 

 To terminate/stop the server, press CTRL+c key