Inky PHAT - new location

I think that code you posted is Python maybe? Which you’d have to run from idle?
You need the correct original formatting though, indents etc to copy and past and run it without any errors.

Thanks
I ran https://ipinfo.io/ off my iPhone and it provides a fair bit of information. Location is way off but I think I’ll opt for a reasonably sized, close and unique location and see what happens, I can always revert back to Sheffield.
The code probably is Python I don’t know enough yet to even guess.
Thanks

It uses your IP address to get the info. Your WAN IP address. Access that site from a PC on your home network and it will reference the public WAN IP your ISP gave you for the info. That should get you the correct Country, City info etc to use on the PI on that network.

Probably a bit late to the party on this one.

I have a static IP, courtesy of my ISP.

They are based in the Pimoroni hometown of Sheffied, which is where any IP location service will resolve too.

It’s 230 miles from my house.

:-)

Ah, Ok, that puts a wrinkle in things, lol. My ISP is located in the same city I live in so my info is good, as near as I can tell anyway.

You should be able to find your alpha-2 ISO country code here at Wikipedia, and then use the nearest decent-sized city or town as the city.

230m! Not quite that far but too far to be of any good.
I tried changing from Sheffield to the ISP location (still 30+ miles out) and to a more local city but running the example code just threw a wobbly. Surely it can’t be that hard to change the physical location?
BB

If I had a normal, dynamically ISP assigned IP, then it would probably resolve my location to somewhere in London, where the internet backbone and my ISP’s routers are.

That’s a mere 90 (ish) miles

Probably best to hard-code it.

;-)

When you say it threw a wobbly, what did it do? Was there a useful error?

OK, so delving into geolocation a little bit…

The reason people like Google know where you are, is because they:

  • Know when you have connected to them via you router and its MAC address.
  • Know when others have done the same via their routers.
  • Nearby routers and MAC address (although unconnected, but broadcasting) + signal strength = distance from them.
  • Map all of that out.

If that sounds far fetched you can make calls yourself to the Google Geolocation API using Python.

Not done this myself but it looks interesting.

Simon.

Not sure how the Yahoo weather API works, but it probably looks here (or something similar):

https://www.metoffice.gov.uk/public/weather/climate-network/#?tab=climateNetwork

So, I would chose the nearest place with a weather station, which is not necessarily the nearest town.

Cheers,

Simon.

I changed “Sheffield” to “Worcester”
here:
CITY = “Worcester”
COUNTRYCODE = “GB”
WARNING_TEMP = “25”

And this was the result:

pi@raspberrypi:~ cd /home/pi/Pimoroni/inky/examples pi@raspberrypi:~/Pimoroni/inky/examples python weather-phat.py --colour “black”
python: can’t open file ‘weather-phat.py’: [Errno 2] No such file or directory

But I notice this line further up:

print("""Inky pHAT: Weather

Displays weather information for a given location. The default location is Sheffield-on-Sea.

Do both need changing?
BB

It looks like this is because Yahoo have “retired” their free weather API and replaced it with an RSS feed API to which you have to sign up for access. :-(

https://developer.yahoo.com/weather/?guccounter=1

We’ll look into alternatives to get this working again.

1 Like

I should have this fixed in the morning. I’ve re-implemented it by scraping the data straight from Dark Sky. :-)

1 Like

This branch of the Inky library should fix the problem. It’ll be merged in sometime today, hopefully, but you can give it a try now, if you like, by doing the following in the terminal:

sudo apt-get install libxml2-dev libxslt-dev python-dev python3-lxml python-lxml
sudo pip install geocoder beautifulsoup4
git clone https://github.com/pimoroni/inky.git
cd inky
git checkout weather-fix
cd library
sudo python setup.py install
cd ../examples/phat
./weather-phat.py -c red

Or, y’know, just wait a little while and then use the one-line installer :-D

1 Like

Hmm, I get :

Traceback (most recent call last):
File “./weather-phat.py”, line 9, in
from font_fredoka_one import FredokaOne
ImportError: No module named font_fredoka_one

pip install font-fredoka-one
;-)

Just tried the above to fix this issue on a yellow inkyphat and this is what i get when running “./weather-phat.py -c yellow”

    Inky pHAT: Weather

Displays weather information for a given location. The default location is Sheffield-on-Sea.


Traceback (most recent call last):
  File "./weather-phat.py", line 42, in <module>
    inky_display = InkyPHAT(colour)
  File "/usr/local/lib/python2.7/dist-packages/inky/phat.py", line 27, in __init__
    v_flip=False)
  File "/usr/local/lib/python2.7/dist-packages/inky/inky.py", line 74, in __init__
    self.eeprom = eeprom.read_eeprom()
  File "/usr/local/lib/python2.7/dist-packages/inky/eeprom.py", line 103, in read_eeprom
    i2c = SMBus(1)
  File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 253, in __init__
    self.open(bus)
  File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 265, in open
    self.fd = os.open("/dev/i2c-{}".format(bus), os.O_RDWR)
OSError: [Errno 2] No such file or directory: '/dev/i2c-1'

What am I missing here?

If i2c isn’t enabled try turning it on and see what happens? It doesn’t make any sense to me, but that seems to be a possible solution based on another thread I read today. If that doesn’t fix it, you’ll have to wait for somebody else to chime in with a possible solution.

DUh! Thank you man, turned it on… works as it should!