[PYTHON] Visualisieren Sie die Überlastung von Ereignissen im öffentlichen Raum mit einem Laser-Entfernungsmesser

Überblick

【Referenz】 Über Gebietsmanagement (Ministerium für Land, Infrastruktur, Verkehr und Tourismus)  https://www.mlit.go.jp/common/001059393.pdf Regionale Revitalisierung Stadtentwicklung - Flächenmanagement - (Kabinettssekretariat Stadt / Menschen / Schaffung von Arbeitsplätzen Hauptsitz Sekretariat)  https://www.kantei.go.jp/jp/singi/sousei/about/areamanagement/areamanagement_panf.pdf

Was vorzubereiten?

IMG_0131.JPG IMG_0197.JPG

Vorbereitung

Versammlung

Programmierung

distance.py


#!/usr/bin/env python

import time
import sys
import signal

import VL53L1X

import ambient
import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.OUT) #Zum Blinken der LED
from time import sleep


print("""distance.py

Display the distance read from the sensor.

Uses the "Short Range" timing budget by default.

Press Ctrl+C to exit.

""")

ambi = ambient.Ambient(xxxxx, 'xxxxxxxxxxxxxxxx') #← Umgebungskanal-ID und Lichttaste
count = 0
sndcnt = 0

# Open and start the VL53L1X sensor.
# If you've previously used change-address.py then you
# should use the new i2c address here.
# If you're using a software i2c bus (ie: HyperPixel4) then
# you should `ls /dev/i2c-*` and use the relevant bus number.
tof = VL53L1X.VL53L1X(i2c_bus=1, i2c_address=0x29)
tof.open()

# Optionally set an explicit timing budget
# These values are measurement time in microseconds,
# and inter-measurement time in milliseconds.
# If you uncomment the line below to set a budget you
# should use `tof.start_ranging(0)`
tof.set_timing(66000, 70)

tof.start_ranging(0)  # Start ranging
                      # 0 = Unchanged
                      # 1 = Short Range
                      # 2 = Medium Range
                      # 3 = Long Range

running = True


def exit_handler(signal, frame):
    global running
    running = False
    tof.stop_ranging()
    print()
    sys.exit(0)


# Attach a signal handler to catch SIGINT (Ctrl+C) and exit gracefully
signal.signal(signal.SIGINT, exit_handler)

while running:
    distance_in_mm = tof.get_distance()
    print("Distance: {}mm".format(distance_in_mm))

    now = datetime.datetime.now()
    minute = '{0:%M}'.format(now)
    second = '{0:%S}'.format(now)

    print(minute)
    print(second)

    if distance_in_mm < 1300:  #Schwelle zum Zählen oder nicht(mm)

        count += 1
        GPIO.output(25, GPIO.HIGH)  #LED blinkt
        sleep(0.5)
        GPIO.output(25, GPIO.LOW)
        sleep(0.5)

    if int(minute) % 5 == 0 and int(second) == 0:

        if sndcnt < 1:

            r = ambi.send({'d1': count})
            if r.status_code != 200:
                continue

            print(count)
            print("***sended***\n")

            count = 0

        sndcnt += 1

    else:

        sndcnt = 0

    time.sleep(0.1)

Installationsstand vor Ort

IMG_0138.JPG IMG_0139.JPG IMG_0140.JPG

Ergebnis

Fehlerinhalt

Für die Zukunft

Recommended Posts

Visualisieren Sie die Überlastung von Ereignissen im öffentlichen Raum mit einem Laser-Entfernungsmesser
[In einer Zeile] Visualisiere wie ein Rasen mit nur Pandas
Spiralbuch in Python! Python mit einem Spiralbuch! (Kapitel 14 ~)
Zeichne mit PyCall ein Herz in Ruby