Skip to main content

Desktop COVID19 Tracker with clock! Raspberry Pi Powered Tracker|



 I had to do something to consistently inform everyone about the latest cases of COVID19.
We know that we can die anytime, even I can die while writing this post, after all, I me, you, we all are mortals. The whole world shook because of COVID19 pandemic. We know how to prevent this, but hey! we know how to pray and why to pray, do we do it daily? No!! Actually, we forget the root cause of why we should do things. So, we know that an hygienic lifestyle can save us yet we don't do it properly. Consider the case of my younger brother, he wants to go out and play even in this time. I had to do something to consistently inform everyone about the latest cases of COVID19. So, I made a digial desk display that shows the latest cases of COVID19 in real time. As this has a clock then I can put it in a place where everyone gathers or comes. They'll see the numbers add up, which will trigger awareness in them and hopefully everyone will be conscious.
Also as I am a maker and hobbyist, this turned out to be a good project to work on in this lock-down session.

1. Parts I have used:

 

 

  1.  Raspberry Pi 3 Model B (booted using sd card)
  2.  Raspberry Pi UPS module (optional)
  3.  7 inch HDMI LCD Screen
  4.  HDMI to HDMI cable (this comes with the screen)
  5.  USB cables
  6.  5v 2A power adapter (to power the pi)
  7.  PVC sheet [wooden color] (to make the body)

2. Setup raspberry pi:

I guess you have set the pi up perfectly, unless you haven't -

  1. get an SD card - more than 8 GB
  2. download latest raspbian iso file from here.
  3. Burn the SD card using etcher 

(Note that people can say a about other software which requires you to do some setup thingy but etcher is super easy to use and simple but effective too.)
Just plug your SD card to pc, run etcher, you'll see the SD card is automatically selected by etcher, then click to select the downloaded iso file or image, then burn it. After successful writing and processing unplug SD card and connect it to your pi, power it and VOILA!! It's alive.

3. Circuit Diagram:


Connect everythingup and power up the raspbery pi,
You'll see the pi booting.






4. The Body:


 

 
 

I cut a PVC sheet to according to the display size, then added it using screws. After that I wired everything up. At last added another sheet at back to support it from falling (blue sheet). If everything is okay, you should see the pi booting (last picture).

5. The Software (Source Code):

If all set up perfectly, you'll need to install some libraries.

The program is written in python3. For GUI (Graphical User Interface) I used PyQt5, and to extract realtime COVID19 data I used COVID19Py library. Thanks to the guys who made the API available for us [[Kudos COVID19Py team]]. See doc in pypi.
That's pretty much it, now open up Terminal on raspberry pi and install libraries (copy each one of them and paste on rpi terminal).

Ignore $ sign while copying
$ pip3 install pyqt5
$ pip3 install requests
$ pip3 install covid19py
That's it, now download the code from here, I've provided the code below:
"""* Realtime Covid19 International and Local Tracker With Clock *"""

"""
************** Stay Home Stay Safe. Live, let Live *************
"""

"""
author: ashraf minhaj
mail: ashraf_minhaj@yahoo.com
site: ashrafminhajfb.blogspot.com
"""

#import necessary libraries
import PyQt5                        #QT GUI Library for python3
from PyQt5.QtCore import Qt, QTimer #timer to update
from PyQt5.QtWidgets import *       #import everything
from PyQt5.QtGui import QFont       #for fonts
import sys                    #necessary for QT applications
#import os
import COVID19Py  #covid19 information -api
import datetime   #you know what this is for


