availableGPIO = # Construct Losant device device = Device ( "my-device-id", "my-app-access-key", "my-app-access-secret" ) def on_command ( device, command ): print ( command + " command received." ) # Listen for the gpioControl. # This key is the GPIO number and the value is the peripheral to control. Import json from gpiozero import LED # Import GPIO library: from time import sleep from losantmqtt import Device # Import Losant library: # We need to describe what GPIO is available to control. Devices can contain many sensors or attached peripherals. In Losant, a device could be Raspberry Pi, Arduino, smart bulb, or any custom hardware. Log in and create an application in Losant. Losant is an easy-to-use and powerful developer platform designed to help you quickly build connected applications.ġ. You can obtain the device ID, access key, and access secret from Losant. We still need to configure one line of the code before we can run: device = Device("my-device-id", "my-app-access-key", "my-app-access-secret") You can see the contents of this file in the Code section. In the folder, you'll see a file named "index.py". Using Git, clone the code from GitHub : git clone Ĭhange to the new project directory: cd example-raspberry-pi-api Next, install the libraries we need: sudo apt-get install git python-pip python-gpiozero python-pkg-resources To begin, we'll need to make sure our device is updated and the proper libraries are installed.įirst, let's update our Pi: sudo apt-get upgrade & sudo apt-get update If you need help with this, check out this tutorial. Unlike typical Pi setups, we can do this without a monitor. First, we'll need to set up our Raspberry Pi Zero W.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |