from machine import I2C, Pin
from time import sleep
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
# LCD I2C configuration
I2C_ADDR = 0x27
I2C_NUM_ROWS = 2
I2C_NUM_COLS = 16
# I2C initialization for (Sensora) Raspberry Pi Pico
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS)
# Display message on LCD at specified position
def lcd_str(message, col, row):
lcd.move_to(col, row)
lcd.putstr(message)
# Main loop simulates API notification
while True:
lcd.clear()
lcd_str("Visitor Alert!", 0, 0)
lcd_str("Sending to API", 0, 1)
# Simulate API call to Laravel backend
print("🔔 Sending POST request to Laravel API: { 'event': 'visitor_detected' }")
# Delay before next notification
sleep(5)