class CoronaTracker(QWidget):
    """main class that contains everything"""
    
    def __init__(self):
        """initialize things"""
        super().__init__()
        
        self.covid = COVID19Py.COVID19()  #initialize
        self.timer = QTimer() #initialize
        
        self.timer.timeout.connect(self.update) #if timer reaches threshold - call update
        
        self.ui()  #user interface


    def ui(self):
        """User Interface section"""
        self.setWindowTitle("Covid19 International and Local Tracker")
        #self.setWindowFlags(Qt.CustomizeWindowHint) #hide title bar
        self.setStyleSheet("Background-color: black")
        self.setFixedSize(640, 480)  #as per my display (x, y) /rpi resolution

        #main label
        self.banner_label = QLabel(self)
        self.banner_label.setGeometry(50, 5, 560, 50)  #(x_origin, y_origin, till_x, till_y)
        self.banner_label.setText("CORONA Pandemic - COVID19 TRACKER")
        self.banner_label.setFont(QFont('SansSerif', 20))
        self.banner_label.setStyleSheet("""
                           background-color: black; 
                           color: white;
                           border-style: outset; 
                           border-width: 1px
                           """)

        """________________________worlds latest data_______________________________________"""
        
        #world label
        self.w = QLabel(self)
        self.w.setGeometry(200, 55, 400, 40)
        self.w.setText("World at a Glance")
        self.w.setFont(QFont('SansSerif', 18))
        self.w.setStyleSheet("""
                           background-color: black; 
                           color: blue; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #worldwide confirmed cases
        self.w_cases = QLabel(self)
        self.w_cases.setGeometry(5, 90, 100, 40)
        self.w_cases.setText("Cases:")
        self.w_cases.setFont(QFont('SansSerif', 18))
        self.w_cases.setStyleSheet("""
                           background-color: black; 
                           color: orange; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #cases number
        self.w_cases_num = QLabel(self)
        self.w_cases_num.setGeometry(110, 90, 100, 40)
        self.w_cases_num.setFont(QFont('SansSerif', 18))
        self.w_cases_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #worldwide deaths 
        self.w_death = QLabel(self)
        self.w_death.setGeometry(350, 90, 100, 40)
        self.w_death.setText("Deaths:")
        self.w_death.setFont(QFont('SansSerif', 18))
        self.w_death.setStyleSheet("""
                           background-color: black; 
                           color: red; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        #death number
        self.w_death_num = QLabel(self)
        self.w_death_num.setGeometry(460, 90, 100, 40)
        self.w_death_num.setFont(QFont('SansSerif', 18))
        self.w_death_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #worldwide cured
        self.w_cured = QLabel(self)
        self.w_cured.setGeometry(5, 140, 100, 40)
        self.w_cured.setText("Cured:")
        self.w_cured.setFont(QFont('SansSerif', 18))
        self.w_cured.setStyleSheet("""
                           background-color: black; 
                           color: cyan; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #worldwide cured number
        self.w_cured_num = QLabel(self)
        self.w_cured_num.setGeometry(110, 140, 100, 40)
        self.w_cured_num.setFont(QFont('SansSerif', 18))
        self.w_cured_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)


        """_______________________Local-By country Code________________________________"""
        
        #local - Country 
        self.c = QLabel(self)
        self.c.setGeometry(170, 200, 400, 40)
        self.c.setText("My Country: Bangladesh")
        self.c.setFont(QFont('SansSerif', 18))
        self.c.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #local confirm cases
        self.c_cases = QLabel(self)
        self.c_cases.setGeometry(5, 240, 400, 40)
        self.c_cases.setText("Cases:")
        self.c_cases.setFont(QFont('SansSerif', 18))
        self.c_cases.setStyleSheet("""
                           background-color: black; 
                           color: orange; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #local cases number
        self.c_cases_num = QLabel(self)
        self.c_cases_num.setGeometry(110, 240, 100, 40)
        self.c_cases_num.setFont(QFont('SansSerif', 18))
        self.c_cases_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #local deaths
        self.c_death = QLabel(self)
        self.c_death.setGeometry(350, 240, 100, 40)
        self.c_death.setText("Deaths:")
        self.c_death.setFont(QFont('SansSerif', 18))
        self.c_death.setStyleSheet("""
                           background-color: black; 
                           color: red; 
                           border-style: outset; 
                           border-width: 1px
                           """)

        #local deaths number
        self.c_death_num = QLabel(self)
        self.c_death_num.setGeometry(460, 240, 100, 40)
        self.c_death_num.setFont(QFont('SansSerif', 18))
        self.c_death_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)
   
        
        #local cured
        self.c_cured = QLabel(self)
        self.c_cured.setGeometry(5, 280, 100, 40)
        self.c_cured.setText("Cured:")
        self.c_cured.setFont(QFont('SansSerif', 18))
        self.c_cured.setStyleSheet("""
                           background-color: black; 
                           color: cyan; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #local cured number
        self.c_cured_num = QLabel(self)
        self.c_cured_num.setGeometry(110, 280, 100, 40)
        self.c_cured_num.setFont(QFont('SansSerif', 18))
        self.c_cured_num.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)



        """_______________________Time, Date, Clock________________________________"""
        #clock
        self.clock = QLabel(self)
        self.clock.setGeometry(115, 340, 400, 70)
        self.clock.setFont(QFont('SansSerif', 60))
        self.clock.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #label for weekday
        self.weekday = QLabel(self)
        self.weekday.setGeometry(5, 360, 110, 20)
        self.weekday.setFont(QFont('SansSerif', 13))
        self.weekday.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)
        
        #date label
        self.date = QLabel(self)
        self.date.setGeometry(510, 360, 110, 20)
        #self.clock.setText("22:49:00")
        self.date.setFont(QFont('SansSerif', 13))
        self.date.setStyleSheet("""
                           background-color: black; 
                           color: white; 
                           border-style: outset; 
                           border-width: 1px
                           """)


        
        #check the timer
        if not self.timer.isActive():
            #if timer is stopped (reached threshold)
            #After 1 second (approx.) or 1000ms

            try:
                """try to get data, else run the code anyway"""
                self.latest = self.covid.getLatest() #gte covid19 latest data

                #get latest data by country code 'BD'-Bangladesh, 'IN'-India etc
                self.local = self.covid.getLocationByCountryCode('BD', timelines=False)
                #print(self.local)
                #print(self.latest)

            except:
                """couldn't get data"""
                print("Internet Error!!")

                pass #ignore, run anyway

            self.timer.start(1000) #start the timer
        
        self.show() #show our User Interface


    def update(self):
        """update labels with information"""

        """_________________Extract ad Update Time and Date Information________________"""
        #set up clock and date time (update values)
        #get and update values
        #to know more read python datetime documentation

        self.dt = datetime.datetime.now() #get datetime data
        self.clock.setText(self.dt.strftime('%X'))
        self.weekday.setText(self.dt.strftime('%A'))
        self.date.setText(self.dt.strftime('%x'))
        
        
        """__________________________update covid19 data______________________________"""
        
        #worldwide latest data
        self.w_cases_num.setText(str(self.latest['confirmed']))
        self.w_death_num.setText(str(self.latest['deaths']))
        self.w_cured_num.setText(str(self.latest['recovered']))
        
        #local latest data
        self.c_cured_num.setText(str(self.local[0]['latest']['recovered']))
        self.c_death_num.setText(str(self.local[0]['latest']['deaths']))
        self.c_cases_num.setText(str(self.local[0]['latest']['confirmed']))

        print("updating")

        return



  
