噪声污染也称为环境噪声或声音污染,是对人类或动物生命活动产生有害影响的噪声传播。城市规划不当可能会引起噪声污染,工业和住宅并排的建筑物会导致噪声污染在居民区。住宅区的一些主要噪音源包括嘈杂的音乐、交通噪音、草坪护理维护、附近的施工或年轻人的大喊大叫(体育比赛)。获得的 97.60 分贝的平均噪音水平超过了 WHO 允许的住宅区 50 分贝值地区。噪音对健康的影响。噪音对健康的影响是经常暴露在持续升高的声级下的身心健康后果。升高的工作场所或环境噪音会导致听力障碍、耳鸣、高血压、缺血性心脏病、烦恼和睡眠障碍。免疫系统的变化和出生缺陷也归因于噪声暴露。因此,作为此解决方案的一个小补救措施,我制作了一个能够获取城市各个区域声级数据的设备。将这些数据与各个部门接受的声级进行比较。考虑医院和公园具有不同的可接受声级。这将已经由有关当局确定,因此当与固定声级相比声级有所增加时。这些部门将由有关团队标记。这是如何工作的,由声音传感器组成的设备会频繁地将数据从扇区发送到IOTA Tangle。该数据由权限通过任何设备访问(应该有 python 平台)
注意:在这里,您可以使用 ADC MCP3008(模数转换器)通过避免使用 arduino uno 来使用树莓派从声音传感器收集模拟数据
pip install pyota
pip install PrettyTable
对于刚接触 IOTA 的人来说,地址系统一开始可能看起来很混乱。为了消除混淆,以下链接将涵盖您需要了解的有关 IOTA 地址的所有专业知识。
int soundSensor=A0;
int dB;
void setup() {
pinMode(soundSensor,INPUT);
Serial.begin(9600);
}
void loop() {
int Data=analogRead(soundSensor);
Serial.println(Data);
dB = (Data+83.2073) / 11.003;//decibal value
Serial.println(dB);
Serial.write(dB);//Send data to the raspberry pi 3
delay(100);
}
第二个是从 arduino 到 pi 的数据的代码,它正在上传到 tangle。(Upload.py)
from datetime import datetime
import schedule
import time
# Import GPIO library
import RPi.GPIO as GPIO
import serial
#Setup sensor as input
# Import the PyOTA library
import iota
# Import json
import json
# Define IOTA address where all transactions (cleaning records) are stored, replace with your own address.
# IOTA addresses can be created with the IOTA Wallet
CleaningLogAddr = b"XXXXXXXXXHKBWTCGKXTJGWHXEYJONN9MZZQUQLSZCLHFAWUWKHZCICTHISXBBAKGFQENMWMBOVWJTCMEWXKQDTJCV9"
# Create IOTA object, specify full node to be used when sending transactions.
# Notice that not all nodes in the field.deviota.com cluster has enabled attaching transactions to the tangle
# In this case you will get an error, you can try again later or change to a different full node.
api = iota.Iota("https://nodes.thetangle.org:443")
# Define static variable
city = "Smart District"
sector=0
def datapost():
FB = api.send_transfer(depth=3, transfers=[pta], min_weight_magnitude=14)['bundle']
print("success")
schedule.every(1).minutes.do(datapost)
# Main loop,
try:
while True:
ser = serial.Serial("/dev/ttyUSB0", 9600)#communication with pi,should also check the port
status=ser.read()
st=str(status)
# Create json data to be uploaded to the tangle
data1 = {'city': city, 'sector':sector,'Status': st}
# Define new IOTA transaction
pta = iota.ProposedTransaction(address = iota.Address(CleaningLogAddr),
message = iota.TryteString.from_unicode(json.dumps(data1)),
tag = iota.Tag(b'SMARTDISTRICT'),
value = 0)
schedule.run_pending()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
第三个代码用于将数据从 tangle 中检索到 authority。(Display.py)
# Imports from the PyOTA library
from iota import Iota
from iota import Address
from iota import Transaction
from iota import TryteString
# Import json library
import json
# Import datetime libary
import datetime
# Import from PrettyTable
from prettytable import PrettyTable
# Define IOTA address where all transactions are stored, replace with your own address.
address = [Address(b'XXXXXXXXXXXXXXCGKXTJGWHXEYJONN9MZZQUQLSZCLHFAWUWKHZCICTHISXBBAKGFQENMWMBOVWJTCMEWXKQDTJCV9')]
# Define full node to be used when retrieving cleaning records
iotaNode = "https://nodes.thetangle.org:443"
# Create an IOTA object
api = Iota(iotaNode)
# Create PrettyTable object
x = PrettyTable()
# Specify column headers for the table
x.field_names = [ "city", "sector","Status"]
# Find all transacions for selected IOTA address
result = api.find_transactions(addresses=address)
# Create a list of transaction hashes
myhashes = result['hashes']
# Print wait message
print("Please wait while retrieving sound records from the tangle...")
# Loop trough all transaction hashes
for txn_hash in myhashes:
# Convert to bytes
txn_hash_as_bytes = bytes(txn_hash)
# Get the raw transaction data (trytes) of transaction
gt_result = api.get_trytes([txn_hash_as_bytes])
# Convert to string
trytes = str(gt_result['trytes'][0])
# Get transaction object
txn = Transaction.from_tryte_string(trytes)
# Get transaction timestamp
timestamp = txn.timestamp
# Convert timestamp to datetime
clean_time = datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
# Get transaction message as string
txn_data = str(txn.signature_message_fragment.decode())
# Convert to json
json_data = json.loads(txn_data)
# Check if json data has the expected json tag's
if all(key in json.dumps(json_data) for key in ["city","sector","Status"]):
# Add table row with json values
x.add_row([json_data['city'], json_data['sector'], json_data['Status'], clean_time])
# Sort table by cleaned datetime
x.sortby = "status"
# Print table to terminal
print(x)
此代码将在 pi 的终端上打印表格。从那里我们可以找到违反规定声级并可以标记的扇区。通过这种方式,我们可以减少每个部门的声音污染,并将其引导到一个智慧城市。
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !