Skip to content

Commit a2ec738

Browse files
authored
Merge pull request #1560 from dherrada/webhook_update
Updated webhook plant code
2 parents 5c077fd + 675c6ad commit a2ec738

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

Webhook_Plant_Sensor/code.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
from adafruit_seesaw.seesaw import Seesaw
1515
import busio
1616

17+
# Used to make sure that the Adafruit IO Trigger is only run once when the moisture value is below
18+
# the desired threshold, set in MIN
19+
LOW = False
20+
# The minimum moisture value. If the value is below this number, it will activate the Adafruit IO
21+
# trigger. This number should match the number you set in your Adafruit IO trigger. Feel free
22+
# to mess around and try out different moisture values as how wet this actually is can vary a lot
23+
# depending on where the sensor is and the soil in the pot.
24+
MIN = 500
25+
1726
# Set up moisture sensor with seesaw
1827
i2c_bus = board.I2C()
1928
seesaw = Seesaw(i2c_bus, addr=0x36)
@@ -79,11 +88,9 @@ def message(client, feed_id, payload):
7988
# Connect to Adafruit IO
8089
print("Connecting to Adafruit IO...")
8190
io.connect()
91+
plant_feed = "plant"
8292

8393
START = 0
84-
LOW = False
85-
86-
MIN = 500
8794

8895
while True:
8996
# read moisture level through capacitive touch pad
@@ -94,12 +101,12 @@ def message(client, feed_id, payload):
94101

95102
if touch < MIN:
96103
if not LOW:
97-
io.publish("plant", touch)
104+
io.publish(plant_feed, touch)
98105
print("published")
99106
LOW = True
100107

101108
elif touch >= MIN and time.time() - START > 10:
102-
io.publish("plant", touch)
109+
io.publish(plant_feed, touch)
103110
print("published to Adafruit IO")
104111
START = time.time()
105112
LOW = False

0 commit comments

Comments
 (0)