Good afternoon, I can’t figure out how to write the code. We read the value from the database, if it exceeds, say, 2000, then we turn on the relay via GPIO.
How to read - I understood.
How to read - I understood.
import struct
import sys
import time
import datetime
import pymysql.cursors
import wiringpi
from wiringpi import GPIO
connection = pymysql.connect(host='127.0.0.1', user='root', password='2548695542', db='sd', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
with connection:
cur = connection.cursor()
cur.execute("SELECT * FROM ddd1 ORDER BY id DESC LIMIT 1")
rows = cur.fetchall()
for row in rows:
print(row["weight"])How to turn on the relay - too.NUM2 = 2 # (wPi-2) orange pi zero 2 wiringpi.wiringPiSetup() wiringpi.pinMode(NUM2, wiringpi.GPIO.OUTPUT); wiringpi.digitalWrite(NUM2, GPIO.HIGH);But I can’t figure out how to connect this together. :-(
