File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ 'adafruitio_00_publish.py'
3
+ ==========================
4
+ Publishes an incrementing
5
+ value to a feed
6
+
7
+ Author(s): Brent Rubell, Todd Treece for Adafruit Industries
8
+ """
9
+ import time
10
+ # Import Adafruit IO REST client.
11
+ from Adafruit_IO import Client , Feed
12
+
13
+ # holds the count for the feed
14
+ run_count = 0
15
+
16
+ # Set to your Adafruit IO key.
17
+ ADAFRUIT_IO_USERNAME = 'YOUR_AIO_USERNAME'
18
+ ADAFRUIT_IO_KEY = 'YOUR_AIO_KEY'
19
+
20
+ # Create an instance of the REST client.
21
+ aio = Client (ADAFRUIT_IO_USERNAME , ADAFRUIT_IO_KEY )
22
+
23
+ # Create a new feed named 'counter'
24
+ feed = Feed (name = "Counter" )
25
+ response = aio .create_feed (feed )
26
+
27
+
28
+ while True :
29
+ print ('sending count: ' , run_count )
30
+ run_count += 1
31
+ aio .send_data ('counter' , run_count )
32
+ # Adafruit IO is rate-limited for publishing
33
+ # so we'll need a delay for calls to aio.send_data()
34
+ time .sleep (3 )
35
+
You can’t perform that action at this time.
0 commit comments