uPY uart 无法与 EG25-G 正确通信

发布于 2025-01-15 03:01:43 字数 2328 浏览 2 评论 0原文

我有一个连接到 GP0 和 GP1 的电机控制器,所以我知道它们可以工作,但是我似乎无法从 SIM 控制器获得响应。如果没有将 pico 连接到板上,我可以让它工作,但是当我添加 pico 时,如果 pico 收到任何数据,它似乎不会发送 AT 命令或翻译接收到的数据。我尝试在实时会话中逐行运行代码,得到的只是一个数字,该数字等于我发送到 sim 控​​制器的字符串中的字母数。即 uart.write(bytearray(b'ATE1\r\n')) 将返回 >>> 6 6 是代码中b之后的字符数。我正在订购一个新的 pico,看看是否是我的焊接质量不合格,但与此同时,我可以看看是否有比我更有经验的人可以指出错误。

import machine
import os
import utime
import time
import binascii
from machine import UART


pwr_enable = 22  # EG25_4G Power key connected on GP22
uart_port = 0
uart_baud = 115200




# Initialize UART0
uart = machine.UART(uart_port, uart_baud)
print(os.uname())


def wait_resp_info(timeout=3000):
        prvmills = utime.ticks_ms()
        info = b""
        while (utime.ticks_ms()-prvmills) < timeout:
            if uart.any():
                info = b"".join([info, uart.read(1)])
        print(info.decode())
        return info



def Check_and_start(): # Initialize SIM Module 
        while True:
            uart.write(bytearray(b'ATE1\r\n')) 
            utime.sleep(10)
            uart.write(bytearray(b'AT\r\n'))
            rec_temp = wait_resp_info()
            print(wait_resp_info())
            print(rec_temp)
            print(rec_temp.decode())
            utime.sleep(10)
            if 'OK' in rec_temp.decode():
                print('OK response from AT command\r\n' + rec_temp.decode())
                break
            else:
                power = machine.Pin(pwr_enable, machine.Pin.OUT)
                power.value(1)
                utime.sleep(2)
                power.value(0)
                print('No response, restarting\r\n')
                utime.sleep(10)
               


def Network_check():# Network connectivity check
        for i in range(1, 3):
            if Send_command("AT+CGREG?", "0,1") == 1:
                print('Connected\r\n')
                break
            else:
                print('Device is NOT connected\r\n')
                utime.sleep(2)
                continue


def Str_to_hex_str(string):
    str_bin = string.encode('utf-8')
    return binascii.hexlify(str_bin).decode('utf-8')



            
    Check_and_start() 
    Network_check() 

响应是

>>> Check_and_start()


b''
b'\x00\x00'

No response, restarting

I had a motor controller connected to GP0 and GP1 so I know they work, however I cant seem to get a response from the SIM controller. Without the pico attached to the board, I can get it to work, but when I add the pico it seems like it wont send AT commands or translate received data if the pico is getting any at all. I have tried to run the code line by line in a live session and all I get is a single number that is equal to the number of letters inside the string that I am sending to the sim controller. ie uart.write(bytearray(b'ATE1\r\n')) would return >>> 6 6 being the number of characters in the code after b. I'm ordering a new pico to see if just maybe it was my sub par soldering, but in the mean time I could see if anyone more experienced than I can point out a error.

import machine
import os
import utime
import time
import binascii
from machine import UART


pwr_enable = 22  # EG25_4G Power key connected on GP22
uart_port = 0
uart_baud = 115200




# Initialize UART0
uart = machine.UART(uart_port, uart_baud)
print(os.uname())


def wait_resp_info(timeout=3000):
        prvmills = utime.ticks_ms()
        info = b""
        while (utime.ticks_ms()-prvmills) < timeout:
            if uart.any():
                info = b"".join([info, uart.read(1)])
        print(info.decode())
        return info



def Check_and_start(): # Initialize SIM Module 
        while True:
            uart.write(bytearray(b'ATE1\r\n')) 
            utime.sleep(10)
            uart.write(bytearray(b'AT\r\n'))
            rec_temp = wait_resp_info()
            print(wait_resp_info())
            print(rec_temp)
            print(rec_temp.decode())
            utime.sleep(10)
            if 'OK' in rec_temp.decode():
                print('OK response from AT command\r\n' + rec_temp.decode())
                break
            else:
                power = machine.Pin(pwr_enable, machine.Pin.OUT)
                power.value(1)
                utime.sleep(2)
                power.value(0)
                print('No response, restarting\r\n')
                utime.sleep(10)
               


def Network_check():# Network connectivity check
        for i in range(1, 3):
            if Send_command("AT+CGREG?", "0,1") == 1:
                print('Connected\r\n')
                break
            else:
                print('Device is NOT connected\r\n')
                utime.sleep(2)
                continue


def Str_to_hex_str(string):
    str_bin = string.encode('utf-8')
    return binascii.hexlify(str_bin).decode('utf-8')



            
    Check_and_start() 
    Network_check() 

Response is

>>> Check_and_start()


b''
b'\x00\x00'

No response, restarting

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待圉鍢 2025-01-22 03:01:43

新的 Pico 解决了我的问题,我相信是我焊接技术不足造成了这个问题。症状是,没有通过 UART 引脚 0 和 1 发送或接收 UART 数据。解决方案是插入新的 Pico 板代替旧板,上传相同的代码并第一次成功运行。

New Pico fixed my issue, I believe it to be that my inadequate soldering skills created the issue. Symptoms were, no UART data was being transmitted or received through UART pins 0 and 1. Solution was new Pico board was inserted in place of old one, same code was uploaded and ran successfully first time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文