Turn off RF module on Raspberry Pi Pico W using CircuitPython

Thread Starter

tyro01

Joined May 20, 2021
87
Hi,
I'm using CircuitPython at Raspberry Pi Pico W.
I want to turn off the RF module before it enters Deep Sleep mode, I wrote the code as follows:
Python:
rfen = digitalio.DigitalInOut(board.GP23)
rfen.direction = digitalio.Direction.OUTPUT
As a result, the following error occurred:
AttributeError: 'module' object has no attribute 'GP23'

GPIO23 is an intarnal I/O port for SMPS control, I don't think this pin is defined as a GPIO pin.
All of the code I searched the internet for was assuming MicroPython and was not helpful.
Please show me the correct way to code.
Thanks,
 

Ya’akov

Joined Jan 27, 2019
8,974
I don't know CircuitPython but your explanation is confusing:

GPIO23 is an intarnal I/O port for SMPS control, I don't think this pin is defined as a GPIO pin.
If GPIO23 serves a different purpose, why are you trying to instantiate an object with it?
Why do you use GP23 as attribute?
 

k1ng 1337

Joined Sep 11, 2020
911
Hi,
I'm using CircuitPython at Raspberry Pi Pico W.
I want to turn off the RF module before it enters Deep Sleep mode, I wrote the code as follows:
Python:
rfen = digitalio.DigitalInOut(board.GP23)
rfen.direction = digitalio.Direction.OUTPUT
As a result, the following error occurred:
AttributeError: 'module' object has no attribute 'GP23'

GPIO23 is an intarnal I/O port for SMPS control, I don't think this pin is defined as a GPIO pin.
All of the code I searched the internet for was assuming MicroPython and was not helpful.
Please show me the correct way to code.
Thanks,
Why do you want to turn off the radio in this manner? Post your code and I'll take a look at it. In your above code, you are trying to set the variable to a port that doesn't exist.

Also, why do you think GPIO23 is for SMPS control? From what I can tell, that pin is either unused or handled internally. You can enable the internal SMPS by brining the 3.3V EN pin high or low. Turning off the SMPS also means turning off the microcontroller affecting the sleep commands so I'm wondering why you want to mess with the SMPS.
 

Thread Starter

tyro01

Joined May 20, 2021
87
GPIO23 on the Raspberry Pi Pico W controls the power supply for the on-board wireless module.
pict.png
It appears to reduce standby power during Deep Sleep. According to this blog, In MicroPython, the following code reduces the standby power of Pico W from 10mA to 2mA.
Code:
machine.Pin(23, machine.Pin.OUT).low()
machine.deepsleep(5000)
 

k1ng 1337

Joined Sep 11, 2020
911
GPIO23 on the Raspberry Pi Pico W controls the power supply for the on-board wireless module.
View attachment 305723
It appears to reduce standby power during Deep Sleep. According to this blog, In MicroPython, the following code reduces the standby power of Pico W from 10mA to 2mA.
Code:
machine.Pin(23, machine.Pin.OUT).low()
machine.deepsleep(5000)
I have the base model of the Pico without the wireless radio. The RP2040 datasheet shows GPIO23 as user definable so it makes sense to see the new model using that pin to control the radio but this is separate from the the SMPS.

Bring GPIO23 high and low without defining it like in your first post. I suspect that pin is already routed assuming the radio is working normally for your other code. You might also be trying a feature that is supported by MicroPython only.
 
Last edited:

Thread Starter

tyro01

Joined May 20, 2021
87
Thanks, CircuitPython is useful for prototyping new ideas, but it still seems difficult to reduce current consumption, interrupts, and other precise controls. I will try Blinka, which says the CircuitPython library works with MicroPython.
 

k1ng 1337

Joined Sep 11, 2020
911
Thanks, CircuitPython is useful for prototyping new ideas, but it still seems difficult to reduce current consumption, interrupts, and other precise controls. I will try Blinka, which says the CircuitPython library works with MicroPython.
I've been able to edit all my code to run on CircuitPython from MicroPython examples but it is a pain. Do you know how to read the available inputs and outputs on the IO bus? Use this example to see if GPIO23 appears in the list. Try commands to get more information about GPIO23.

CircuitPython Pins and Modules | CircuitPython Essentials | Adafruit Learning System
 

Thread Starter

tyro01

Joined May 20, 2021
87
dir(board) result:
Code:
['__class__', '__name__', 'A0', 'A1', 'A2', 'A3', 'GP0', 'GP1', 'GP10', 'GP11', 'GP12', 'GP13', 'GP14', 'GP15', 'GP16', 'GP17', 'GP18', 'GP19', 'GP2', 'GP20', 'GP21', 'GP22', 'GP26', 'GP26_A0', 'GP27', 'GP27_A1', 'GP28', 'GP28_A2', 'GP3', 'GP4', 'GP5', 'GP6', 'GP7', 'GP8', 'GP9', 'LED', 'SMPS_MODE', 'STEMMA_I2C', 'VBUS_SENSE', 'VOLTAGE_MONITOR', 'board_id']
SMPS_MODE was found in this list, but the test results had nothing to do with the power supply of the Wireless module.

As far as I have tried, I have not been able to install Blinka on my Raspberry Pi Pico W. I don't know the details, but the flash storage capacity may be low.
 

k1ng 1337

Joined Sep 11, 2020
911
dir(board) result:
Code:
['__class__', '__name__', 'A0', 'A1', 'A2', 'A3', 'GP0', 'GP1', 'GP10', 'GP11', 'GP12', 'GP13', 'GP14', 'GP15', 'GP16', 'GP17', 'GP18', 'GP19', 'GP2', 'GP20', 'GP21', 'GP22', 'GP26', 'GP26_A0', 'GP27', 'GP27_A1', 'GP28', 'GP28_A2', 'GP3', 'GP4', 'GP5', 'GP6', 'GP7', 'GP8', 'GP9', 'LED', 'SMPS_MODE', 'STEMMA_I2C', 'VBUS_SENSE', 'VOLTAGE_MONITOR', 'board_id']
SMPS_MODE was found in this list, but the test results had nothing to do with the power supply of the Wireless module.

As far as I have tried, I have not been able to install Blinka on my Raspberry Pi Pico W. I don't know the details, but the flash storage capacity may be low.
From that list, GP23 isn't available with the board module which is why you got the error in your first post but it may be available via another module. The example you posted in #4 uses the machine module from MicroPython which was rewritten for CircuitPython. I'm not sure how to access GP23 without board in CircuitPython but there is certainly a way. Have you tried the CircuitPython forum?
 
Top