Skip to content

Commit cfb5de9

Browse files
authored
Merge pull request #83 from arduino/update_readme
misc: Update README.md.
2 parents bf1844b + f0dfce0 commit cfb5de9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Arduino IoT Cloud Python client ☁️🐍☁️
2-
This is a Python client for the Arduino IoT cloud, which runs on both CPython and MicroPython. The client supports basic and advanced authentication methods, and provides a user-friendly API that allows the user to connect to the cloud, and create and link local objects to cloud objects with a just a few lines of code.
2+
This is a Python client for the Arduino IoT Cloud, which runs on both CPython and MicroPython. The client supports basic and advanced authentication methods, synchronous and asynchronous modes and provides a user-friendly API that allows users to connect to the cloud and create and link local objects to cloud objects with just a few lines of code.
33

44
## Minimal Example
55
The following basic example shows how to connect to the Arduino IoT cloud using basic username and password authentication, and control an LED from a dashboard's switch widget.
@@ -41,6 +41,23 @@ DEVICE_ID = "" # Provided by Arduino cloud when creating a device.
4141
SECRET_KEY = "" # Provided by Arduino cloud when creating a device.
4242
```
4343

44+
Note that by default, the client runs in asynchronous mode. In this mode, the client takes runs an asyncio loop that updates tasks and records, polls networking events, etc. The client also supports a synchronous mode, which requires periodic client polling. To run the client in synchronous mode, pass `sync_mode=True` when creating a client object and call `client.update()` periodically after connecting. For example:
45+
46+
```Python
47+
# Run the client in synchronous mode.
48+
client = ArduinoCloudClient(device_id=DEVICE_ID, ..., sync_mode=True)
49+
....
50+
client.register("led", value=None)
51+
....
52+
# In synchronous mode, this function returns immediately after connecting to the cloud.
53+
client.start()
54+
55+
# Update the client periodically.
56+
while True:
57+
client.update()
58+
time.sleep(0.100)
59+
```
60+
4461
For more detailed examples and advanced API features, please see the [examples](https://github.com/arduino/arduino-iot-cloud-py/tree/main/examples).
4562

4663
## Testing on CPython/Linux

0 commit comments

Comments
 (0)