该系统是基于物联网的热报警系统,当检测到热异常时,会关闭设备并发送短信。硬件部件:BoltIoTBoltWiFi模块蜂鸣器LED(红色、蓝色、5mm)温度感应器(LM35)(LM35传感器对其可以检测到的温度有限制,它只能检测最低-55摄氏度到最高155摄氏度)软件应用程序:TwilioSMS电路图:第1步:蜂鸣器标有“+”的引脚为正极引,它连接到BoltWi-Fi模块的GPIO1端口。第2步:蓝色和红色LED的较长脚是正极引脚,它们分别连接到GPIO端口2和3。第3步:蜂鸣器的“-”标记引脚和两个LED的较短脚是负极引脚,它们都连接到BoltWi-Fi模块的GND(接地)端口。第4步:LM35传感器的引脚配置如下:引脚1连接到Bolt模块的5V端口引脚2连接到Bolt模块的模拟A0引脚引脚3连接到Bolt模块的GND(接地)端口(注意:最好使用面包板进行连接,因为它可以防止Bolt模块中的电线过度拥挤。)代码:(点击查看)importdevice_infofromboltiotimportBolt,Smsimportjson,timemax_temp=55min_temp=25mybolt=Bolt(device_info.api,device_info.dev_id)sms=Sms(device_info.SID,device_info.token,device_info.my_no,device_info.from_no)response=mybolt.isOnline()power=json.loads(response)ifpower['value']=="online":whileTrue:print("Readingsensordata...")data=json.loads(mybolt.analogRead('A0'))try:temp=int(data['value'])*100/1024print("Sensorreadingis"+str(temp)+"degreecelsius")iftemp>max_temp:print("ContactingTwilioservers...")response=sms.send_sms("HIGHTEMPERATUREALERT!CURRENTTEMPERATUREIS"+str(temp))print("SMSstatus:"+str(response.status))response2=mybolt.analogWrite('1','250')foriinrange(1,8):response3=mybolt.digitalWrite('2','HIGH')time.sleep(0.5)response3=mybolt.digitalWrite('2','LOW')eliftempprint("ContactingTwilioservers...")response=sms.send_sms("LOWTEMPERATUREALERT!CURRENTTEMPERATUREIS:"+str(temp))print("SMSstatus:"+str(response.status))response2=mybolt.analogWrite('1','50')foriinrange(1,8):response3=mybolt.digitalWrite('3','HIGH')time.sleep(0.5)response3=mybolt.digitalWrite('3','LOW')else:print("Temperaturealright.")response2=mybolt.digitalWrite('1','LOW')response3=mybolt.digitalWrite('2','LOW')response3=mybolt.digitalWrite('3','LOW')exceptExceptionase:print("Error!")print(e)time.sleep(10)else:print("DEVICEOFFLINE..")print("MAKESURETHEIOTMODULEHASBEENPLUGGEDIN")项目演示: