4GES600S开发
移远通信 ES600S开发板的Demo和一些基础的操作指南
开始教程
配置环境与基本认识文档:
开发板使用几大步骤:
1.插上模组;
2.模组开机(具体步骤:https://python.quectel.com/doc/doc/Quick_start/zh/Quick_start.html的4.1章节);
3.驱动安装(注意事项:https://python.quectel.com/doc/doc/Quick_start/zh/Quick_start.html的4.2章节);
4.烧录QuecPython固件
注意事项见:https://python.quectel.com/doc/doc/Quick_start/zh/Quick_start.html的4.3章节
具体步骤的视频连接:https://www.bilibili.com/video/BV1ci4y1w7g8/
5.下载Demo程序(官网的下载专区https://python.quectel.com/download有个Demo的文件夹)
6.例程无法跑通请先自查并参考官网wiki(https://python.quectel.com/wiki/#/),wiki里面包含demo里面涉及的所有API库
开发板需要注意的地方:
Quectel_EC600x-CN(_QuecOpen)兼容性设计讲稿_-0506.pdf
Page24
EC600N-CN/EC600S-CN (QuecOpen)接喇叭则需增加外部PA设计(放大听
筒信号)
EC600N-CN/EC600S-CN QuecOpen 复用键盘引脚(PIN 48~57)也可以复用成
GPIO功能使用,在不用键盘情况下可使用
复用成GPIO口时要注意开机默认状态和电源域,具体参考Quectel_EC600x-CN
QuecOpen_GPIO配置表_V1.0
EC600S-CN/EC600N-CN QuecOpen 开机默认是PU,用于控灯、电机和外部电源
使能之类要注意模块上电时有上拉动作
天线设计
小实验:
如何将软硬件结合?
另外在查询开发板上的GPIO的号码时,可以看看板子中间的引脚介绍,可以解决不少问题,查找不到的可以按照下面的方法进行查找。
即如何查找软件 GPIO 或 ADC 等接口与物理开发板接口的位置
下面以查找KEY2所对应的GPIO号为例:
首先打开 EC600X_QuecPython_EVB_V1.3_SCH.pdf 文件
然后根据需要切换到第六GPIO+UART这一页也是最经常查找的
可以看到左下角的S4,S5即是我们所要寻找的,找到引脚号PIN60后
即可根据API查询到相关的GPIO号码,如图12 即为所求。
有部分不易寻找到内容可以采取多种类似说法,大小写,简要内容的搜索来查找。
简单的外设Demo
UART串口:
External_interrupt外部中断
from machine import ExtInt
import utime as time
# 参考自 http://qpy.quectel.com/wiki/#/zh-cn/api/?id=extint
state = 2
def callBack(args):
global state
print('### interrupt {} ###'.format(args))
#传入的应该是一个List,[GPIOX,X] ,第二个参数不清楚
state = state - 1
def main():
# 映射GPIO12的下降沿触发回调函数
# GPIO12即key2
extint = ExtInt(ExtInt.GPIO12, ExtInt.IRQ_FALLING, ExtInt.PULL_PU, callBack)
# 等待按键按下,触发
while state:
time.sleep_ms(10)
pass
# 停止映射外部中断
extint.disable()
print("The main function has exited")
if __name__ == "__main__":
main()
WatchDog 看门狗
看门狗的复位指的是重启机器
# 实验1: 独立看门狗实验
# API资料参考连接: https://python.quectel.com/wiki/#/zh-cn/api/?id=wdt
from machine import WDT
import utime
wdt = None # 定义全部变量
def Watchdog(): # 2秒钟内调用喂狗函数,否则系统复位
global wdt # 声明全部变量
if wdt is None:
wdt = WDT(2) # 启动看门狗,间隔时长 单位 秒
wdt.feed() # 喂狗
def func_1():
utime.sleep_ms(1000) # 延时1秒
print('功能函数 1')
def func_2():
utime.sleep_ms(1000) # 延时1秒
print('功能函数 2')
def func_3():
utime.sleep_ms(1000) # 延时1秒
print('功能函数 3')
Watchdog() # 2秒钟内调用喂狗函数
utime.sleep_ms(1000) # 延时1秒
print('功能函数 3_2')
def func_4():
utime.sleep_ms(1000)
print('功能函数 4')
Watchdog() # 2秒钟内调用喂狗函数
print('尝试在5s后喂狗')
utime.sleep_ms(5000) # 延时5秒
Watchdog()
print('来不及喂狗,系统已经复位')#此行代码不会显示因为机器已经重启了
def main():
print('喂狗')
Watchdog() # 2秒钟内调用喂狗函数
func_1() # 用户程序
print('喂狗')
Watchdog() # 2秒钟内调用喂狗函数
func_2() # 用户程序
print('喂狗')
Watchdog() # 2秒钟内调用喂狗函数
func_3() # 用户程序
print('喂狗')
Watchdog() # 2秒钟内调用喂狗函数
func_4() # 用户程序
if __name__ == "__main__":
main()
温湿度检测
测得不准,勉强能看
'''
File: i2c_aht10.py
Project: i2c
File Created: Monday, 28th December 2020 5:17:28 pm
Author: chengzhu.zhou
-----
Last Modified: Tuesday, 29th December 2020 9:01:35 pm
Modified By: chengzhu.zhou
-----
Copyright 2020 - 2020 quectel
'''
import log
from machine import I2C
import utime as time
"""
1. calibration
2. Trigger measurement
3. read data
"""
# API 手册 http://qpy.quectel.com/wiki/#/zh-cn/api/?id=i2c
# AHT10 说明书
# https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf
class aht10class():
i2c_log = None
i2c_dev = None
i2c_addre = None
# Initialization command
AHT10_CALIBRATION_CMD = 0xE1
# Trigger measurement
AHT10_START_MEASURMENT_CMD = 0xAC
# reset
AHT10_RESET_CMD = 0xBA
def write_data(self, data):
self.i2c_dev.write(self.i2c_addre,
bytearray(0x00), 0,
bytearray(data), len(data))
pass
def read_data(self, length):
r_data = [0x00 for i in range(length)]
r_data = bytearray(r_data)
self.i2c_dev.read(self.i2c_addre,
bytearray(0x00), 0,
r_data, length,
0)
return list(r_data)
def aht10_init(self, addre=0x38, Alise="Ath10"):
self.i2c_log = log.getLogger(Alise)
self.i2c_dev = I2C(I2C.I2C1, I2C.STANDARD_MODE) # 返回i2c对象
self.i2c_addre = addre
self.sensor_init()
pass
def aht10_transformation_temperature(self, data):
r_data = data
# 根据数据手册的描述来转化温度
humidity = (r_data[0] << 12) | (
r_data[1] << 4) | ((r_data[2] & 0xF0) >> 4)
humidity = (humidity/(1 << 20)) * 100.0
print("current humidity is {0}%".format(humidity))
temperature = ((r_data[2] & 0xf) << 16) | (
r_data[3] << 8) | r_data[4]
temperature = (temperature * 200.0 / (1 << 20)) - 50
print("current temperature is {0}°C".format(temperature))
def sensor_init(self):
# calibration
self.write_data([self.AHT10_CALIBRATION_CMD, 0x08, 0x00])
time.sleep_ms(300) # at last 300ms
pass
def ath10_reset(self):
self.write_data([self.AHT10_RESET_CMD])
time.sleep_ms(20) # at last 20ms
def Trigger_measurement(self):
# Trigger data conversion
self.write_data([self.AHT10_START_MEASURMENT_CMD, 0x33, 0x00])
time.sleep_ms(200) # at last delay 75ms
# check has success
r_data = self.read_data(6)
# check bit7
if (r_data[0] >> 7) != 0x0:
print("Conversion has error")
else:
self.aht10_transformation_temperature(r_data[1:6])
def i2c_aht10_test():
ath_dev = aht10class()
ath_dev.aht10_init()
# 测试十次
for i in range(10):
ath_dev.Trigger_measurement()
time.sleep(1)
if __name__ == "__main__":
i2c_aht10_test()
Photoresistor 光敏电阻
得到的数值为ADC电压值
'''
File: Photoresistor.py
Project: adc
File Created: Thursday, 24th December 2020 5:44:08 pm
Author: chengzhu.zhou
-----
Last Modified: Wednesday, 30th December 2020 10:10:33 am
Modified By: chengzhu.zhou
-----
Copyright 2020 - 2020 quectel
'''
from misc import ADC
import utime as time
import _thread
# unit as Ω
def Voltage_to_Resistance(Volt):
#
Va = 2 * Volt
resistance = (2 * 4700 * 40200 * Va)/(2 * 4700 * (3300 - Va) - (40200 * Va))
return resistance
def Photoresistor_thread(delay, retryCount):
# creat a adc device
AdcDevice = ADC()
while retryCount:
retryCount = retryCount - 1
# get ADC.ADC0 value
adcvalue = AdcDevice.read(ADC.ADC0)
print("get ADC.ADC0 Voltage value as {0}mv".format(adcvalue))
# Converted to resistance
resistance = Voltage_to_Resistance(adcvalue)
print("Photoresistor resistance as {0}Ω".format(resistance))
time.sleep(delay)
pass
if __name__ == "__main__":
# creat a thread Convert ADC to Voltage
_thread.start_new_thread(Photoresistor_thread, (1, 10))
print("creent main thread has exit")