· 项目介绍(包括设计思路、软硬件介绍等)
由于参加项目比较晚,根据推荐单进行购买发现好多都已经是零库存或者需要批量购买,经过多重筛选后终于定位到这两款芯片
AD22105ARZ-REEL7、Max77596
AD22105是ADI的温度开关芯片,用来测量电池充电时温度,当温度过高时,切断充电功能,对电池进行保护
主要特点如下:
User-programmable temperature setpoint
±2.0°C maximum ambient setpoint accuracy
4.1°C typical hysteresis
Wide supply range: 2.7 V to 7.0 V
Wide temperature range: −40°C to +150°C
Low power dissipation
MAx77596 为buck DCDC 芯片,宽电压输入,非常适合,5v输入或者电池供电输入
芯片主要特点如下:
Benefits and Features
● Flexible Power for Systems That Require a Wide
Input Voltage Range
• VIN Range: 3.5V to 24V
• Up to 300mA Output Current
• Fixed 3.3V, 5V, or Programmable 1V to 10V
Output Voltage
• 98% (Max) Duty Cycle Operation with Low
Dropout
• Operates from 5V, 12V, or 20V USB Type-C Input
Power
• Operates from 2S, 3S, or 4S Li-Ion Batter
购买图片
所以此项目主要是实现5v电源输入、电池输入,5v输入电池自动充电、dcdc buck 3.3V转换、OLED显示 当前甲醛浓度、温湿度
1.硬件部分介绍
1)电源部分
VIN 为5Vtype c 输入,VBAT 为电池输出,此电路实现5v 及电池的输出自动切换,当5v输入时,切断VBAT输出,当无5v输出时,使能VBAT输出,Vout输出给MAX77596。
充电管理实现
充满自动断开充电,当超过设定温度时,自动停止充电,保护电池
AD22105为温度开关芯片,根据温度曲线公式,设定再80摄氏度左右时输出高电平,然后切断电池充电
甲醛模块使用 PICO 串口0 进行数据接收
DHT11 使用pico gpio17 进行单线数据通信
· 项目用到的板卡、芯片、模块、仪器、设备等介绍
1.DHT 11 :温湿度模块
2.pico 树莓派 开发板
3.ZE08-CH2o 电化学甲醛模组
4.SSD1306 IIC oled 模块
5.AD22105 温度开关芯片
6.MAx77596 buck DCDC电源芯片
7.电池充电管理芯片 tp4056
· 关键性代码及说明
1.甲醛 浓度解析
根据datasheet 得知
Byte5 +Byte4*256=ppb
ppm=ppb/1000
ppm与浓度转换关系为
由https://baike.baidu.com/item/%E7%94%B2%E9%86%9B/167033?fr=kg_qa#reference-[2]-4913-wrap 百科可知甲醛分子量为30.3
则 质量浓度= ppm*30.3/22.4
class myUART(UART):
def readUntil(self, ):
sate =0
datHigh=0
datLow =0
while True:
if self.any():
buf = self.read(1)
#print("sate:"+str(sate))
if sate==0:
#print(buf)
if buf == b'\xff':
sate=1
else:
sate=0
elif sate==1 :
if buf == b'\x17':
sate =2
else:
sate =0
elif sate== 2:
if buf == b'\x04':
sate =3
else:
sate=0
elif sate ==3:
if buf == b'\x00':
sate =4
else:
sate=0
elif sate==4:
datHigh=buf
sate=5
elif sate==5:
datLow = buf
sate=6
elif sate==6:
if buf== b'\x13' :
sate=7
else:
sate=0
elif sate==7:
if b'\x88'==buf:
sate=8
else:
sate=0
elif sate==8 :
low = int.from_bytes(datLow,'big')
high = int.from_bytes(datHigh,'big')
if(int.from_bytes(buf,'big')+0x17+0x04+high+low+0x13+0x88)%256==0 :
ch2odat = high*256+low
ppm=ch2odat*0.001
res = ppm*30.3/22.4
sate =0
print(res)
return res
sate=0
串口接收使用状态机形式实现
2.DHT11 温湿度解析
from machine import Pin
import utime
from time import sleep_ms,sleep_us
import sys
import time
class DHT11:
def __init__(self,pin_name):
time.sleep(1)
self.N1 = Pin(pin_name, Pin.OUT)
self.PinName=pin_name
sleep_ms(10)
def read_data(self):
self.__init__(self.PinName)
data=[]
j=0
N1=self.N1
N1.low()
sleep_ms(20)
N1.high()
N1 = Pin(self.PinName, Pin.IN)
sleep_us(30)
if N1.value() != 0:
return [0,0]
while N1.value()==0:
continue
while N1.value()==1:
continue
while j<40:
k=0
while N1.value()==0:
continue
while N1.value()==1:
k+=1
if k>100:break
if k<3:
data.append(0)
else:
data.append(1)
j=j+1
print('Sensor is working')
j=0
humidity_bit=data[0:8]
humidity_point_bit=data[8:16]
temperature_bit=data[16:24]
temperature_point_bit=data[24:32]
check_bit=data[32:40]
humidity=0
humidity_point=0
temperature=0
temperature_point=0
check=0
for i in range(8):
humidity+=humidity_bit[i]*2**(7-i)
humidity_point+=humidity_point_bit[i]*2**(7-i)
temperature+=temperature_bit[i]*2**(7-i)
temperature_point+=temperature_point_bit[i]*2**(7-i)
check+=check_bit[i]*2**(7-i)
tmp=humidity+humidity_point+temperature+temperature_point
if check==tmp:
print('temperature is',temperature,'-wet is',humidity,'%')
else:
print('Error:',humidity,humidity_point,temperature,temperature_point,check)
return [str(temperature),str(humidity)]
实际使用时发现 中间会报 0,0的状态,所以做数据读取时进行判断,如果为[0,0]则使用上次非[0,0]数据
DhtData =dht.read_data()#读取温湿度的值
if DhtData!=[0,0]:
data = DhtData
else :
data =data
· 功能演示结果及说明(可添加演示图片进行解释说明)
如图 可实现甲醛浓度、温度湿度的实时读取
· 对本活动的心得体会(包括意见或建议)
FastBond这个活动很赞,自由发挥度很大,活动群也很活跃,希望主办方多多举办这样的活动。