Does anyone know of a simple IOT Cloud Messenger Widget and Python Example that can read and write a word back and forth between an IOT Cloud Messenger Widget and Python?
did you look at the documentation and example ?
Yes, I saw that and gave it a closer look over. Not sure i am seeing the Messenger Widget reading and writing some simple text to python functionality in there. It looks like it was doing some file functions there.
I was able to get some value and boolean widgets reading and writing similar to what is in the following blog on the arduino home page. I was able to get python to write to the messenger widget. I could not get the messenger widget writing to python working though...
Not exact ref below.. but in the blog ref there is some example numerical value and boolean client set up....
Looking for an example that does the same with text and the messenger widget and python.
client.register("test_value", on_read=read_value, interval=10.0)
client.register("button", on_read=read_button, interval=1.0)
client.register("led", value=None, on_write=on_led_changed)
client.start()
Hello!
I figured out how to do a simple example that can read and write text to and from python using the messenger widget. I can enter text in the dashboard messenger widget that gets sent to python. Python then writes back "Msg Received!" to the dashboard messenger widget.
import time
from Credentials import DEVICE_ID
from Credentials import SECRET_KEY
from arduino_iot_cloud import ArduinoCloudClient
client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY, sync_mode=True)
def newmsg_cmd(client, value):
print("new msg from IOTMsgWidget")
print(client["testStr1"])
client["testStr1"] = "Msg Received!"
client.update()
client.register("testStr1", value=None, on_write=newmsg_cmd)
client.start()
while True:
client.update()
time.sleep(0.100)
well done - thanks for sharing.