This commit is contained in:
2025-06-14 10:18:40 +02:00
parent 97a80599d6
commit 1c93f4fae7
8 changed files with 629 additions and 22 deletions

45
pico_files/test.py Normal file
View File

@@ -0,0 +1,45 @@
import urequests
import config
from connection import connection
from machine import Pin
from time import sleep
import random
from machine import Pin, SPI, reset
from camera import *
import gc
wait_pin = Pin(13, Pin.OUT)
good_pin = Pin(15, Pin.OUT)
bad_pin = Pin(14, Pin.OUT)
# Send the POST request with the raw image data as the body
url = f'http://{config.server}:{config.port}/{config.data_path}'
spi = SPI(0,sck=Pin(18), miso=Pin(16), mosi=Pin(19), baudrate=921600) # Pins for the Raspberry Pi Pico
cs = Pin(17, Pin.OUT)
cam = Camera(spi, cs, debug_text_enabled=True)
def send_image(image_file_path):
gc.collect()
cam.capture_jpg()
sleep(3)
image_data = cam.return_image()
headers = {"Content-Type": "image/jpeg"}
response = urequests.post(url, headers=headers, data=image_data)
result = response.json()
response.close()
return result
while connection.isconnected():
good_pin.low()
bad_pin.low()
wait_pin.high()
response = send_image("image.jpg")
print(response)
wait_pin.low()
if response["status"]:
good_pin.high()
else:
bad_pin.high()
sleep(1)