Tag archive for: Python 3

Rendering multiple checkboxes with WTForms and Bootstrap

When you use WTForms and Bootstrap, you can quickly build up the dashboard for your own content management system with Python.

This is because WTForms provide several out-of-the-box implementations for rendering some basic fields that for capturing form data.

However, rendering multiple checkboxes can be open to different UI implementations based on users’ preferences. Therefore, different fields and widgets are available in WTForms to cater for different ways of displaying a form input to the user.

Given these points, let’s see how we can render multiple checkboxes with WTForms and Bootstrap.

How to use your Raspberry Pi for Python development

Since its inception, the Raspberry Pi had progressed by leaps and bounds. Indeed, one of the reasons why we want to get a Raspberry Pi is its versatility. Apart from the huge selection of hardware, there are many Python libraries for you to build Raspberry Pi applications.

If you want to build something out of a Raspberry Pi, then you will benefit from setting up one for Python development.

Even if you do not build Raspberry Pi projects for a living, setting up a Raspberry Pi Python developer machine can be useful. For example, you may be a Solutions Engineer who build proof of concepts for demo purposes. In this case, you can build your demos with Python and run them on your Raspberry Pi.

If you are thinking of using Raspberry Pi for Python development, then this post is a reference for you.

How to use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint

If you want to direct someone to a web page without saying a word, then you can use QR codes to do so.

For example, your QR code reader will direct your phone’s browser to visit our home page when you scan the following QR Code:

Techcoil home page QRCode

Given that, you can use QR codes to send HTTP requests to an endpoint of your HTTP server. In addition, you can embed data that you wish to send to the endpoint in the QR codes.

With this in mind, let’s look at how we can use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint.

How to use threading.Condition to wait for several Flask-APScheduler one-off jobs to complete execution in your Python 3 application

Previously, I discussed how to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request.

When we run jobs as discussed in that post, jobs are ran once by the underlying ApScheduler instance. In addition, our Flask endpoint return the HTTP response back to the HTTP client as soon as the jobs are scheduled.

If we do not want the HTTP client to know the outcome of the jobs within that HTTP call, then we are good. But what if we want to include any errors that the jobs encounter in the same HTTP response?

In such a situation, we will need a mechanism to wait for the one-off jobs to complete execution before returning that response.

Given that in mind, this post shows how we can use threading.Condition to wait for several Flask-APScheduler one-off jobs to complete execution.

How to create an interval task that runs periodically within your Python 3 Flask application with Flask-APScheduler

Previously, I talked about how to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request.

If you wish to run long running tasks triggered by an HTTP request, then that post will help you do so.

However, what if you want to run jobs periodically without blocking your Flask HTTP server from serving HTTP requests?

In this case, you will want to run an interval task with Flask-APScheduler.

Given that, let’s look at how we can use Flask-APScheduler to create an interval task within your Python 3 Flask application.

How to read RFID tags from SparkFun RFID USB Reader with Python 3

When you have an RFID starter kit from Sparkfun, you will be able to read RFID tags through serial.

Previously, we saw how to use an ESP32 board to read RFID tags from a SparkFun RFID USB Reader.

Given that, I was able to build a ESP32 prototype to scan tag ids from RFID cards.

In order for that ESP32 prototype to recognise what each of my tag card represents, I need to label the ids. Whenever my ESP32 prototype gets a tag id, it will query a tag catalogue to see what that tag id represent.

Since it is easier to label the tag cards from a computer, I built a Python 3 application to read the RFID tags from the SparkFun RFID reader.

So how we can read RFID tags from SparkFun RFID USB Reader with Python 3?

If you are looking for a way to read RFID tags from SparkFun RFID USB Reader with Python 3, then this post is for you.

How to use Python 3 to convert your images to Base64 encoding

When you encode your images in Base64, your images can be transferred and saved as text.

Although there will be a 37% bloat in space requirements, it can be useful to encode images in Base64.

For example with SAP HANA XS Advanced, you can quickly build an OData service to receive images via JSON.

Given that, let’s see how we can encode an image in Base64 encoding with Python 3.

How to read soil moisture level with Raspberry Pi and a YL-69/FC-28 moisture sensor

When I did a Raspberry Pi 4 Model B review, I got myself a Raspberry Pi 4 Model B. Therefore, the current Raspberry Pi 3 Model B+ that I have been using for validating Raspberry Pi ideas became available for another IoT project in the house.

So what should I do with my Raspberry Pi?

Since I have always wanted to build my own indoor herb garden, I plan to use it to help my plants grow well.

When I bought the LED Grow Lights, I am able to give my plants consistent lighting. Given that consistent lighting is solved, I can use my Raspberry Pi 3 to monitor soil moisture so that I can provide water my plants better.

Given these points, this is a proof of concept that I did to read soil moisture level with my Raspberry Pi and a YL-69/FC-28 moisture sensor.