Git Product home page Git Product logo

pi-azure-recipes's Introduction

Raspberry Pi Recipes for Azure

Overview

Raspberry Pi recipes for Azure is a collection of samples that use use a Raspberry Pi and one or more Azure services. All the recipes included here represent end to end scenarios rather than just documenting how to interface with a single service. These are all written to get you up and running fast. Most take between 5 and 30 minutes to complete and require the least amount of hardware. All is code is designed to be adapted into other project, and many of these recipes can be combined.

If there is something you'd like to know how to do using Azure and a Raspberry Pi and you don't see it here open an issue and let us know. If you know how to do something cool with Azure and a Raspberry Pi open a PR and show us what you got!

Note: We do our best to minimize the cost of services, but some of these samples will incur a small charge on your Azure account.

Prerequisites

  1. Free Azure Account
  2. Basic understanding on Python
  3. Raspberry Pi 3 or 4
  4. Monitor/keyboard/mouse or ability to SSH into the Pi

Contents

Recipe Description Time Prerequisites
01 IoT Hub d2c Send telemetry to Azure table storage using IoT Hub and Azure functions. 25 Mins None
02 IoT Hub c2d Trigger events on your Raspberry Pi using Azure functions and IoT Hub 15 mins None
03 Computer Vision Use the computer vision cognitive service to detect objects in an image 20 Mins None
04 IoT Central Connect and control a Raspberry Pi with IoT Central 30 Mins None

Resources

Raspberry Pi Resources Repo

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

If you know how to do something cool with a Raspberry Pi and Azure we'd love to see it! To contribute open a PR with your additions and someone from the team will review it.

Guidelines

  • Keep all of the file for each example in it own directory. Using this format: 01_example_name
  • Include a readme with instructions on how to setup the example
  • If you would like to use images in your readme they should referenced not uploaded to this repo
  • Include an estimated cost for the Azure resources
  • When possible and practical use one programing language for the whole example
  • Use flake8 to lint Python code
  • Examples should be secure by default, meaning connection strings and api key can't be checked in by accident. To do this we wrote a shell script that generate .env files that the user populates with their keys.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

pi-azure-recipes's People

Contributors

adiazulay avatar dependabot[bot] avatar firedog1024 avatar jenfoxbot avatar lmgeorge avatar microsoftopensource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-azure-recipes's Issues

Add code comments

Suggest adding code comments to all sample code in pi recipes b/c it will help folks modify and adapt for custom scenarios.

Pi Recipes #3 Updates: Test Function locally section

Deploying the function locally needs updates to ensure it's not broken.
Function executed as expected, but did not see the output as indicated in the instructions. Pulling the URL from instructions did work and generated a 'device is on' message output on the Pi.

No telemetry transmission

In RAW DATA and Overview - no telemetry data.

In RaspberryPi it only displays:

pi@raspberrypi:~ $ cd client
pi@raspberrypi:/client $ source ./.venv/bin/activate
(04_iot_central) pi@raspberrypi:
/client $ python raspberry_pi_client.py
Press Q to quit
Sending reported property: {'remaining_disk_space': '19G'}

Errors are displayed when the program is interrupted by Q.

Press Q to quit
q
Quitting...
Traceback (most recent call last):
File "/home/pi/client/raspberry_pi_client.py", line 296, in
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/pi/client/raspberry_pi_clie

nt.py", line 288, in main
await asyncio.gather(telemetry_loop, reported_loop)
File "/home/pi/client/raspberry_pi_client.py", line 161, in send_telemetry
payload = f'{{"cpu_temp": {get_current_cpu_temp()}, "cpu_freq": {get_cpu_frequency_statistics()["current"]}, "cpu_usage": {get_cpu_usage()}, "ram_usage": {get_memory_statistics()["used"]}}}'
File "/home/pi/client/raspberry_pi_client.py", line 91, in get_cpu_usage
return float(cpu_usage)

ValueError: could not convert string to float: ''
Task was destroyed but it is pending!

Please, can you tell me where this error came from ?
"line 91, in get_cpu_usage
return float(cpu_usage)**
ValueError: could not convert string to float: ''"

About, Commands - works ok.

raw_data
Overwiew

Pi Recipe #3 Updates: Testing CV on the Pi

For folks using SSH, a camera preview isn't possible. Suggest adding in some commentary around how to handle this (maybe folks could use a desktop viewer over SSH?).

Pi Recipe #2 updates: Prep environment section

Errors and clarification for Pi Recipe #2 Prep environment section:
step 4: recipe has been renamed, need to update folder name
step 5: keyboard shortcut doesn't work on windows PC
step 9: before this step, folks are asked about creating a virtual environment and need to indicate 'Yes'

Pi Recipe #2 Updates: Setup IoT Hub section

Step 3: Suggest rephrasing b/c as-is it's confusing. IoT Hub is at the bottom of the page. Options menu, '...' is on that bottom tab.
Step 8: Unclear what folder folks should look in for the local.settings.json file
Step 11: We don't have a device ID at this stage, that is done in the next section. Suggest moving this to after Device ID is added. (Or making sure that what folks put here is used for the next section)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.