Coding

Ever since I advanced beyond the “hello worlds” of Java, I had never stopped coding. This section is for documenting code usages that I had employed while solving the technological problems that I had encountered.

How to post JSON data to a HTTP server endpoint from your ESP32 development board with ArduinoJson

When sending data from your ESP32 development board, you may choose to send the data in JSON.

In such a situation, you can consider using ArduinoJson to help you construct the JSON data.

Given that, let us look at how we can post JSON data to a HTTP server endpoint from a ESP32 development board with ArduinoJson.

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 control a servo motor with an ESP32 development board

When I try to reuse the Ardunio Sketch to control a servo motor with a ESP8266, I encountered the following error during compile time:

WARNING: library Servo claims to run on (avr, sam, samd, nrf52, stm32f4) architecture(s) and may be incompatible with your current board which runs on (esp32) architecture(s).
In file included from /Users/i309663/Documents/learning/Arduino-sketches/sketch_arduino_servo/sketch_arduino_servo.ino:1:0:
/Users/i309663/Arduino.1.8.7/Arduino.app/Contents/Java/libraries/Servo/src/Servo.h:73:2: error: #error “This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor.”
#error “This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor.”
^
exit status 1
Error compiling for board ESP32 Dev Module.

Therefore, I had to find another way to control my SG90 servo motor with an ESP32 development board.

Given that, this post shows how to control a servo motor with an ESP32 development board.

ESP32 devkit-c v4 connected to sg90 servo motor

How to use an ESP32 development board to read from a VCNL4010 Proximity/Light sensor

If you have a Proximity/Light sensor, you will be able to detect how close an object is. When your range of detection is within 200mm, you can use the VCNL4010 Proximity/Light sensor.

Given that characteristic, you can use the VCNL4010 Proximity/Light sensor as a contactless switch to trigger some action.

For example, you can use it in a soap dispenser that will dispense some soap when a palm is near the nozzle.

In case you need it, this is how to use an ESP32 development board to read from a VCNL4010 Proximity/Light sensor.

VCNL4010 Proximity/Light sensor

How to use an ESP32 development board to read RFID tags from a SparkFun RFID USB Reader

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

Although the SparkFun RFID USB Reader comes with a USB port, you can also read RFID tags with an ESP32 development board.

In case you need it, this is how to use an ESP32 development board to read RFID tags from a SparkFun RFID USB Reader.

SparkFun RFID USB Reader

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 add a React component that rotates recommended items on your website

As I had mentioned in how to monetise a programmer’s website effectively, affiliate marketing can be an effective way for your website to earn money.

Since affiliate marketing programs revolves around links, we can build a catalogue of items that we wish to recommend to visitors to our websites.

If you have already built that catalogue of product recommendations and an API endpoint, you can build a sticky component in your sidebar and rotates recommended items from there.

Since I have been hearing good feedback about React, I implemented such a feature on my website with React.

In case you are looking to do the same, this is how you can add a React component that rotates recommended items on your website.

How to create a Carousel in WordPress with Slide Anything

When you have been adding content to your website for some time, you may notice two things:

  1. There are many pages that are never visited in months or even years.
  2. The home page will always have page views.

Given these points, the home page is one place where you have the chance to promote pages that are rarely seen organically.

If your website is realised by polyglot stack, then you will find the Slide Anything plugin useful for creating a Carousel for your WordPress instance.

Given that, this post shows how you can create a Carousel in WordPress with Slide Anything.

Sample Slide Anything WordPress Carousel on Techcoil home page

CSS styles for styling image alignment in your WordPress pages and posts

When you create your own WordPress theme, one of the things of provide for is the ability to style image alignments.

By default, the WordPress Editor will include one of the predefined CSS classes when we add images to a post or page.

Therefore, by providing the CSS styles for each of these classes, we will be able to style the image alignment of our WordPress pages and posts.

Given these points, let us look at the CSS styles for styling image alignment in our WordPress pages and posts.