Developer Support Iotic Labs

Basic create Thing


This is the most basic Python script needed to hook up a virtual Iotic Thing to an application. It references the py-IoticAgent API, creates the Iotic Thing, and reports that it’s running.


The def connect_thing¬†function checks the Local ID defined in line 16¬†(‘First_Iotic_Thing’), and connects the script to an existing Thing in the Space app if one already exists with that ID, or if not it creates a new Thing.


NOTE: This script references a Thing with the Local ID First_Iotic_Thing, and the file Iotic_Agent.ini. You will need to update these to match your own Thing and .ini.


Python logo

# IMPORTS -------------------------------------------------------------------------------------------------------------
import time

# IOTIC AGENT IMPORTS -------------------------------------------------------------------------------------------------
from IoticAgent import IOT
from IoticAgent.Core.Const import R_FEED

# ---------------------------------------------------------------------------------------------------------------------

def connect_thing(client):
    print("Connecting First Iotic Thing")

    # CREATE THING -----------------------------------------------------------------------------------------------------
    # Note: Calling 'create_thing' connects your script to a virtual Thing if the Local ID (lid) is already in use. If not it creates a new Thing with this lid.
    my_thing = client.create_thing('First_Iotic_Thing') # ** Make sure the Local ID matches your Thing **

    return my_thing

# MAIN -------------------------------------------------------------------------------------------------------------
def main():
    with IOT.Client(config='Iotic_Agent.ini') as client:  # ** Make sure this matches your .ini file **
        my_thing = connect_thing(client)

        while True:
                print("Main running. Press ctrl+c to quit.")
            except KeyboardInterrupt:

# RUN --------------------------------------------------------------------------------------------------

if __name__ == '__main__':

# END --------------------------------------------------------------------------------------------------



Remember, before you can hook your Thing up to code you also need to:


  1. Create a new Iotic Agent in the Space app, and download an .ini file
  2. Assign Things to an Agent
  3. Organise your file directory

By continuing to use the site, you agree to the use of cookies. more information

This website uses cookies via Google Analytics to give you the best browsing experience possible. No personally-identifiable information is collected about you unless you explicitly submit that information on this website. Click "Accept" to continue.