This example presents field data from sensor BME280 connecting to cloud, mbed Device Connector.
Please read details at the link. https://github.com/soramame21/connector-api-python-quickstart_4BME280
README.md@1:b194c28a1670, 2017-08-23 (annotated)
- Committer:
- Ren Boting
- Date:
- Wed Aug 23 14:08:23 2017 +0900
- Revision:
- 1:b194c28a1670
- Parent:
- 0:a9bcda5b678a
Refined the application and update logo.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edamame22 | 0:a9bcda5b678a | 1 | # connector-api-python-quickstart_4BME280 |
edamame22 | 0:a9bcda5b678a | 2 | This is a quickstart application for the [mbed-connector-api-python](https://github.com/armmbed/mbed-connector-api-python) package. |
edamame22 | 0:a9bcda5b678a | 3 | The goal of this application is to get the user up and running, using the mbed-connector-python package and talking to devices through mbed Device Connector in under 5 min, 5 steps or less. |
edamame22 | 0:a9bcda5b678a | 4 | The quickstart webapp is meant to be paired with the [BLEClient_mbedDevConn](https://github.com/soramame21/BLEClient_mbedDevConn) and the [BLE_Server_BME280](https://github.com/soramame21/BLE_Server_BME280). The quickstart web app will allow the user to see measured sensor value through Device Connector. |
edamame22 | 0:a9bcda5b678a | 5 | |
edamame22 | 0:a9bcda5b678a | 6 | ### Pre-requisites |
edamame22 | 0:a9bcda5b678a | 7 | - A [mbed connector](https://connector.mbed.com) account and have generated an [API token](https://connector.mbed.com/#accesskeys) |
edamame22 | 0:a9bcda5b678a | 8 | - A endpoint running the [BLEClient_mbedDevConn](https://github.com/soramame21/BLEClient_mbedDevConn) |
edamame22 | 0:a9bcda5b678a | 9 | - A device running the [BLE_Server_BME280](https://github.com/soramame21/BLE_Server_BME280) for BLE broadcasting data on field |
edamame22 | 0:a9bcda5b678a | 10 | - Install the required packages `pip install -r requirements.txt` |
edamame22 | 0:a9bcda5b678a | 11 | |
edamame22 | 0:a9bcda5b678a | 12 | ### Use |
edamame22 | 0:a9bcda5b678a | 13 | 1. Put your [API key](https://connector.mbed.com/#accesskeys) into the app.py file, replace the following text |
edamame22 | 0:a9bcda5b678a | 14 | ```python |
edamame22 | 0:a9bcda5b678a | 15 | token = "Change Me" # replace with your API token |
edamame22 | 0:a9bcda5b678a | 16 | ``` |
edamame22 | 0:a9bcda5b678a | 17 | or set an evironment variable called `ACCESS_KEY` with the value of your API key |
edamame22 | 0:a9bcda5b678a | 18 | 2. Run the `app.py` file |
edamame22 | 0:a9bcda5b678a | 19 | ```python |
edamame22 | 0:a9bcda5b678a | 20 | python ./app.py |
edamame22 | 0:a9bcda5b678a | 21 | ``` |
edamame22 | 0:a9bcda5b678a | 22 | 3. Open a web page to the web.py server. Usually [http://localhost:8080](http://localhost:8080) will work. |
edamame22 | 0:a9bcda5b678a | 23 | 4. Touch BME280 by finger to see temperature and humidity change on the web app. |
edamame22 | 0:a9bcda5b678a | 24 | 5. Modify : go checkout the API for the [mbed-connector-api-python library](https://docs.mbed.com/docs/mbed-connector-api-python/en/latest/) and make your own applications! |
edamame22 | 0:a9bcda5b678a | 25 | |
edamame22 | 0:a9bcda5b678a | 26 | Make sure `\views\index.hbs` file is encoded as UTF8. |
edamame22 | 0:a9bcda5b678a | 27 | |
edamame22 | 0:a9bcda5b678a | 28 | ## Troubleshooting |
edamame22 | 0:a9bcda5b678a | 29 | Here are some common problems and their solutions. |
edamame22 | 0:a9bcda5b678a | 30 | |
edamame22 | 0:a9bcda5b678a | 31 | ##### Cannot establish a secure connection |
edamame22 | 0:a9bcda5b678a | 32 | This is most likely caused by not having the `requests[security]` package installed. If you are using Ubuntu 14.4 LTS you may need to update pip first `pip install -U pip` and then install the requests security package `pip install -U requests[security]`. |
edamame22 | 0:a9bcda5b678a | 33 | |
edamame22 | 0:a9bcda5b678a | 34 | ##### WebSocket transport not available |
edamame22 | 0:a9bcda5b678a | 35 | Dont worry about that warning message, it is not applicable to this demo, but likewise the warning message cannot be disabled. |
edamame22 | 0:a9bcda5b678a | 36 | |
edamame22 | 0:a9bcda5b678a | 37 | ##### ERROR 500 on trying to run the app.py file |
edamame22 | 0:a9bcda5b678a | 38 | Make sure you added your [Access Key](https://connector.mbed.com/#accesskeys) to the app. You can do this by either changing the value of the `token` variable in the app.py file or by setting the `ACCESS_KEY` environment variable to your access key. |
edamame22 | 0:a9bcda5b678a | 39 | |
edamame22 | 0:a9bcda5b678a | 40 | ## Screenshot |
edamame22 | 0:a9bcda5b678a | 41 | ![Screenshot of Demo](./static/img/python_BME280_screenshot.png) |