Pomodoro Timer with Esp8266 ,micropython and slack – a small weekend project

No Comments

 

Hi All,

Pomodoro technique is really effective, more than the technique it’s more or less like a good stress buster to me.

https://en.wikipedia.org/wiki/Pomodoro_Technique

There are few problems with the timer management

1.  It’s impractical for me to manually add 25-minute timer every time

2. I can do a small script but again my computer should always be on

3. Use some app or use a timer with sound (both of them are really disturbing for myself and also colleagues around me)

What did I use

  1. With anything involving DIY/IoT, there are two important aspects – It should be small and portable and secondly, cost should below.

Components Used :

  1. ESP8266
  2. 0.96Inch 128×64 OLED display (Pictures below)
  3. Micropython ( I could have gone with C++ but honestly I don’t know the language, hence I had to go through a lot of pain to make it work in microphone)
  4. Slack for daytime notifications about timer stages

Challenges :

  1. How do I make sure I don’t look at the clock every 25 minutes? Sound is not an option, so I used a slack webhook to notify me
  2. Code was big and hence there were memory allocation issues in micro-controller, used mpy_cross to compile code and transport to micropython (http://docs.micropython.org/en/latest/index.html)
  3. Overall project cost – Less than 3.5 USD

code used :

https://github.com/yukthr/auts/tree/master/pomodoro_esp8266

 

For every 25 Mins, it would indicate a 5-minute non-compulsive break and after 2.5 Hours a compulsive break of 15 minutes. It’s understandable that in our nature of work we might be in a call or meeting or a code review, but just a small a non-compulsive reminder that we have a 5m break for hydration or fresh air does really improve thought process and most importantly is a de-stressor.

 

 

-Rakesh

Python Decorators – From a Network Engineers Perspective

No Comments

As going through learning some basic programming, I encountered Decorators. I should be very honest if any of you are trying to figure out or learn what decorators in python do from my blog post you are dangerously in trouble.

So what this post about if not learning, well its mostly on what the functionality is so that you can learn the concept from better programming resources.

 

Let’s examine the below code

 

The output will be something like below

 

What’s in this code:

The first thing you have to realize is that some representation with ‘@’ symbol. If you have noticed get_reinfo and get_modelinfo functions, they have one thing in common which is to connect to the device and get output before they parse the required fields, that what a Decorator is helping us to do here, we extend that wrapping functionality around new functions without having to write everything or globalize everything.

At least that is what I understood.  So, next time when you are writing some code try to think if you can incorporate decorators into them.

-Rakesh

 

My Ignorance for a Year and Dell IDRAC

No Comments

Hi,

I have a Dell R810 and it makes a lot of noise. So, I have put it somewhere remote in the home where it’s completely inhabitable for human beings. Now, the problem was always to go there and manually power-up the system.  This has been the scenario for years. So, technically if am away from my home I need to take help from my wife. All this is going well and I was always wondered should it not have a better way to do things.

Was talking to my friend and he had some paid solution for the same thing, he doesn’t even remember and that’s for his cisco gear, now for Cisco gear as long you supply power they will be powered (if the Power button is always on), for servers however just like our Personal CPU’s and Laptops you have to manually press the power button.

Then yesterday all of a sudden I took this somewhat seriously and explored options, then I understood it was sitting right inside the server, Dell has something called Integrated DRAC system which helps you do this thing, all you need to have is a proper Lan connection, the message was always there during the boot but it was ignorance in servers which made me shoo away with the boot messages. The below image is slightly dull as I have said the place where this sit’s is not great with light.

 

https://www.dell.com/support/contents/ie/en/iebsdt1/article/product-support/self-support-knowledgebase/enterprise-resource-center/systemsmanagement/idrac

After quick setup of IDRAC, I was looking for this to work over a script and below is the script

Git – https://github.com/yukthr/auts/blob/master/random_programs/server_idrac.py

And it looks something like this

 

All of this may look serious programming for someone who is not into this yet, this is really easy and most of it is nothing to do with programming, few lines from here and there and StackOverflow will do ;), again I can write this with my programming knowledge imagine what you can do with this.

 

-Rakesh

 

 

 

 

 

 

Multithreading – Whats in it ?

1 Comment

Hi,

I never took threading seriously, partly because I was barely getting started with programming let alone running and improving a Programs performance. I have all the time in the universe to wait for the program to run instead of making it run much faster 😉

Problem statement: Has 3 sites to ping, make 3 parallel pings (like opening 3 terminal and issuing a parallel ping statement) instead of one by one approach and has to be done with python

Threading Module comes to Rescue

https://github.com/yukthr/auts/blob/master/random_programs/threading_program.py

 

Basically, in the below output if you see two blocks, one block gets executed sequentially one ping after the other while the other one includes threading and everything is taken parallel and hence we see the output differences as well. I think am yet to figure on calculating time aspect of the threading but it is definitely faster.

Again not going much into GIL or (IO / CPU threading differences), all I can say is we can use this to enhance some day to day activities.

 

 

This may sound a little strange, macosx was not giving me any results for threading while any Linux / Unix (raspberry pi in this case) was good enough for testing the threading.

 

-Rakesh

Listing TOP 5 Processes – Top command

No Comments

Continuing some exploration of Pandas, I realized in networking we often has to deal with Toptalkers, I dont have any Networking Realted Top Talker IP Data as such but wanted to see if this can checked on my Laptop’s current Processes comsuming CPU and Top processes which are repeated often.

Without dragging the topic

-> Took the text file it was delimited with space (TOP Command will generally Delimit)

-> Converted to Pandas Read FWF and then converted the file to CSV

-> Used CSV to read into specific %CPU coloumn and implemented SORT function in descending order.

-> Finally Took Counter from Collections Module and implemented it on the list.

output looksl something like this

Pandas are effective and easy, I will continue to explore some functions so as to build some scripts in day to day activities.

 

-Rakesh

 

Python Pandas – Reading text files got a lot better.

No Comments

Problem Statement – Have a list of VMWare Instances and wanted to quickly iterate and see what VMs are powered on, this has nothing to do with Vmware or ESXI, look at the below image, programmatically I want to pick two specific rows and perform dictionary operations on them.

Git – https://github.com/yukthr/auts/blob/master/random_programs/pandas_vmware_esxi.py

for someone like me who is partly into programming and mostly into networking, anything effective is easy, I could have gone with the other way of doing this but  since Pandas are effective i would text parsing with them.

 

I only want two sections which are of interest to me, in a normal way maybe I should have pasted this in excel and Do a text to the column and do a manual data extraction, but wanted to do it with Pandas and they are powerful.

First things first

  • Read with Pandas
  • Read the text
  • If possible convert into CSV (as I have some experience with csv file operations)
  • Then split the Columns and make the dictionary for further use

 

 

Let’s see how this proceeds

Pandas make it so powerful to just pick Columns out of the fly, in this case, I wanted them from [1] and [6], with some code I could write up a sample script which helps in getting the power state. The next operations would be to read the os.system output and parse it but we all know how that can be done in general python use cases.

Final program looks something like this

 

-Rakesh

 

 

Close Bitnami banner
Bitnami