@@ -0,0 +1,27 @@ | |||
{ | |||
// Verwendet IntelliSense zum Ermitteln möglicher Attribute. | |||
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen. | |||
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387 | |||
"version": "0.2.0", | |||
"configurations": [ | |||
{ | |||
"name": "Download and Run current file", | |||
"type": "ev3devBrowser", | |||
"request": "launch", | |||
"program": "/home/robot/${workspaceFolderBasename}/${relativeFile}", | |||
"interactiveTerminal": true | |||
}, | |||
{ | |||
"name": "Download and Run my-program", | |||
"type": "ev3devBrowser", | |||
"request": "launch", | |||
"program": "/home/robot/${workspaceFolderBasename}/my-program (replace 'my-program' with the actual path)", | |||
"interactiveTerminal": true | |||
} | |||
] | |||
} |
@@ -0,0 +1,3 @@ | |||
__pycache__/ | |||
*.pyc | |||
.venv/ |
@@ -0,0 +1,13 @@ | |||
{ | |||
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | |||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | |||
// List of extensions which should be recommended for users of this workspace. | |||
"recommendations": [ | |||
"lego-education.ev3-micropython" | |||
], | |||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | |||
"unwantedRecommendations": [ | |||
"ms-python.python" | |||
] | |||
} |
@@ -0,0 +1,15 @@ | |||
{ | |||
// Use IntelliSense to learn about possible attributes. | |||
// Hover to view descriptions of existing attributes. | |||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |||
"version": "0.2.0", | |||
"configurations": [ | |||
{ | |||
"name": "Download and Run", | |||
"type": "ev3devBrowser", | |||
"request": "launch", | |||
"program": "/home/robot/${workspaceRootFolderName}/main.py", | |||
"interactiveTerminal": false | |||
} | |||
] | |||
} |
@@ -0,0 +1,7 @@ | |||
// Place your settings in this file to overwrite default and user settings. | |||
{ | |||
"files.eol": "\n", | |||
"debug.openDebug": "neverOpen", | |||
"python.linting.enabled": false, | |||
"python.languageServer": "None" | |||
} |
@@ -0,0 +1,14 @@ | |||
# Import the necessary modules from the ev3dev2 library | |||
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_D | |||
from time import sleep | |||
# Connect the motors to the EV3 brick | |||
motor_left = LargeMotor(OUTPUT_A) | |||
motor_right = LargeMotor(OUTPUT_D) | |||
# Move the robot forward for 5 seconds | |||
motor_left.on(50) | |||
motor_right.on(50) | |||
sleep(5) | |||
motor_left.off() | |||
motor_right.off() |
@@ -0,0 +1,3 @@ | |||
__pycache__/ | |||
*.pyc | |||
.venv/ |
@@ -0,0 +1,13 @@ | |||
{ | |||
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | |||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | |||
// List of extensions which should be recommended for users of this workspace. | |||
"recommendations": [ | |||
"lego-education.ev3-micropython" | |||
], | |||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | |||
"unwantedRecommendations": [ | |||
"ms-python.python" | |||
] | |||
} |
@@ -0,0 +1,15 @@ | |||
{ | |||
// Use IntelliSense to learn about possible attributes. | |||
// Hover to view descriptions of existing attributes. | |||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |||
"version": "0.2.0", | |||
"configurations": [ | |||
{ | |||
"name": "Download and Run", | |||
"type": "ev3devBrowser", | |||
"request": "launch", | |||
"program": "/home/robot/${workspaceRootFolderName}/main.py", | |||
"interactiveTerminal": false | |||
} | |||
] | |||
} |
@@ -0,0 +1,7 @@ | |||
// Place your settings in this file to overwrite default and user settings. | |||
{ | |||
"files.eol": "\n", | |||
"debug.openDebug": "neverOpen", | |||
"python.linting.enabled": false, | |||
"python.languageServer": "None" | |||
} |
@@ -0,0 +1,65 @@ | |||
#!/usr/bin/env pybricks-micropython | |||
from pybricks.hubs import EV3Brick | |||
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, | |||
InfraredSensor, UltrasonicSensor, GyroSensor) | |||
from pybricks.parameters import Port, Stop, Direction, Button, Color | |||
from pybricks.tools import wait, StopWatch, DataLog | |||
from pybricks.robotics import DriveBase | |||
from pybricks.media.ev3dev import SoundFile, ImageFile | |||
import sys | |||
def fun_1(ev3): | |||
pass | |||
def fun_2(a,b): | |||
return 1 | |||
def move_1(mo_forward_1, mo_forward_2, mo_le_ri, mo_up_down): | |||
wait(2000) | |||
#move forward | |||
mo_forward_1.run_target(500, 1250,wait=False) | |||
mo_forward_2.run_target(500, 1250) | |||
#move arm | |||
mo_le_ri.run_target(200,-50) | |||
#move sensors | |||
mo_up_down.run_target(500,2500) | |||
wait(2000) | |||
mo_up_down.run_target(500,0) | |||
#move arm | |||
mo_le_ri.run_target(200,0) | |||
#move backwards | |||
mo_forward_1.run_target(500, 0,wait=False) | |||
mo_forward_2.run_target(500, 0) | |||
def move_2(): | |||
pass | |||
def move_3(): | |||
pass | |||
ev3 = EV3Brick() | |||
motor_forward_1 = Motor(Port.A) | |||
motor_forward_2 = Motor(Port.D) | |||
motor_le_ri = Motor(Port.B, Direction.COUNTERCLOCKWISE, [8, 56]) #with gear for angle | |||
motor_up_down = Motor(Port.C) | |||
#n = int(sys.argv[1]) | |||
#if n == 1: | |||
move_1(motor_forward_1,motor_forward_2,motor_le_ri,motor_up_down) | |||
@@ -0,0 +1,55 @@ | |||
from flask import Flask | |||
import time | |||
from sensors import readSensors | |||
app = Flask(__name__) | |||
@app.route("/", methods=['GET', 'POST']) | |||
def hello_world(): | |||
return "<p>Hello, World!</p>" | |||
""" | |||
SENSOR TEST FUNCTION | |||
""" | |||
@app.route("/measurement_test", methods=['GET']) | |||
def measurement_test(): | |||
return readSensors() | |||
""" | |||
""" | |||
@app.route("/temp/<int:sensor_id>", methods=['GET']) | |||
def get_temperature(sensor_id): | |||
if sensor_id == 1: | |||
# here we need to read our sensor values | |||
return "23.4" | |||
elif sensor_id == 2: | |||
return "21.0" | |||
else: | |||
return "not found" | |||
@app.route("/move/<position>", methods=['POST']) | |||
def post_move(position): | |||
if position == 'plant1': | |||
return f"I moved to position: {position}" | |||
# control motors or whatever you like | |||
return f"Somewhere moved, no idea where to: {position}" | |||
@app.route("/all", methods=['GET']) | |||
def get_all(): | |||
# read sensor data | |||
# TODO | |||
time.sleep(10) | |||
# put sensor data into a dict | |||
ret = { | |||
"plant_id": 1, | |||
"sensordata_temp":20.5, | |||
"sensordata_humidity": 23.5 | |||
} | |||
# return it as json data | |||
return ret | |||
app.run(host='192.168.0.106', port=5000) |
@@ -0,0 +1,14 @@ | |||
# Import the necessary modules from the ev3dev2 library | |||
from ev3dev2.motor import LargeMotor, OUTPUT_B, OUTPUT_C | |||
from time import sleep | |||
# Connect the motors to the EV3 brick | |||
motor_left = LargeMotor(OUTPUT_B) | |||
motor_right = LargeMotor(OUTPUT_C) | |||
# Move the robot forward for 5 seconds | |||
motor_left.on(50) | |||
motor_right.on(50) | |||
sleep(5) | |||
motor_left.off() | |||
motor_right.off() |
@@ -0,0 +1,89 @@ | |||
from picamera import PiCamera | |||
from time import sleep | |||
from datetime import datetime | |||
import RPi.GPIO as GPIO | |||
import board | |||
import adafruit_dht | |||
import smbus | |||
import time | |||
#Connect Sensors | |||
#Camera | |||
#camera = PiCamera() | |||
#Air Temp&Humidity | |||
dhtDevice = adafruit_dht.DHT22(board.D4, use_pulseio=False) | |||
#Earth Humidity | |||
chanel = 21 | |||
GPIO.setmode(GPIO.BCM) | |||
GPIO.setup(chanel, GPIO.IN) | |||
# Brightness Sensor | |||
bus = smbus.SMBus(1) | |||
bus.write_byte_data(0x39, 0x00 | 0x80, 0x03) | |||
bus.write_byte_data(0x39, 0x01 | 0x80, 0x02) | |||
def readSensors(): | |||
#Connect Sensors | |||
#Camera | |||
#camera = PiCamera() | |||
#Air Temp&Humidity | |||
dhtDevice = adafruit_dht.DHT22(board.D4, use_pulseio=False) | |||
#Earth Humidity | |||
chanel = 21 | |||
GPIO.setmode(GPIO.BCM) | |||
GPIO.setup(chanel, GPIO.IN) | |||
#Camera | |||
#camera.start_preview() | |||
dt = datetime.now() | |||
ts = datetime.timestamp(dt) | |||
#name = "/home/pi/Pictures/{}.jpg".format(ts) | |||
#camera.capture(name) | |||
print("Camera on") | |||
#camera.stop_preview() | |||
#Air Temp&Humidity | |||
temperature_c = dhtDevice.temperature | |||
humidity = dhtDevice.humidity | |||
print("Temp: {:.1f} C Humidity: {}% ".format(temperature_c, humidity)) | |||
#Earth Humidit: | |||
ground_humidity = GPIO.input(chanel) | |||
print("Earth Humitiy: {}".format(ground_humidity)) | |||
#Brightness Sensor | |||
# Read data back from 0x0C(12) with command register, 0x80(128), 2 bytes | |||
# ch0 LSB, ch0 MSB | |||
data = bus.read_i2c_block_data(0x39, 0x0C | 0x80, 2) | |||
# Read data back from 0x0E(14) with command register, 0x80(128), 2 bytes | |||
# ch1 LSB, ch1 MSB | |||
data1 = bus.read_i2c_block_data(0x39, 0x0E | 0x80, 2) | |||
# Convert the data | |||
ch0 = data[1] * 256 + data[0] | |||
ch1 = data1[1] * 256 + data1[0] | |||
light_intesity = ch0-ch1 | |||
# Output data to screen | |||
print("Visible Value :%d lux" %(ch0 - ch1)) | |||
return {"Air_Temperature": temperature_c, | |||
"Air_Humidity": humidity, | |||
"Ground Humidity": ground_humidity, | |||
"Light_Intensity": light_intesity | |||
} | |||
def main(): | |||
test = readSensors() | |||
if __name__ == "__main__": | |||
main() |
@@ -0,0 +1,14 @@ | |||
from picamera import PiCamera | |||
from time import sleep | |||
from datetime import datetime | |||
camera = PiCamera() | |||
camera.start_preview() | |||
dt = datetime.now() | |||
ts = datetime.timestamp(dt) | |||
name = "/home/pi/Pictures/{}.jpg".format(ts) | |||
camera.capture(name) | |||
camera.stop_preview() |
@@ -0,0 +1,29 @@ | |||
import time | |||
import board | |||
import adafruit_dht | |||
# connect Device | |||
dhtDevice = adafruit_dht.DHT22(board.D4, use_pulseio=False) | |||
# you can pass DHT22 use_pulseio=False if you wouldn't like to use pulseio. | |||
# This may be necessary on a Linux single board computer like the Raspberry Pi, | |||
# but it will not work in CircuitPython. | |||
# dhtDevice = adafruit_dht.DHT22(board.D18, use_pulseio=False) | |||
while True: | |||
try: | |||
# Print the values to the serial port | |||
temperature_c = dhtDevice.temperature | |||
humidity = dhtDevice.humidity | |||
print("Temp: {:.1f} C Humidity: {}% ".format(temperature_c, humidity)) | |||
except RuntimeError as error: | |||
# Errors happen fairly often, DHT's are hard to read, just keep going | |||
print(error.args[0]) | |||
time.sleep(2.0) | |||
continue | |||
except Exception as error: | |||
dhtDevice.exit() | |||
raise error | |||
time.sleep(2.0) |
@@ -0,0 +1,19 @@ | |||
import RPi.GPIO as GPIO | |||
import time | |||
chanel = 21 | |||
GPIO.setmode(GPIO.BCM) | |||
GPIO.setup(chanel, GPIO.IN) | |||
def callback(chanel): | |||
if GPIO.input(chanel): | |||
print("No water detected") | |||
else: | |||
print("Water detected") | |||
print(GPIO.input(chanel)) | |||
GPIO.add_event_detect(chanel, GPIO.BOTH, bouncetime=300) | |||
GPIO.add_event_callback(chanel, callback) | |||
callback(chanel) |
@@ -0,0 +1,33 @@ | |||
import smbus | |||
import time | |||
# Get I2C bus | |||
bus = smbus.SMBus(1) | |||
# TSL2561 address, 0x39(57) | |||
# Select control register, 0x00(00) with command register, 0x80(128) | |||
# 0x03(03) Power ON mode | |||
bus.write_byte_data(0x39, 0x00 | 0x80, 0x03) | |||
# TSL2561 address, 0x39(57) | |||
# Select timing register, 0x01(01) with command register, 0x80(128) | |||
# 0x02(02) Nominal integration time = 402ms | |||
bus.write_byte_data(0x39, 0x01 | 0x80, 0x02) | |||
time.sleep(0.5) | |||
# Read data back from 0x0C(12) with command register, 0x80(128), 2 bytes | |||
# ch0 LSB, ch0 MSB | |||
data = bus.read_i2c_block_data(0x39, 0x0C | 0x80, 2) | |||
# Read data back from 0x0E(14) with command register, 0x80(128), 2 bytes | |||
# ch1 LSB, ch1 MSB | |||
data1 = bus.read_i2c_block_data(0x39, 0x0E | 0x80, 2) | |||
# Convert the data | |||
ch0 = data[1] * 256 + data[0] | |||
ch1 = data1[1] * 256 + data1[0] | |||
# Output data to screen | |||
print("Full Spectrum(IR + Visible) :%d lux" %ch0) | |||
print("Infrared Value :%d lux" %ch1) | |||
print("Visible Value :%d lux" %(ch0 - ch1)) |
@@ -0,0 +1,21 @@ | |||
from pybricks.hubs import EV3Brick | |||
from pybricks.ev3devices import Motor | |||
from pybricks.parameters import Port | |||
#from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank | |||
# Initialize the EV3 brick. | |||
ev3 = EV3Brick() | |||
# Initialize a motor at port B. | |||
test_motor = Motor(Port.B) | |||
#test = ev3dev2.motor.LargeMotor('/dev/ttyAMA0') | |||
#test.on(500) | |||
# Run the motor up to 500 degrees per second, for 2 seconds. | |||
test_motor.run_time(500, 2000) | |||
# Stop the motor. | |||
test_motor.stop() | |||
# Beep to indicate that the program has finished. | |||
ev3.speaker.beep() |
@@ -0,0 +1,132 @@ | |||
Adafruit-Blinka==8.15.2 | |||
adafruit-circuitpython-busdevice==5.2.3 | |||
adafruit-circuitpython-dht==3.7.8 | |||
adafruit-circuitpython-requests==1.13.0 | |||
adafruit-circuitpython-tsl2561==3.3.15 | |||
adafruit-circuitpython-typing==1.8.3 | |||
Adafruit-GPIO==1.0.3 | |||
Adafruit-PlatformDetect==3.40.3 | |||
Adafruit-PureIO==1.1.10 | |||
altgraph==0.17.3 | |||
arandr==0.1.10 | |||
astroid==2.5.1 | |||
asttokens==2.0.4 | |||
automationhat==0.2.0 | |||
beautifulsoup4==4.9.3 | |||
blinker==1.4 | |||
blinkt==0.1.2 | |||
buttonshim==0.0.2 | |||
Cap1xxx==0.1.3 | |||
certifi==2022.12.7 | |||
cffi==1.15.1 | |||
chardet==4.0.0 | |||
charset-normalizer==3.0.1 | |||
click==8.1.3 | |||
colorama==0.4.4 | |||
colorzero==1.1 | |||
cryptography==3.3.2 | |||
cupshelpers==1.0 | |||
dbus-python==1.2.16 | |||
distro==1.5.0 | |||
docutils==0.16 | |||
drumhat==0.1.0 | |||
envirophat==1.0.0 | |||
ExplorerHAT==0.4.2 | |||
Flask==2.2.3 | |||
fourletterphat==0.1.0 | |||
gpiozero==1.6.2 | |||
html5lib==1.1 | |||
idna==3.4 | |||
importlib-metadata==6.0.0 | |||
isort==5.6.4 | |||
itsdangerous==2.1.2 | |||
jedi==0.18.0 | |||
Jinja2==3.1.2 | |||
lazy-object-proxy==0.0.0 | |||
logilab-common==1.8.1 | |||
lxml==4.6.3 | |||
MarkupSafe==2.1.2 | |||
mccabe==0.6.1 | |||
microdotphat==0.2.1 | |||
mote==0.0.4 | |||
motephat==0.0.3 | |||
mypy==0.812 | |||
mypy-extensions==0.4.3 | |||
numpy==1.19.5 | |||
oauthlib==3.1.0 | |||
pantilthat==0.0.7 | |||
parso==0.8.1 | |||
pexpect==4.8.0 | |||
pgzero==1.2 | |||
phatbeat==0.1.1 | |||
pianohat==0.1.0 | |||
picamera==1.13 | |||
picamera2==0.3.8 | |||
pidng==4.0.9 | |||
piexif==1.1.3 | |||
piglow==1.2.5 | |||
pigpio==1.78 | |||
Pillow==8.1.2 | |||
psutil==5.8.0 | |||
pybricks==3.2.0 | |||
pycairo==1.16.2 | |||
pycparser==2.21 | |||
pycups==2.0.1 | |||
pyftdi==0.54.0 | |||
pygame==1.9.6 | |||
Pygments==2.7.1 | |||
PyGObject==3.38.0 | |||
pyinotify==0.9.6 | |||
pyinstaller==5.8.0 | |||
pyinstaller-hooks-contrib==2023.0 | |||
PyJWT==1.7.1 | |||
pylint==2.7.2 | |||
PyOpenGL==3.1.5 | |||
pyOpenSSL==20.0.1 | |||
PyQt5==5.15.2 | |||
PyQt5-sip==12.8.1 | |||
pyserial==3.5b0 | |||
pysmbc==1.0.23 | |||
python-apt==2.2.1 | |||
python-ev3dev==1.2.0 | |||
python-ev3dev2==2.1.0.post1 | |||
python-prctl==1.7 | |||
pyusb==1.2.1 | |||
rainbowhat==0.1.0 | |||
reportlab==3.5.59 | |||
requests==2.28.2 | |||
requests-oauthlib==1.0.0 | |||
responses==0.12.1 | |||
roman==2.0.0 | |||
rpi-ws281x==4.3.4 | |||
RPi.GPIO==0.7.0 | |||
RTIMULib==7.2.1 | |||
scrollphat==0.0.7 | |||
scrollphathd==1.2.1 | |||
Send2Trash==1.6.0b1 | |||
sense-hat==2.4.0 | |||
simplejpeg==1.6.4 | |||
simplejson==3.17.2 | |||
six==1.16.0 | |||
skywriter==0.0.7 | |||
smbus==1.1.post2 | |||
smbus-cffi==0.5.1 | |||
sn3218==1.2.7 | |||
soupsieve==2.2.1 | |||
spidev==3.5 | |||
ssh-import-id==5.10 | |||
sysv-ipc==1.1.0 | |||
thonny==4.0.1 | |||
toml==0.10.1 | |||
touchphat==0.0.1 | |||
tsl2561==3.4.0 | |||
twython==3.8.2 | |||
typed-ast==1.4.2 | |||
typing_extensions==4.5.0 | |||
unicornhathd==0.0.4 | |||
urllib3==1.26.14 | |||
v4l2-python3==0.3.1 | |||
webencodings==0.5.1 | |||
Werkzeug==2.2.3 | |||
wrapt==1.12.1 | |||
zipp==3.15.0 |
@@ -0,0 +1,2 @@ | |||
python 3.8.2 | |||
python 2.7.18 |
@@ -0,0 +1,11 @@ | |||
certifi==2022.12.7 | |||
charset-normalizer==3.0.1 | |||
click==8.1.3 | |||
Flask==2.2.3 | |||
idna==3.4 | |||
itsdangerous==2.1.2 | |||
Jinja2==3.1.2 | |||
MarkupSafe==2.1.2 | |||
requests==2.28.2 | |||
urllib3==1.26.14 | |||
adafruit-circuitpython-dht==3.7.8 |
@@ -0,0 +1 @@ | |||
print("Hello World") |