Sign inSign up

2smartdev/raspberry

By 2smartdev

•Updated about 5 years ago

Image
0

1.9K

2smartdev/raspberry repository overview

⁠Raspberry Pi GPIO Bridge

This is a virtual device for the 2Smart Cloud⁠ platform, it provides you ability to control and read state from Raspberry Pi GPIO. You could run this device on any Raspberry Pi version and connect it to your mobile account of 2Smart Cloud mobile application.

You can install the 2Smart Cloud mobile application in the App Store⁠ or Play Market⁠.

⁠Instruction to run ready-to-use virtual device
  1. Create the config.json file and insert data below:
{
    "mqttUri":"mqtt://cloud.2smart.com:1883",
    "wssUri":"wss://cloud.2smart.com/mqtt",
    "userEmail":"",
    "productId":1617262851233026,
    "token":"",
    "deviceId":"",
    "firmwareVersion":"2"
}
  1. Insert your user email into userEmail field and device access token into token field. You could get this parameters in Account settings screen in the 2Smart Cloud⁠ mobile application.
  2. Run the following command to start the device:
docker run --name raspberry-gpio --privileged --restart always --privileged -d -v "${PWD}:/config" 2smartdev/raspberry

The device will appear in your mobile application in a few seconds.

⁠Instruction to create your own product based on Raspberry Pi GPIO Bridge

  1. Register a vendor acccount on 2Smart Cloud⁠ platform and create a product based on Raspberry Pi MCU. Look throught more about platform here https://2smart.com⁠

  2. Download the device connection data from your product's hub or wizard in the 2Smart Cloud vendor interface. To do this in the “Connection info” modal window choose the Configuration file and download it for the target environment("production" or "sandbox").

  3. Open the directory with this file in the terminal. If you downloaded the "production" configuration file then the "token" field would be empty, read the "Retrieve production token" topic to get this token and paste its value.

(Important: if you downloaded both "production" and "sandbox" configuration files, then they must be located in different directories because they have the same name).

  1. Run the following command to start the device:
docker run --name raspberry-gpio --restart always --privileged -d -v "${PWD}:/config" 2smartdev/raspberry

⁠Additional configuration

A configuration file consists of the following required fields and must have the name "config.json" :

{
  "mqttUri": "",
  "userEmail": "",
  "productId": "",
  "token": "",
  "deviceId": ""
}

Fill each field according to the next descriptions:

  • mqttUri - a production or sandbox 2smart-cloud app URI
  • userEmail - an email related to your account
  • productId - a product's ID
  • token - a 2smart-cloud access token(sandbox or production), if you downloaded the production configuration file, then this field would be empty, read the "Retrieve production token" topic to get this token, then paste it here
  • deviceId - a device ID, leave it empty if your entered production MQTT URI, it will be generated automatically

⁠Custom virtual devices

Raspberry Pi GPIO Bridge is based on public 2Smart Cloud SDK, which allow to configure firmware of your device in the fastest way. Example of the same device you can find in public repository⁠ or find full information about SDK here⁠

⁠Stopping and restarting the device

Run the following command to find the container id of the device:

docker ps

Find the record where "IMAGE" column equals "2smartdev/raspberry-system-monitor" and copy the value of "CONTAINER ID" column for this record

⁠Stop the device

Run the following command with the retrieved container id to stop the device:

docker stop <container id>
⁠Restart the device

Run the following command with the retrieved container id to restart the device:

docker restart <container id>

Tag summary

Content type

Image

Digest

Size

141.3 MB

Last updated

over 5 years ago

docker pull 2smartdev/raspberry