Smartphone and you – How to improve your sleep quality

In the world of technology, we often tend to think that our life is made simpler and our capability to do things more efficiently has been made possible. However, like our inherent human tendency, we abuse the power we have been given and completely ignore the possibilities of side effects.

Does technology have any side effects?  Well, there are many which you might not be aware of but through this post, I will try to answer this fundamental question and hopefully help make your life a little better.

To begin with, answer the following questions to evaluate where you stand now:

  1. Do you find yourself sleep deprived irrespective of the number of hours you have slept for? or are you waking up each morning wondering why you aren’t feeling fresh?
  2. Do you experience headaches frequently? Do these headaches last for hours together?

If your answer to both were yes, then this article will give you more information on why that might be happening and suggest slight adjustments that you can make in your routine and try to mitigate the side effects.

If your answer was no for the questions above, then you are doing something right and this article will tell you what that is.

The Normalcy

Before we go about the issues,  I would like to dive into the science of what happens normally in a human body and how it happens.I will try to keep these explanations as simple as possible.

1. Circadian Rhythm a.k.a The Biological Clock

The Circadian Rhythm is a cyclic process in your body responsible for controlling various internal processes like maintaining your sleep cycle, blood pressure, secreting hormones at the right time, regulating bowel movements, and many many more things. This happens every day.


(Example of Circadian Rhythm) Source: Wikipedia

Though this cycle has a set of tasks to perform at a given point in time, it is very flexible and can be influenced by the person’s surrounding environment. This is a good thing because it adapts to the natural changes like seasonal changes, light, and temperature without affecting you. However, this also means that leading an unhealthy lifestyle can heavily influence this cycle and throw it off balance causing many issues to you.

2. Eyesight

The reason why we have the ability of sight is relatively unknown. To understand this, we would have to first understand what light is.  To put it in simple terms, light is a wave of energetic particles. In this wave,  only a small portion is visible to the human eye and this visible portion is responsible for our visual perception.

visble-light(The visible spectrum of light) Source: Visible Light

in the diagram above, the left-hand side depicts lower energy particles and rightmost side indicates higher energy particles. The ultraviolet light comprises of high energetic particles that are bad for humans. Fortunately for us, most of it is filtered out when the light from the sun travels through the earth’s atmosphere.

When the rest of the visible light passes through your eye, many different things happen. Firstly, as the objects around you reflect the light, your brain forms the image of your surrounding by processing in this information. Depending on the energy of the reflected light that falls in your eyes, it will identify and differentiate the various colors and you will be able to see.

However, the energy of the light particles that falls through your eyes is used by the brain to determine a few other things. For example, in the visible range, the blue light corresponds to higher energy particles, and when this light falls through your eyes, your brain interprets that it’s morning time and starts to trigger various chemical processes in your body.

3. The Sleep Cycle

Your biological clock responds to external stimuli to trigger the sleep process. The most influential external stimulus is light. When sunlight fades and it starts to get dark, the amount of light going through your eyes reduces drastically and the body starts to generate a sleep hormone called Melatonin. When this hormone is released in large quantities in the blood ( usually in the night), you tend to relax and start feeling sleepy.

When you wake up the next morning, the sunlight pours in through your eyes and the body gets the signal that it’s daytime. It has now been observed that the “blue light” which is a part of the sunlight is heavily responsible for suppressing melatonin. With the receding levels of this hormone in your body, you feel fresh and ready to start your day. This process happens day after day for your whole life.

Melatonin can also be absorbed by the body from certain types of vegetables and fruits like tomatoes, walnuts, olives, rice, etc and you may start to feel relaxed. When the time comes for the body to secrete this hormone, it generates the right amount required for a good sleep.

Udemy Generic 300x250

The Smartphone

In this section, I will try to simplify how the smartphone display works. Though this process is similar to almost all the digital devices, I want to focus more on smartphones as they are the most used device by people these days and are also the cause for the current technology-driven lifestyle.

Most of the smartphones today have LED screens. This screen is made up of a set of LED light bulbs and a few layers above it. These layers are made of various materials to filter light as it reaches to the top where the user can see.


