Overclocking any Raspberry Pi model it’s really simple. But overclocking? Raspberry Pi Pico is even simpler. All it takes is two lines of MicroPython and your Pico can easily run at twice its normal speed without needing it. best cpu coolers
Here’s how we overclock the Raspberry Pi Pico to 270MHz, doubling the base speed of 133MHz. Then we’ll write a script to test how far we can overclock and then how low we can underclock the CPU.
You might be thinking “Why overclock a Raspberry Pi Pico?” Using a low-level language like C, the Pico can be used to play games like Doom (the full game) using an HDMI output board. It can emulate retro computers like ZX Spectrum and Commodore 64. Overclocking with MicroPython will give us a noticeable speedup, and the lower idle can give us longer battery life if we use it in a battery-powered project.
Here’s how to work with a Raspberry Pi Pico, Pico W and many others Best RP2040 based boards When using MicroPython. There are other methods to change the frequency when programming boards in other languages.
For this project you will need:
Raspberry Pi Pico or Pico W or any other RP2040 based board running MicroPython.
Overclocking Raspberry Pi Pico with MicroPython
1. Install the latest version of MicroPython on your Pico. If you haven’t already, follow it step three of this guide learn how
2. Import the machine module in the REPL and: check the current speed of the Raspberry Pi Pico. The returned value will probably be 125000000 Hertz (125 MHz). Some boards or versions of MicroPython may have it set slightly higher by default.
import machine
machine.freq()
3. Using the same command, set the processor speed to 270 MHz.
machine.freq(270000000)
4. Check the processor speed to make sure the overclock worked. The returned value should be 270000000 Hertz (270 MHz).
machine.freq()
This speed increase is temporary at this time. When the Pico is restarted, it will revert to its default speed (typically 125MHz). To maintain the overclock, it must be adjusted every time the Pico boots. Adding these two lines to the beginning of any MicroPython code will bring the RP2040 to the desired speed when the code is run.
import machine
machine.freq(SPEED IN HERTZ)
How far can the RP2040 be pushed?
Overclockers are always looking to go a little faster, but how do we determine our luck in the silicon lottery? To do this, we’ve automated the process with a little Python code.
1. In Tony start a new file from by first importing two modules. Machine is used to change the speed of the processor and time is used to speed up the code.
import machine
import time
2. Create a variable, frequency and store 270 MHz as Hertz. We know that 270 MHz works well, so we start with a known operating speed. If your goal is to lower the RP2040, lower the value accordingly.
freq = 270000000
3. Create an object, speed, and store the current speed of the RP2040 there. Using a little math, the value returned in Hertz is converted to megahertz, then rounded to one decimal place, before finally being converted to a string.
speed = str(round(machine.freq()/1000000,1))
4. Print the current CPU speed as part of the message. We had to convert the velocity to a string to put it in the message.
print("The starting speed is",speed,"MHz")
5. Print a message to the user informing them that the test will start in five seconds, then wait five seconds.
print("Starting the test in five seconds")
time.sleep(5)
6. Create a loop to run the code continuously. We can use a for loop, but sometimes the True loop will crash when it hits a bad frequency, so we gain nothing from the for loop.
while True:
7. Set the processor speed using the frequency variable.
machine.freq(freq)
8. Create an object, speed, and store the current speed of the RP2040 there. Using a little math, the returned value is converted in Hertz to MegaHertz, then rounded to one decimal place, before finally being converted to a string.
speed = str(round(machine.freq()/1000000,1))
9. Print the current CPU speed as part of the message. We had to convert the velocity to a string to put it in the message.
print("The starting speed is",speed,"MHz")
10. Increase the speed by 10 MHz and store the value in frequency. The += operator translates to freq = freq + 10000000. It’s shorter and neater in code. Both work equally well and can be interchanged for simplicity. += can be replaced with -= to make the values count backwards to find the lowest CPU speed.
freq += 10000000
11. Pause the code for two seconds. This will give us time to read the values before the loop iterates.
time.sleep(2)
12. Save the code on the Raspberry Pi Pico as speedtest.py and click Run. Our best speed was 280MHz, but you might get lucky.
We also tested underclocking (decreasing the speed by 10 MHz per cycle) and managed to get it down to 10 MHz, which should significantly reduce power consumption for projects that require long battery life. We were unable to collect any data due to the level of precision equipment required.
Full list of codes
import machine
import time
freq = 270000000
speed = str(round(machine.freq()/1000000,1))
print("The starting speed is",speed,"MHz")
print("Starting the test in five seconds")
time.sleep(5)
while True:
machine.freq(freq)
speed = str(round(machine.freq()/1000000,1))
print("The current speed is",speed,"MHz")
freq += 10000000
time.sleep(2)