我尝试在一个专用的Raspberry Pi(我称之为PiServer)中每隔一秒生成一个随机信号,从Raspberry Pi发送到本地web服务器。在
然后,PiServer将消息发送回Raspberry Pi,并在MySQL数据库中存储一个数据。在
现在我想看看增加发送包裹的次数需要多少时间。所以我运行以下代码(咖啡机.py)多次。在
这是我的密码
在咖啡机.py包含在客户机中from time import sleep
import requests
import datetime
import random
home = "A"
device = ["CoffeeModel01", "WashingMachine01", "RiceCooker01", "DryingMachine01", "MicrowaveModel01"]
while True:
num1 = random.randint(0, 1)
num2 = random.randint(0, 1)
num3 = random.randint(0, 1)
deviceNum = random.randint(0,4)
code = "%d%d%d" % (num1, num2, num3)
interval = random.uniform(2.0, 4.0)
timestamp = datetime.datetime.now()
payload = {"Device": device[deviceNum], "Code": code, "T