(Cross section of LED screen) Source: Sound&Vision

As these smartphones are often used outside, the sunlight tends to glare your screen and you wouldn’t be able to see anything on it. To overcome that, the phone screens come with a few things:

  1. Anti-glare screens – These screens disperse the light that falls on it, thereby reducing the glaring effect.
  2. High Energy light –  The Blue Light, which we have seen earlier are high energy particles in the visible range are used. This makes the screen appear much brighter so that you can easily see it when you are outside. The high energy of the blue light particle makes it the perfect choice to beat the sunlight and make the phone display stand out even in bright places.

The result of this is the bright, crisp high definition screen that makes anything on it look amazing any time of the day. This is truly an engineering marvel.

Piecing Things Together

Now that we know how our body works normally and how a smartphone display would work, we can piece these two together to understand the side effects of using a smartphone throughout the day.

1. The Day Time

During the daytime, there is not much of a difference in terms of the light from the screen affecting you on a short term basis. Mainly because the light emitted by the smartphone has similar traits when compared to sunlight.  However, since we are constantly looking at screens for a prolonged period of time during the day, the high energy particles cause flickering in the eyes leading to eye strains. This, in turn, causes loss of clarity, headache, mental fatigue, to name a few.

2. The Night Time

The most destructive effect of smartphone screens happens at night. Consider this normal behavior of an average person living in a town/ city.

He or she returns home in the evening after staring at computer monitors/ mobile phones for a prolonged amount of time. At this point of time, the body senses that it’s dark due to the absence of sunlight and starts to produce melatonin in the body. The person starts to feel relaxed and once the chores are done, the person picks up the smartphone to check WhatsApp, to watch an episode of a series on YouTube and checks mail. At this point of time, the person does not realize what’s happening inside the body.

Inside the body of that person, melatonin, the sleep hormone is being secreted, but as the bright blue light from the smartphone enters the eyes, the brain gets a signal and it starts interpreting that it’s day time. And since the biological clock is influenced by your surrounding, it starts to suppress the melatonin and instead of becoming more and more relaxed, you start to become more and more alert. Suddenly you find yourself thinking, that you aren’t feeling sleepy anymore and you continue to use your mobile for some more time. It’s a vicious cycle.

So, What are the Side Effects?

As you might have guessed by now, this habit of yours is suppressing the amount of melatonin required for a good sleep.  This answers the first question that we had asked, why do we find ourselves sleep deprived irrespective of the number of hours we have slept for? and why we aren’t fresh when we wake up. When you do not get a good sleep, that triggers another set of problems like headaches throughout the day, feeling lethargic and having mental and physical fatigue and in some cases, this habit leads to insomnia.

Another side effect that arises from staring at the bright blue light in a dark place is eye strain. The Bright light which has high energy can strain your eyes causing headaches and loss of clear vision.

Different Ways to Prevent It

The side effects can be prevented to a great extent and following some of these prevention techniques can help you feel better within a day. Now, the most obvious thing to do would be to reduce the usage of the smartphone. If you can do this, then hats off to you. However, most of us might find this to be a very challenging task. So, for people like you and me, here are a few simple things you can try out for various screen types:

  1. Use the screen in low brightness from evening onwards.
  2. For your desktop/ laptop screen, there is a  software called Flux. This software works by making your screen slightly orange depending on the time of the day. orange light falls in the low energy particle side of the visible spectrum, thereby reducing damage to your eyes.
  3. Most Important Step: Practicing this step can quickly show you the results and so it’s important that you do this every single day. DO NOT use smartphones or any digital device 1.5 to 2 hours before you sleep.   Make sure you finish checking your emails, WhatsApp and other important things at least 1.5 hours before you sleep. Set your alarms and leave the phone aside. You can use the time you have till you fall asleep to go for a walk, talk to your family members or best, spend time reading a good book.

I hope that this has given you a  bit more understanding of the aspects of smartphones and human processes and I hope that this information helps you.   

P.S: share your views on the effects of smartphones, how it has helped you or how it hasn’t in the comments below. If you find this article informative, share it with others so that they can benefit from this as well.  

Source Dexter is becoming better and I need your help!

Dear reader,

Thank you for being a part of my journey. Over the years, this blog has tried to become a destination for useful resources in the technological space.I have put my heart and soul into some of the things I have shared here and I have always wanted to make this big.

Among the tens of thousands of readers that this blog has witnessed, I know for a fact that many have found the information present here to be very useful. It makes me feel good that I had a part to play in helping a few people in their respective journeys. I do not exactly know how many are constantly following this blog, but if you are one among them, I thank you for your support. I wouldn’t have a good blog without you.

To share with you a brief history of this blog, I would have to go back a couple of years when I had felt that I could share the things that I come across with other people with a hope to help them in some way. As time went by, the readership grew and so did the type of blog posts. I primarily blogged about a few niche technologies like python, Raspberry Pi, and Ubuntu. This blog has helped me in various ways which I hadn’t realized before. One example for this is the way in which I was able to leverage these content to get freelance writing projects. However, the times when I was not fascinated by a few technologies or when I got caught up with work, I wouldn’t blog and months of dry spells would follow. I sometimes felt that the drive to keep this alive was missing.

Writing and science have been two of my passions but this blog focused more on technology which as you know is a by-product of science. I want to change this now and start giving more importance to science as well. You might have subscribed to this blog for the type of technical content I have been writing so far and so it is important that you know what is coming up next from my side. I have decided to publish science-based articles that dwell deep into the intertwining of science with technology in a bid to simplify some of the complex concepts or bring out some of the research work that can benefit common people like you and me.

To begin with,  I will publish articles only when I am satisfied with it and not on a regular basis just to maintain a cyclical publishing habit. As time goes, I might shift to a fixed pattern. I would, however, need your support in terms of sharing the content and helping more people understand and gain more knowledge. I don’t want to consider this as a new year’s resolution but as a new attempt in pursuing my passion and giving this blog a part of my identity.

Happy holidays!! I hope to see you soon.


P.S: please do share your opinions and suggestions through the comments. It helps me as a blogger to understand what you feel and also improve myself. So, go ahead, let me know 🙂

Raspberry Pi Tutorials : how to assign static IP and change hostname

Making a Raspberry Pi cluster requires an initial setup to be performed. Here I assume that the OS that is running is Raspbian. So once the cluster is built generally one Raspberry pi designated as the  master node controls the functionality of all the other nodes. So this post deals with how the master node connects to or other nodes ,how you can use the master node to login to any other node in the cluster, how to assign static IP address and how to differentiate each of the nodes from the other by assigning different hostnames.

Assigning static IP address :

The first thing that has to be done is assign static IP address to each PI . This helps to connect to other PIs(nodes) via SSH (Secure Shell) . So first use the command :


This lists all the IP addresses. My result of running the command ifconfig was :

inet addr: bcast addr: mask:

Make a note of these addresses. So, from the above result, the inet address indicates the IP address of the node. What we do now is assign addresses to each node. The first step in it is to decide a range of IPs . I had 5 nodes and so I decided to take the range to . Once the range is fixed login to one of the PIs.
Also, make a note of the gateway address by typing the following command

sudo route -nee

Gateway: 192.168.3. 1

The final step is to modify the interface file :

sudo nano /etc/network/interfaces

Remove the line that reads

iface eth0 inet dhcp

Add the following:

iface eth0 inet static
address #change according to your range

save by pressing CTRL+X and then type Y to save and exit. then reboot the PI using :

sudo reboot

Type the following command to ping your gateway address or router and will return :

ping  -c3

The response should look somewhat like this :

64 bytes from icmp_req=1 ttl=255 time=2.18
64 bytes from icmp_req=2 ttl=255 time=2.43
64 bytes from icmp_req=3 ttl=255 time=3.24


Learn  how to make your Bench Automation Raspberry Pi computer now!!!

One last thing that needs to be modified is the /etc/resolv.conf file. This file contains information of DNS name resolvers that allow your raspberry pi to resolve names to IP addresses. For example, if you ping, the raspberry pi will have to determine the IP address of my python tutorials website,

Enter the following command to edit the resolv.conf file:

sudo nano /etc/resolv.conf

