I am not able to figure out what is the problem just 30 min before it was working fine.
Hii @nakuldubey0601
Exactly the same happened with me . This happens because there is a connection error . If you want to check then write
print(data)
Above the line of " sensor value is"
You will see a connection error
This is because the Virtual box is not getting the internet connection properly. Check ur internet connection and update all the packages by the command
Sudo apt-get -y update
And now run the code
I hope this will work.
@nakuldubey0601 its internet bro…I think your bolt device got disconnected check if green led is still glowing.
IF it is then
check your laptop’s connection maybe that got disconnected.
But its no other reason, only INTERNET issue.
I am facing the same issue even after checking my internet connection. The green led is glowing, but still I’m getting the error. Kindly let me know what I can do to resolve the error.
Hi @jebo22mca,
The error you’re encountering is due to a KeyError when trying to access the ‘value’ field from the JSON response. The KeyError is raised because the field is incorrectly named as 'value ’ (with a space at the end) in the code.
To resolve this issue, you should remove the extra space in the field name. Here’s the corrected line in your code:
Change this line:
print("Sensor value is: " + str(data['value ']))
to
print("Sensor value is: " + str(data['value']))
After making this change, your code should work correctly without the KeyError.
The error you are facing results from a KeyError triggered while attempting to access the ‘value’ field in the JSON response. This KeyError occurs because the field is erroneously named 'value ’ (with a space at the end) in your code.
To rectify this issue, it is necessary to eliminate the extra space in the field name. Please adjust the specified line in your code as follows:
Change this line:
pythonCopy code
print("Sensor value is: " + str(data['value ']))
to
pythonCopy code
print("Sensor value is: " + str(data['value']))
By implementing this modification, your code should function correctly, resolving the KeyError.