MohammadReza Sharifi
Published © MIT

Upgrading an old laptop Coolpad using RPi Pico and Python

In this tutorial, we upgrade an old laptop Coolpad and display the laptop's hardware parameters using Python and LabVIEW.

IntermediateFull instructions provided1 hour330
Upgrading an old laptop Coolpad using RPi Pico and Python

Things used in this project

Story

Read more

Schematics

circuit diagram in fritzing

Code

Coolpad Controller based on Raspberry Pi Pico

MicroPython
this script controls Coolpad fans and neopixel RGB ring
from machine import UART
from machine import Pin as pin
from time import sleep
import machine, neopixel

#####
#thanks to microsoft copilot for guiding me to write these functions to control RGB LED ring using neopixel library
# Pin number, number of LEDs, and bpp
PIN_NUM = 15
NUM_LEDS = 16
BPP = 4

# Create a neopixel object
np = neopixel.NeoPixel(machine.Pin(PIN_NUM), NUM_LEDS, bpp=BPP)

# Define the rainbow colors
RED = (255, 0, 0, 128)
ORANGE = (255, 128, 0, 128)
YELLOW = (255, 255, 0, 128)
GREEN = (0, 255, 0, 128)
BLUE = (0, 0, 255, 128)
INDIGO = (75, 0, 130, 128)
VIOLET = (148, 0, 211, 128)

# Store the colors in a list
COLORS = [RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET]

# Loop through the colors and display them on the LEDs
def rainbow():
    for color in COLORS:
            # Set the color of each pixel
        for i in range(NUM_LEDS):
            np[i] = color
            # Write the data to the LEDs
        np.write()
           
        time.sleep(0.5)


def disable_rainbow():
    for color in COLORS:
            # Set the color of each pixel
        for i in range(NUM_LEDS):
            np[i] = (0, 0, 0, 0)
            # Write the data to the LEDs
        np.write()

#####
ut = UART(0,9600)

command = b'S'

#Define Driver pins
in1 = pin(16,pin.OUT)
in3 = pin(17,pin.OUT)


#########
ENA = pin(18,pin.OUT)
ENB = pin(19,pin.OUT)

ENA.value(1)
ENB.value(1)
#########

def enable_fan():
    in1.value(1)
    in3.value(1)


def disable_fan():
    in1.value(0)
    in3.value(0)


disable_fan()

while True:
  
    if ut.any():
        command = ut.readline()
        #print(command)     
        
        if command == b's':
            disable_fan()
            
        elif command == b'o':
            enable_fan()
            rainbow()
            
        elif command == b'f':
            disable_fan()
            disable_rainbow()
                       
        else:
            pass

show hardware info

Python
this python script shows hardware info
import psutil
import GPUtil as gu

def show_gpu_temp():   
        
    gpu = gu.getGPUs()[0]
    return gpu.temperature


def show_cpu_freq():

    current_freq, _, _ = psutil.cpu_freq()
    return current_freq

def show_cpu_perecent():
    
    cpu_perecent = psutil.cpu_percent()
    return cpu_perecent

def cpu_core_count():
    cpu_cores = psutil.cpu_count()
    return cpu_cores

def show_memory_info():
    total_memory, available_memory, percent, used_memory, free_memory = psutil.virtual_memory()
    return percent

Full source code on my github page

Credits

MohammadReza Sharifi

MohammadReza Sharifi

10 projects • 4 followers
I'm an Electrical Engineer and Maker.

Comments