Enter the follow Google public DNServer IP address:


Press CTRL-X to exit but remember to save the file by accepting the changes.

Now type ifconfig and the new IP will be the one you would have assigned.Repeat this for all the other nodes on the cluster individually.


Change the hostname manually

If SSH is not installed then the hostname can be changed manually by logging into each of the raspberry pi individually and changing the hostname file as :

sudo nano /etc/hostname

By default the content of the file is :


change it to what you want. for example, if the new hostname should be client003 , then delete the existing name and type the new name :
press CTRL+X followed by Y to save and exit. So from the next time you login the new hostname will be seen.




Build your own steganography tool with python

Steganography is the process of hiding text or files like images, documents etc  within another  file like an image, audio, some other text, etc. This technique was used by many groups of people to hide and send a secret message so that only The person to whom it would be delivered could know what it contains. To extract the message from the hidden files many different tools can be used.

Here is an example of steganography. Person A hides his personal details within a message using a steganography tool. Only he knows that an image has some text hidden within it. Anyone else who gets that image can only see the image but will not even have a clue that it contains some data. Now person A can get back his data using the same steganographic tool in reverse order.

Steganography is different from encryption. In the sense that, in encryption, no data is hidden but only converted or transformed into some other form of data depending on the algorithm used. But here we actually hide the data. Its up to the user whether he wants to encrypt it or not before he hides it.

I have built a simple tool , you can either use that to improve it or use the idea to build something better. So read further to learn more.

I wanted to try out steganography  just like I do other projects in my free time. so I started with a project to create a steganography tool that would hide messages within a data. This tool is completely built in python
Here I call the data to be hidden as “message” and the data in which the message is hidden “base data”. So the base data that I chose is the lorem ipsum text.

Lorem Ipsum is generally used in the typeset industry to check  the layout and font look. It is also used to randomly fill, in templates with data. So these sentences though widely used do not have any meaning.The reason I chose lorem ipsum as my base data is if configured right I would be able to send messages within template like format so no one would suspect that it would contain hidden messages. For a layman, it’s just some lorem ipsum data put up to see how a website looks when it gets real data.

So finally my project when finished, it could accept a data ,generate lorem ipsum sentences and hide data within it. It would also generate a key which would help the user to extract the message from the base data. This key is different for each message and also I encrypted the key. This tool also provides the option to store the key in the same file that contains the base data or the user can make a note of the key and send it to the recipient by some other means. Thus without that key, the data cannot be extracted.

the source code can be found on  github :

Here is an example where I hide the message “may the force be with you” 😛 within the base data.

Workspace 1_004

As you can see, it generates a key that you have to decide whether to manually store it somewhere or store it in the file with the base data.
below is the screenshot to show the base data in which the message is hidden.

Screenshot from 2014-02-22 11:46:23

So within that paragraph lies hidden the message.I also created a

I also created a visualization to demonstrate how the data will be stored. Here I have used 2 colors alternatively to differentiate between words. So, if the letters of the  first word are showed in green then the letters of the second word will be in blue and so on it will alternate.

Screenshot from 2014-02-22 11:44:43

What is Access Control Allow Origin and how to use CORS in Java Spring

When a javascript client tries to  consume data from another application or some resource on a server through a REST API, the server responds with a  Access-Control-Allow-Origin  response header to tell the client that the content of this page is accessible to certain origins. The origins can be any  client that sends a request to the server to fetch some resource. The clients that are allowed to access can also be specified. But by default, clients are not allowed to fetch the resource from the server.

This Access-Control-Allow-Origin  is a Cross Origin Resource Sharing (CORS) and the CORS filter must be implemented to send a response from the server while building RESTful Web Services.  The way this works is, when a client makes a request for a resource, it sends the Origin header in the request. The server validates this origin and decides to allow the request or not. If it decides  to allow, then it responds  with the Access-Control-Allow-Origin in the header and then upon receiving this, the browser  matches the origin and allows the request. If the browser finds that the origin matches, it allows the request to be completed, else it throws an error.

Here is an example of a GET request made to a REST service and the corresponding response given by the server. Here, the Origin matches the one mentioned by the server.


