Skip to main content

Posts

Showing posts from 2018

Developing Micro Web Pages for ESP8266

ESP8266 is a WiFi module that can be programmed to serve web pages. The capability is similar to a typical WiFi router serving its own administrative web pages. We can hack a WiFi router with OpenWRT or we can just program ESP8266. The server-side example codes can be found at the micro-api  framework repo. Here we are going to prepare for the client-side development. ESP8266 is a general purpose WiFi module where the web pages can be more than just administrative. However, due to the limited resources of ESP8266 the processes should be mostly pushed to the client side. See  libesphttpd and Micro API . Localhost Our web server will be based on libesphttpd . It comes with a tiny read-only file system (espfs) and a utility to pack the entire web file structure into a single blob file which is to be flashed into ESP8266. The web server will serve the files just like any other web server. We need to set up a localhost web server and start developing for the client side. We ca

libesphttpd and Micro API

libesphttpd is a HTTP server library for ESP8266. It has a fair documentation on Github and a demo . It supports common gateway interface (CGI) in C. It also has a tool to compile a collection of web pages into a binary blob which is to be flashed into ESP8266 separately from the web server codes. It can host static web files. In general, libesphttpd can be used to build a complete web server for ESP8266. However, ESP8266 is too tiny for a full blown web server. It is a standard practice to separate the development of web pages and a web server. In fact, due to the limited resources of the ESP8266, the web server should be kept to minimum by only exposing APIs. The web pages should be designed as the applications that run at the client side. I wrote a micro-api framework using libesphttpd and esp-open-sdk . Separation of concerns is important in web application development since it involves multiple stacks of tools. On the server side there will be embedded C-based tools. And

Position of the Sun

I was working on the Prayer Times when I stumbled upon the notion of the position of the Sun  in Wikipedia. I was converting the Javascript codes into C and made a major restructuring of the codes so that I know what was the main contributor. It was the position of the Sun. All Muslim prayer times are related to solar events such as sunrise, noon and sunset. The details of the calculation of the position of the Sun are involved. The true relationship between the Earth and the Sun is never constant. The method that is given by Wikipedia is just an approximation which is good enough for few decades to come. Hopefully by that time we already have a better approximation. The events of sunrise to sunset are due to the Earth rotation on its polar axis. Never expect the Sun's circling the Earth to be in the perfect 24 hour rotation. The noon is never at the same time every day. This is due to the motion of the Earth orbiting the Sun. The orbit is not a perfect circle and the speed of

Git My Way

Update : This blog was written about two years before Github dropping the so-called divisive "master" terminology , and renamed it to "main". But I'm not going to change anything here. I just want to keep the original context as is. Please read master as main . After all this while I still could not remember how to do git right, and I kept on coming back to this blog, each and every time I wanted to update a Github repo. If you are careless then you may encounter "fatal: Couldn't find remote ref master", and Google will lead you into a pit of old and unrelated discussions. I used to bookmark a number of git tutorials. Most of it works but only to a certain extend until I forgot most of the required steps later. The steps were not intuitive and can easily be forgotten. Git uses alien English. Then I realize that I have to list my own way of using git. I believe all of you have too because we depend on it. I use git with Github and mostly to upda

Connecting to a Micro Web Server

ESP8266 can be programmed to serve a micro web server which can be accessed through WiFi. However, connecting to the module involves multiple steps. Connecting to a WiFi Access Point (AP) is like physically plugging-in a cable of a Local Area Network (LAN) into its switch. Yet it does not immediately connect our device to a web server. A connection to an AP may not necessarily get our device into an Internet Protocol (IP) network where a web server is hosted because a WiFi AP does not necessarily implement IP. Similarly, a LAN switch may not necessarily implement IP. At the very low level of networking the devices may identify each other through Media Access Control (MAC) addresses. A mesh networking implements a communication layer below IP. It is up to the devices to implement their own networking protocol. However, IP happens to be pervasive in WiFi networking. ESP8266 does implement IP and a Dynamic Host Configuration Protocol (DHCP) server which assign our device with a dynami

ESP8266, D1 and the esp-open-sdk

ESP8266 started with terrible documentation. Yet for a cheap-and-tiny WiFi module, people hacked around it, added code to it, and manipulated its extra I/O pins to make it do more than it was originally designed for which is a WiFi module to be controlled by an external processor via a serial interface with AT commands in an embedded system. Why extend it to external microcontrollers or microprocessors when it has its own powerful 32-bit processor and plenty of flash memories? ESP8266 has many uses and people created many quick-to-used boards for it such as D1 . No, we don't have to limit ourselves to a particular board. People also created various SDKs for the module and flooded the Internet with incompatible documentations. This is a bitter-sweet situation. Now, we have to assemble our own tool's stack. Espressif Systems, the founder of ESP8266, has a catalog of documentation . They are now proactive to the world community. This is a collection of programming notes ar

Free SSL Certificate on GoDaddy Shared Hosting with DNS Verification

This is an update from my earlier post on the same subject for more than a year ago. The SSL certification is the same but the process has changed. Getting free SSL certificates from Let's Encrypt is a multi steps process. Sites like SSL for Free and ZeroSSL  make it simpler. However, they want to verify that you have the control over the domain where the free SSL certificate is for. They want you to create TXT records in the DNS server that hosts your domain. They will give the details of the TXT records for you to enter. Then they will query the DNS server for the TXT records. If the records are the same then you are verified to have the control over the domain, and they will create the certificate for you. They just create the certificate. You have to install it in your hosting server. I was getting the free SSL certificate for my https://cryptobubbles.club from Let's Encrypt. In fact I wanted to have HTTPS for https://answering.cryptobubbles.club because I want

Money in Secret Messages

You want to write a message to a friend. But you don't want to leave any trail leading to her. It is important that your message does not include her address. You have to leave your message at a secret place so that she can pick it up later. I have created a secret messaging place  Blindtalk.net . As a software developer I cannot run away from cryptocurrency. I studied Bitcoin's whitepaper and its source code. Being so serious about it I managed to extract Bitcoin's message verification code into a standalone library. While many people are focusing too much on the blockchain I'm focusing on the signing algorithm. Cryptocurrency leads me to Blindtalk. But I'm not using Bitcoin or the signing algorithm. Instead, I'm using the Waves platform. I've created Blindtalk token based on Waves, which is the easiest part. Blindtalk is a repository where the senders post messages and the receivers search for them. But it is not a regular posting. A sender has