MikrofonSensor und TemperaturSenor die zwei Python programme funktionieren. mit den jeweiligen 2 json Datein. Beim TemperaturSensor wird im Terminal keine Wertre ausgegeben aber in der json Datei kann man die Temp und Hum sehen.

This commit is contained in:
Chiara 2025-05-28 14:53:44 +02:00
parent 4c654ec969
commit 1751076592
2614 changed files with 349009 additions and 0 deletions

View file

@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""Genereic Pin class for use with MicroPython boards"""
from adafruit_blinka import Enum
class Pin(Enum):
"""
Identifies an IO pin on the microcontroller.
They are fixed by the hardware so they cannot be constructed on demand. Instead, use board or
microcontroller.pin to reference the desired pin.
"""
def __init__(self, pin_id):
"""Identifier for pin, referencing platform-specific pin id"""
self.id = pin_id
def __repr__(self):
# pylint: disable=import-outside-toplevel, cyclic-import
import board
import microcontroller.pin
for key in dir(board):
if getattr(board, key) is self:
return "board.{}".format(key)
# pylint: enable=import-outside-toplevel, cyclic-import
for key in dir(microcontroller.pin):
if getattr(microcontroller.pin, key) is self:
return "microcontroller.pin.{}".format(key)
return repr(self)

View file

@ -0,0 +1,54 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""I2C Class for Generic MicroPython"""
from machine import I2C as _I2C
class I2C:
"""I2C Class for Generic MicroPython"""
MASTER = 0
# pylint: disable=unused-argument
def __init__(self, portId, *, mode=MASTER, baudrate=100000):
self._i2c = _I2C(portId, freq=baudrate)
def scan(self):
"""Perform an I2C Device Scan"""
return self._i2c.scan()
def writeto(self, address, buffer, *, stop=True):
"""Write the data from the buffer to the address"""
return self._i2c.writeto(address, buffer)
def readfrom_into(self, address, buffer, *, stop=True):
"""Read data from an address and into the buffer"""
return self._i2c.readfrom_into(address, buffer)
def writeto_then_readfrom(
self,
address,
buffer_out,
buffer_in,
*,
out_start=0,
out_end=None,
in_start=0,
in_end=None,
stop=False,
):
"""Write data from buffer_out to an address and then
read data from an address and into buffer_in
"""
self._i2c.writeto_then_readfrom(
address,
buffer_out,
buffer_in,
out_start=out_start,
out_end=out_end,
in_start=in_start,
in_end=in_end,
)
# pylint: enable=unused-argument

View file

@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""SPI Class for Generic MicroPython"""
from machine import SPI as _SPI
# pylint: disable=protected-access, no-self-use
class SPI:
"""SPI Class for Generic MicroPython"""
MSB = _SPI.MSB
LSB = _SPI.LSB
def __init__(self, portId, baudrate=100000):
self._frequency = baudrate
self._spi = _SPI(portId)
# pylint: disable=too-many-arguments,unused-argument
def init(
self,
baudrate=1000000,
polarity=0,
phase=0,
bits=8,
firstbit=_SPI.MSB,
):
"""Initialize the Port"""
self._frequency = baudrate
self._spi.init(
baudrate=baudrate,
polarity=polarity,
phase=phase,
bits=bits,
firstbit=firstbit,
mode=_SPI.MASTER,
)
# pylint: enable=too-many-arguments
@property
def frequency(self):
"""Return the current frequency"""
return self._frequency
def write(self, buf, start=0, end=None):
"""Write data from the buffer to SPI"""
self._spi.write(buf)
def readinto(self, buf, start=0, end=None, write_value=0):
"""Read data from SPI and into the buffer"""
self._spi.readinto(buf)
# pylint: disable=too-many-arguments
def write_readinto(
self, buffer_out, buffer_in, out_start=0, out_end=None, in_start=0, in_end=None
):
"""Perform a half-duplex write from buffer_out and then
read data into buffer_in
"""
self._spi.write_readinto(
buffer_out,
buffer_in,
out_start=out_start,
out_end=out_end,
in_start=in_start,
in_end=in_end,
)
# pylint: enable=too-many-arguments