GET /test/test.json  HTTP/1.1/
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) Gecko/
Firefox/3.5.5 (.NET CLR 3.5.30729)
Accept: application/json


HTTP/1.1 200 OK
Content-Type: Application/json;character-set=UTF-8
Date: Sun,  30 Aug 2015

Thus, the request is allowed in the above case. If your server should allow requests from all origins, then you can set:
Access-Control-Allow-Origin: “*”

Here the “*” indicates all origins to be allowed to complete their request.

If you are building a REST service in spring, you can create a simple or complex CORS filter. This filter will then help your server respond to request accordingly. Following is a simple program given by the Official Spring Documentation, which allows all origins to access a resource from your server.

package hello;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;

public class SimpleCORSFilter implements Filter {

	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletResponse response = (HttpServletResponse) res;
		response.setHeader("Access-Control-Allow-Origin", "*");
		response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
		response.setHeader("Access-Control-Max-Age", "3600");
		response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
		chain.doFilter(req, res);

	public void init(FilterConfig filterConfig) {}

	public void destroy() {}

This Program allows any kind of origin to  send  GET, POST, OPTIONS and DELETE requests  and serves them accordingly. The Access-Control-Max-Age field makes sure that the access control is alive for 1 hour or 3600 seconds.

Without setting the CORS filter, any client , be it a web front end built using AngularJS or a simple JavaScript client will not be able to fetch the data. and you might get an error thrown by he browser.

Source: Spring Documentation 1, Spring Documentation 2, StackOverFlow

6 Common Errors When Building a Raspberry Pi Cluster

Though the Internet is a vast resource for getting a Pi cluster up and running, there is no full set of errors that you can refer to when you’re stuck. Many times it happens that the same error on two different clusters can have two totally different meanings, making it even more difficult to solve problems. The issues that come with building these clusters are increasingly relevant as their popularity increases in all parts of the world.

Raspberry Pi clusters are affordable and can be clustered to make a super computer or cloud computing clusters. It can be use for many cool application like desk automation.Raspberry Pi: Make a Bench automation computer
Bobo Cloud, for example, is an open-source cloud service for students built on Raspberry Pis.

As thse clusters become more common, there will be an increasing need for documentation and other resources. This post intends to be a reource for troubleshooting problems. It describes five common types of errors that beginners in this field of Raspberry Pi may encounter and their possible solutions.

Power Issues


  • First boot password change is not allowed or password change on first boot hangs the Pi each time.
  • Any time the Raspberry  Pi is fired up, only two of its ports work. For example, only the two USB ports might work and the HDMI port connecting to a terminal and the ethernet port don’t. Or, the  HDMI and one USB work, disabling the rest of the ports on the device.
  • Midway into operating, the Raspberry Pi restarts and continues to restart repeatedly at irregular intervals.
  • All ports work fine but the Pi stops responding to key presses.

Problem and solution:

These problems are caused by lack of power to the Pi. Raspberry Pi is designed to run on low power but when the power supply  goes much lower than required, it works but does not perform at its full capacity.

An ideal power supply for Raspberry Pi model B is 5v, 2A . Though most of the mobile adapters are used to power the Pi, most of the times it has much lesser power rating which leads to the above problems.

Also, if the adapter is built to send the power through a micro USB cord, low-quality adapters cause loss during power transmission so that the full 5V is not delivered.

You might be able to use a workaround for some of the above errors, like for detecting the key presses of a keyboard by changing configuration of the speed of USB transfers, but doing so merely delays the onset of the other errors. Instead, get a good quality adapter to fix these errors.

Overlapping MPI Problems


  • mpiexec crash
  • ssh error: error passing parameters

Problem and solution:

These errors occur generally due to the overlapping of multiple MPI distributions. The most commonly used and ideal distributions are OpenMPI and MPICH. Linux generally uses MPICH.

When you install packages directly to the system with one of the MPI distributions, overlapping occurs leading to the corruption of mpiexec and behavior of mpicc. For example, direct installation of Python packages to run with MPI or multiple installations of the same MPI distribution (shared and unshared) leads to the  clashing. This happens because direct installation sometimes doesn’t check the full compatibility. It just checks for the dependencies and if that check is passed, the packages get downloaded and installed. Unknowingly these packages might install the MPI distribution, even if you’ve already installed an MPI distribution. It might also change the system path for MPI. This can corrupt the entire MPI installation.

The solution is to build each package manually. Installation guides specific to each
MPI distribution are typically available.  If not or if a manual build is not possible, make sure you have a restore point created before the installation so that any corruption can be backtracked

Hostname Issues


