1

Today is my first day using raspberry pi, and I am new to microcontrollers in general, so please forgive me if my question has an obvious answer.

When I run the following program:

import machine
import utime
import ubinascii

RS08_W_Addr = 0x52

#state1 = [0x17, 0x1, 0x0]
#state2 = [0x17, 0x0, 0x0]
state1 = [b'b10111', b'1', b'0']
state2 = [b'b10111', b'0', b'0']


#p16 = machine.Pin(16, machine.Pin.OUT, machine.Pin.PULL_UP)
#p17 = machine.Pin(17, machine.Pin.OUT, machine.Pin.PULL_UP)


i2c = machine.I2C(0, scl=machine.Pin(17), 
sda=machine.Pin(16),freq=100000)

while True:
    utime.sleep_ms(1000)
    #send "open" command
    i2c.writevto(RS08_W_Addr, state1, True)
    utime.sleep_ms(100)

    utime.sleep_ms(1000)
    #send "close" command
    i2c.writevto(RS08_W_Addr, state2, True)
    utime.sleep_ms(100)

I get the following error messages:

Traceback (most recent call last):
  File "C:\Users\jonat\AppData\Local\Programs\Thonny\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "C:\Users\jonat\AppData\Local\Programs\Thonny\lib\site-packages\thonny\workbench.py", line 1961, in toolbar_handler
    handler(*args)
  File "C:\Users\jonat\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 411, in cmd_run_current_script
    self.execute_current("Run")
  File "C:\Users\jonat\AppData\Local\Programs\Thonny\lib\site-packages\thonny\running.py", line 370, in execute_current
    and not self._proxy.can_run_local_files()
AttributeError: 'NoneType' object has no attribute 'can_run_local_files'

Additionally, when I try to stop/restart backend, I get

Unable to connect to COM3: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)

If you have serial connection to the device from another program, then disconnect it there first.

Backend terminated or disconnected. Use 'Stop/Restart' to restart.

This happens whenever I try to stop the backend, and so my solution keeps on being to nuke the flash. Afterwards, I am able to run other programs on the pico (e.g. toggle an LED), but when I try to run this one again, the same issue occurs. Strangely, it worked for me temporarily once, which is why I keep on trying to run it again.

If anyone could explain what is going on or refer me to someplace that explains it, I would be greatly appreciative.

Thank you in advance.

Updates/clarification based on comments:

I figured out what line causes the issue by only uploading portions of the program to the raspberry pi, until I hit the line that causes the issue. The line that causes the issue is "i2c.writevto(RS08_W_Addr, state1, True)".

Re "what is 'i2c.writevto(RS08_W_Addr, state1, True)' supposed to do?" :

The RS_08 is a shutter that communicates via I2C. The first byte tells the shutter that I want to change it's state, and then the second two bytes specify what state I want to change it to.

re "It is not clear if you started using Rpi3/4 today, or Rpi Pico today using Win 7/10 Thonny, or Rpi 3/4 Thonny.":

Yesterday was my first time using Rpi Pico, my first time using Thonny, and my first time using any Rpi product.

7
  • 2
    please format your code and the error message ... put ``` on a blank line before the listing and on blank line after the listing
    – jsotola
    Sep 10 at 6:36
  • (1) What is this statement supposed to do: "i2c.writevto(RS08_W_Addr, state1, True)"? (2) Are you playing with PCA9685?
    – tlfong01
    Sep 10 at 8:15
  • 2
    This appears to be a Windows problem. Nothing to do with the Pico.
    – joan
    Sep 10 at 9:02
  • (3) And if you mess up Win COM3, Windows will start a new port, eg COM4. So updating Windows Thonny to COM4 should solve the problem. (4) It is not clear if you started using Rpi3/4 today, or Rpi Pico today using Win 7/10 Thonny, or Rpi 3/4 Thonny. You might like to clarify.
    – tlfong01
    Sep 10 at 9:52
  • 1
    Update: I tried changing the COM port (device manager --> Ports (COM & LPT) --> USB Serial Devices (COM3) --> Port Settings -->Advanced --> COM5 (it says COM4 is in use). It didn't solve the problem. Is this what you were suggesting @tlfong01 or did I misinterpret your suggestion? I answered the questions posted by updating my question. Thank you all again. Sep 10 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.