i want to submit a value from my website to a python script. ive got a raspberry pi, running with apche2 and php7. there is an light sensor connected and my script does switch on or off a light, when a definid value has reached. is it possible, to change the value of an running python script through my website with php?
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import smbus
import time
import RPi.GPIO as gpio
gpio.setwarnings(False)
gpio.setmode(gpio.BOARD)
gpio.setup(29, gpio.OUT)
gpio.output(29, gpio.HIGH)
while True:
lux = 200
bus = smbus.SMBus(1)
bus.write_byte_data(0x39, 0x00 | 0x80, 0x03)
bus.write_byte_data(0x39, 0x01 | 0x80, 0x02)
time.sleep(0.5)
data = bus.read_i2c_block_data(0x39, 0x0C | 0x80, 2)
data1 = bus.read_i2c_block_data(0x39, 0x0E | 0x80, 2)
ch0 = data[1] * 256 + data[0]
ch1 = data1[1] * 256 + data1[0]
print (ch0 - ch1)
if (ch0 - ch1) < lux:
gpio.output(29, gpio.LOW)
print("Licht AN")
time.sleep(60)
if (ch0 - ch1) > lux:
gpio.output(29, gpio.HIGH)
print("Licht AUS")
time.sleep(60)
thanks, Matthias