  • hostname not resolved
  • $pi@(none):

Problem and solution:

This error was one of the most confusing to me. Why? Because a node wouldn’t know its hostname and it would give this error but would perform the task given to it 60 percent of the time. This occurs only if the hostname is changed from its default to something the user would want so that he/she can differentiate between the nodes.

The “hostname not resolved” error can be cleared by changing the hostnames in two places:

  • sudo nano /etc/hostname
  • sudo nano /etc/hosts

Run the above commands, each of  which opens a file. In that file, change the default

hostname to the hostname that is required.

Finally The  pi@(none) or (none) hostname errors occur when the hostname given has
the ‘-’ (hyphen symbol)  or any other symbol. The solution is to edit both the files mentioned above and replace the illegal symbol for the hostname with an
‘_’   (underscore symbol).        

Below are two images of  file /etc/hosts before and after changing  hostname from
“akshay” to “akshay_001.”




The same has to be done for the other file. Save and reboot for the changes to be applied successfully.

HDMI Port Problems


  • insufficient ports for connecting a display terminal
  • choosing the right display

Problem and solution:

More than any error this is a difficulty which many beginners might face. It happens
when you don’t have an HDMI port on a terminal/monitor or  when you want to connect a different display to the Raspberry Pi.

The solution lies in the availability of materials. The many options for connecting
the display are:

  • Use a display with an HDMI port.
  • Use an HDMI to VGA converter and connect it to the display.
  • Use an Ethernet cable to connect to a laptop’s display (this is recommended if you don’t need the Ethernet port for a LAN connection).
  • Use any computer or laptop’s display wirelessly using SSH. When SSH has been configured on both laptop and the Raspberry Pis, then it can be connected remotely, which means none of the ports on the device will be required.

Repeat Login Problems


  • Connection to another node through SSH fails.
  • Login credentials required for each remote login to other nodes.
  • Error: RSA key not safe.
  • Warning: unprotected private key file.

Problem and solution:

The main aim for using SSH is what many computer experts call “secure gateway without login.” What this means is that you have to provide the login credential only for the first time you log in to the other node.  If you are asked to input credentials each time  you log into a node, it means something is wrong. In fact, it’s a disaster if the cluster has around 64 nodes and login is needed for each of them. This error generally occurs when the file containing the private key is copied to another location or its access permission has been tampered with. Another possible reason is that the hostname is not correctly configured, in which case SSH is not sure whether that node exists in its network or not. This leads the SSH to believe that the default setting no longer  exists and concludes that the network is not safe and secure. Hence, these errors.

I fixed these errors by changing the access permissions to only read and execute by the owner and no permissions to the group or  to others. If the hostnames are not configured properly, use the solution given for Hostname Issues above.

Shared Libraries Problem:


  •  Build failed : mpicc not found.
  • –enable-shared option not recognized.

Problem and solution:

We had experienced these errors because of two reasons. Firstly, we had already  built mpich2 without shared libraries. And then tried to build a shared version parallel to it. Now , theoretically, it shouldn’t be a problem and many papers published with regard to this suggest that it is possible to build  mpich2  with shared libraries parallel to  the version without shared libraries.  But turns out that, with the newer versions of mpich it doesn’t work.

For some users only the –enable-shared option might not be recognized. This is because the build script is not able to locate the path of mpicc or some other dependencies.

The solution is to build only the mpich with shared library.  And its advisable to build it in the /usr/local directory of the Raspbian OS. So this removes any ambiguity  in PATH information and leads to a successful build. It is important to know that having shared library is only important when there is a need for a dynamic library(.so) and not a static library(.a) . So if there any need to load libraries at runtime, mpich should be configured with shared libraries.