microsoft / pi-azure-recipes

Collection of quickstart guides using a Raspberry Pi and Azure services
MIT License
22 stars 8 forks source link

KeyError when running client.py #6

Open ElwoodPowerBI opened 3 years ago

ElwoodPowerBI commented 3 years ago

I got to the step where I ran the "python3 raspberry_pi_client.py" command but I am seeing a KeyError, shown in attached png.

image

jenfoxbot commented 3 years ago

Hello! Thanks for reaching out. Did you update the device connection string via the python_environment_setup.sh shell script? (Steps 6 - 8 under "Set up your Raspberry Pi" in the ReadMe)

ElwoodPowerBI commented 3 years ago

@jenfoxbot I tried to run the script, but was getting an error. So I was copying each command into the prompt and when I changed "python" to "python3" command ran. But then the connection string was the issue, so I unhid and found the .env file and tried copying the connection string there. some screenshots below image

image

jmlp1 commented 2 years ago

@lmgeorge Hi there, I am having similar issues, had to break down the script into steps for creating the .env file

Once done I executed the source command, which I think is successful, however every time I tried to run the py script got the same error does not matter if executing as python or python3 any thoughts?

image

jmlp1 commented 2 years ago

I figured out the first part of the problem, I was executing the python_environment_setup.sh with sh instead of using bash, which fixed the first script running issue, however still having problems with the python script

jmlp1 commented 2 years ago

A little bit of perseverance and got it working, from raspberry_pi_client.py had to comment

Once done telemetry started working and receiving data

image image image

jmlp1 commented 2 years ago

Successfully connected a Raspberry Pi to Azure IoT Central, which via an MS Power Automate WorkFlow Rule sends alerts to D365 Field Service, just brilliant image