查看: 2991|回复: 1

[求助] 關於超音波測量溫度(hc-sr04)

[复制链接]
  • TA的每日心情
    开心
    2015-2-14 07:12
  • 签到天数: 4 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    发表于 2015-3-14 21:26:11 | 显示全部楼层 |阅读模式
    分享到:
    上網查了有關超音波的東西
    發現超音波竟然可以測量溫度
    自己也去查了不少
    要如何用python寫出他的超音波測量溫度的公式呢@@?
    只找到這公式
    Vs =331+ 0.6 t°
    我去查也只有測量距離的
    想要改成測量溫度
    有人能幫個忙嘛!!

    以下是我網站抓的程式
    # ultrasonic_1.py
    # Measure distance using an ultrasonic module
    #
    # Author : Matt Hawkins
    # Date   : 09/01/2013

    # Import required Python libraries
    import time
    import RPi.GPIO as GPIO

    # Use BCM GPIO references
    # instead of physical pin numbers
    GPIO.setmode(GPIO.BCM)

    # Define GPIO to use on Pi
    GPIO_TRIGGER = 23
    GPIO_ECHO = 24

    print "Ultrasonic Measurement"

    # Set pins as output and input
    GPIO.setup(GPIO_TRIGGER,GPIO.OUT)  # Trigger
    GPIO.setup(GPIO_ECHO,GPIO.IN)      # Echo

    # Set trigger to False (Low)
    GPIO.output(GPIO_TRIGGER, False)

    # Allow module to settle
    time.sleep(0.5)

    # Send 10us pulse to trigger
    GPIO.output(GPIO_TRIGGER, True)
    time.sleep(0.00001)
    GPIO.output(GPIO_TRIGGER, False)
    start = time.time()
    while GPIO.input(GPIO_ECHO)==0:
      start = time.time()

    while GPIO.input(GPIO_ECHO)==1:
      stop = time.time()

    # Calculate pulse length
    elapsed = stop-start

    # Distance pulse travelled in that time is time
    # multiplied by the speed of sound (cm/s)
    distance = elapsed * 34000

    # That was the distance there and back so halve the value
    distance = distance / 2

    print "Distance : %.1f" % distance

    # Reset GPIO settings
    GPIO.cleanup()


    回复

    使用道具 举报

  • TA的每日心情

    2015-8-29 20:27
  • 签到天数: 5 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    发表于 2015-3-15 19:17:38 | 显示全部楼层
    这种超声波精度不够

    点评

    我知道 但是想試試看  发表于 2015-3-15 21:11
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-4-25 17:27 , Processed in 0.128661 second(s), 18 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.