pimoroni / breakout-garden

Documentation, software, and examples for the Breakout Garden ecosystem.
https://shop.pimoroni.com/products/breakout-garden-hat
MIT License
72 stars 14 forks source link

Getting error on Raspberry Pi Zero #5

Closed daniel1979 closed 4 years ago

daniel1979 commented 6 years ago

I'm getting this when weather.py is used as is.

This Pimoroni Breakout Garden example requires a BME680 Environmental Sensor Breakout and a 1.12" OLED Breakout.

This example turns your Breakout Garden into a mini weather display combining indoor temperature and pressure data with a weather icon indicating the current local weather conditions.

Press Ctrl+C a couple times to exit.

Traceback (most recent call last): File "./weather.py", line 152, in code = get_weather_code(location_string) File "./weather.py", line 73, in get_weather_code if "channel" in json_data["query"]["results"]: TypeError: argument of type 'NoneType' is not iterable

What am I doing wrong?

lechemmy commented 6 years ago

The ip lookup is probably returning some empty data. My current IP address is not getting a city or region from the lookup (which would probably should be: res = requests.get('http://ipinfo.io/json') and the code is not checking for empty fields.

To quick fix this issue set your city (line 37) and comment or delete the def get_location(): function (lines 43-48).

daniel1979 commented 6 years ago

Worked like a charm. Thank you. Make sure you know how Yahoo spells your city if you are from non-English country.