def main():
    app = QApplication(sys.argv)  
    win = CoronaTracker()  #instantiate
    sys.exit(app.exec())
   
#run the application 
if __name__ == '__main__':
    main()

6. Finish Up:


After testing the code I put it in desk and dedicated a power source for it. So that it can work while charging. By using the ups this can run even in load-shedding also, this gives ur pi SD card a suitable protection too.

No matter how or who we are, we have to die. Let's not think about yourself, think about the world. We can only live forever through our deeds, let it be that way.






Comments

  1. Question do you use raspbian lite iso or raspbian desktop ? thank you

    ReplyDelete
  2. No, I have used Rasbian-Stretch.

    ReplyDelete

Post a Comment

Popular posts from this blog

Make a Smart Phone Controlled Robotic Arm ! Arduino DIY.

Making ROBOT ARMs is very popular and fun among hobbyists, but it's not that easy to control a ROBOT ARM. So today we'll be making a robot arm that can be controlled using just your Android Smartphone or tablet. Good news is, you just need to program the Arduino, the App is already available to download for free. Step 1: Parts You'll Need 2 More Images Servo motor 4x (I'm using micro servo Sg90 but any model or size is okay) you can use upto 5 servo for this robot arm, I've only 4, so I'm using them. sliced piece of Card Board - to make the body. USB OTG (on the go) [pic3 & 4- all the same] And of course a Arduino board (any board) And a few jumpers to make the connection And a 9v battery to power the servo motors. Step 2: Making the Robot Arm (THE BODY) Now in here I'm actua

Make a Smart Humanoid Talking Robot- MOFIZA.

This Robot - Mofiza - (weird name) Can SEE , TALK and REACT to her surroundings. Before I proceed watch the video: Ever since I've seen making talking robots I saw that people actually use other development boards rather than Arduino to make talking robots. But it's completely possible to make a Humanoid robot with Arduino who can talk and add a lot of servos to make it move. So lets begin: Step 1: Parts You'll Need Arduino Pro mini (5v 16 Mhz) [any board is good but i've used this to make it small) Female header pins for connecting on pcb Male header pins Vero Board to make the circuit Sd card TF module (to make it talk) micro sd card (not more than 2GB) 3x IR proximity sensor 3x servo motor (I've used micro servo sg90) Cardboard to make the body Step 2: Connecting IR Sensor and the Body Make a

Make AI Assistant Robot with Arduino and Python

Introduction: We all are familiar with ‘Jarvis’ AI assistant robot from “Iron Man’ movies and Marvel series. It has always been a dream of programmers to make something on their own. I will today show a simple way to make such an assistant using Python programming. Moreover, I will also make a physical avatar of that robot, so that whenever we talk to the robot, it can do some movements. That will be more amazing than just a software robot. Because if it has a body, it is cool. So today we will learn to use both Arduino and Python programming to make an AI robot which can control your computer and have a little chit chat with you. Let’s hop in guys! Why I named the robot ‘Jaundice’? Because I painted it yellow, very very yellow!   Parts: Electronics - Arduino Nano – 1x Micro Servo Sg90 – 3x Ultra Sonic Sensor HCsr04 – 1x Body – PVC sheet (preferably white, better for coloring, I used blue one) Servo wheel (for the stand) Tools -  Cutter knife Scissor Hot glu

Arduino Automated Parking Garage

An Arduino Automated Car Parking System that is too easy and too fun to make. When a car arrives it shows the number of empty slots (if available) and then opens the gate. if there is not any empty slot then the gate does not open.  Amazing thing is that the whole project can just be POWERED using a POWER BANK!! Watch the video for the full tutorial. Note: you can use display instead of my hand made led sign display. Now lets get started. Step 1: Parts Arduino  - any board Infrared proximmity sensor  (pic 2 & 3 - both are functional) 330r resistor some  LED 's Servo motor  - any model or size you wish. Step 2: Making the LED Display To make this  LED display  I have used a piece of bredboard then soldered the LED's and the 330r resistor. Then just added a ribbon cable f

Problems using PIR sensor?? Always HIGH? DELAY? Solution is here.

PIR sensor When I was working on a project "controlling home appliances using just a wave of hand" I had used a PIR sensor and found some issues: PIR doesn't work properly when starts. PIR output value is always 1. It some times doesn't read motions. Now those are three Common and Unavoidable problems of a PIR sensor. So what would we do? I assume you know what a PIR sensor is and I'll just try to give a solution to the problems so that you can use PIR in your project efficiently, also I've added a code below on how to solve that problem. As I have mentioned earlier those are Common and Unavoidable,  keep 3 issues in mind: After powering - PIR sensor needs 1 minute to function For that 1 minute the OUTPUT is always HIGH. When a motion is detected it'll take 5 to 7 seconds to detect motion again. SOLUTION: After powering - PIR sensor needs 1 minute to function:  which means when you'll power a PIR sensor it wi

Control Anything Over Internet / WiFi. IOT Light Switch_ NodeMCU ESP8266 .

Parts: NodeMCU ESP8266  WiFi Development Board LED 330r resistor Android app Download the app from Below , To Upload code to NodeMCU using Arduino.ide Update Arduino.ide (desktop app) start Arduino app goto  Files > Preferences  Then  paste the link  then press  ok.    http://arduino.esp8266.com/stable/package_esp8266com_index.json goto  Tools>Boards> Board Manager  then wait untill it finds ESP8266 properties Scroll down and  click install Then Restart the Arduino App. Now you can upload Code in C / C++ to NodeMCU ESP8266 using Arduino.ide Getting IP Address Code T o get the IP Address (Internet Protocol Address) Upload this Code and open serial monitor. #include <ESP8266WiFi.h> const char* ssid="WIFI name"; const char* password = "WIFI PASSWORD"; int ledPin = 13; void setup() { pinMode(ledPin,OUTPUT); digitalWrite(ledPin,LOW); Serial.begin(115200); Serial.println(); Serial.print("Wifi co

How to use ServoTimer2 Library with Arduino- full tutorial.

Introduction I've been trying to make a humanoid robot  MOFIZA -Arduino Talking Humanoid Robot.  recently- which means dealing with Servo motors. Everything worked just as fine just before I tried to make the robot TALK. When I needed to use the TMRpcm library. But there's some libraries like #TMRpcm .h #VirtualWire .h are libraries that use the Timer1 of Arduino. It appears that you can't use two devices simultaneously where both use the same timer...So, if my robot talks- the servos don't work. Because The Servo.h and the TMRpcm both works on Arduino TImer1. Which is a mess. If you want to make both of them work you have to use another library for servos. Which is ServoTimer2 library? This uses the Timer2 on Arduino...Unfortunately on internet I haven't found any tutorials to understand how this ServoTimer2 library actually works, and how to use it in code. So, I've decided to make a tutorial so that people like me can understand better. We'll be u