Shop OBEX P1 Docs P2 Docs Learn Events
Can I access information from web pages on my propeller? — Parallax Forums

Can I access information from web pages on my propeller?

Private19872Private19872 Posts: 61
edited 2015-01-14 20:46 in Propeller 1
I had an idea of getting information (primarily weather forecasts) on my propeller and then having it display them. I was wondering if it was possible to get the information from the website onto my propeller without having the propeller connected to my computer.I would imagine that it would involve the Wiznet Ethernet board. Thanks for answering, and if anyone could suggest a website to get the information from that would greatly be appreciated.

Comments

  • ElectrodudeElectrodude Posts: 1,658
    edited 2015-01-10 14:52
    I would recommend using a Wiznet chip. You would have to send an HTTP GET request to your forecast server (I would suggest weather.gov because they have a relatively easy to parse tabular format) and then parse the response. The hardest part would definitely be parsing the response, but this might help:

    Open this in a browser, replacing YOURLAT and YOURLONG with your latitude and logitude:
    http://forecast.weather.gov/MapClick.php?unit=0&lg=english&FcstType=digital&lat=YOURLAT&lon=YOURLONG
    

    View the source and search for <font color="#FF0000" size="1"><b> . The next number will be the current temperature. The number after the nth match will be the temperature in n-1 hours. If you want a field other than temperature, change the color to be the color of whatever field you want. To make this not fail in case they change the colors, find the first color before the title of the field you want and use that for the color.

    Now you just have to write a propeller program to do what you just did yourself.
  • Private19872Private19872 Posts: 61
    edited 2015-01-10 16:31
    Thanks, after a bit of testing I managed to get the website to work. Are there any options for this using Wifi or would I only be able to use a direct Ethernet connection?
  • ElectrodudeElectrodude Posts: 1,658
    edited 2015-01-10 16:48
    There's the XBee wifi module that should work. I've never used wifi on a propeller, so I don't know what else there is. weather.gov doesn't care what you use.

    EDIT: There's also https://developer.forecast.io/ that gives you results in JSON. It's free if you do less than 1000 API calls per day, which should be plenty.
  • Private19872Private19872 Posts: 61
    edited 2015-01-10 16:54
    Alright, I'll look into that. Thanks!
  • FredBlaisFredBlais Posts: 370
    edited 2015-01-10 16:56
    You should get an ESP8266

    Example project
    http://m.instructables.com/id/ESP8266-Wifi-Temperature-Logger/
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2015-01-10 20:27
    +1 to the ESP8266 suggestion. These are the cheapest wifi solution by a large margin.
    A propeller could browse the internet with one of these - we just haven't written the code yet. It should be able to pull data out of the html text stream, eg the actual temperature buried on a weather webpage.
    You can test a lot of things with a simple terminal program and talk to it one line at a time, and after a few instructions it dumps out data off a web page.
  • Private19872Private19872 Posts: 61
    edited 2015-01-11 08:30
    Is that something I can add to the other end of a Wiznet chip or is it just a simple serial interface?
  • ElectrodudeElectrodude Posts: 1,658
    edited 2015-01-11 15:45
    You mean on the propeller side? The propeller can talk directly to the wiznet chip through an SPI interface - there's already a driver for it.
  • Private19872Private19872 Posts: 61
    edited 2015-01-11 17:20
    I was referring to the ESP8266. I wondered if it was just an antenna and I still needed a Wiznet chip or if the ESP8266 was standalone.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-01-11 17:46
    I was referring to the ESP8266. I wondered if it was just an antenna and I still needed a Wiznet chip or if the ESP8266 was standalone.

    BTW, we are playing with extracting information from webpages at present in Tachyon although the emphasis to date has been serving them up. I have my own compact WIZnet modules with an integrated Prop chip so that you can talk to them serially.
    See this thread here.

    Alternatively you can use the base IOT5500 module with your own WIZnet drivers.
  • Private19872Private19872 Posts: 61
    edited 2015-01-11 18:12
    Along with the previous question about the ESP8266, I noticed that the weather website has 70KB of information on it. How do I fit that into the propeller's RAM. Can I request the website line by line from the Wiznet chip or do I need to parse the data on the fly?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-01-11 18:19
    Along with the previous question about the ESP8266, I noticed that the weather website has 70KB of information on it. How do I fit that into the propeller's RAM. Can I request the website line by line from the Wiznet chip or do I need to parse the data on the fly?

    You can parse it as you go line by line etc then discard or cancel what you don't need. I notice that on the local government weather site that it has JSON and CSV files updated every 10 minutes, perhaps you have something similar.

    Here's the first part of the file with the latest observations so it is very easy in Tachyon to have a defined word called "air_temp": that picks this information out seamlessly.
    {
    	"observations": {
    		"notice": [
    			{
    				"copyright": "Copyright Commonwealth of Australia 2015, Bureau of Meteorology. For more information see: http://www.bom.gov.au/other/copyright.shtml http://www.bom.gov.au/other/disclaimer.shtml",
    				"copyright_url": "http://www.bom.gov.au/other/copyright.shtml",
    				"disclaimer_url": "http://www.bom.gov.au/other/disclaimer.shtml",
    				"feedback_url": "http://www.bom.gov.au/other/feedback"
    			}
    		],
    		"header": [
    			{
    				"refresh_message": "Issued at 11:31 pm EST Sunday 11 January 2015",
    				"ID": "IDQ60901",
    				"main_ID": "IDQ60900",
    				"name": "Brisbane",
    				"state_time_zone": "QLD",
    				"time_zone": "EST",
    				"product_name": "Capital City Observations",
    				"state": "Queensland"
    			}
    		],
    		"data": [
    			{
    				"sort_order": 0,
    				"wmo": 94576,
    				"name": "Brisbane",
    				"history_product": "IDQ60901",
    				"local_date_time": "11/11:30pm",
    				"local_date_time_full": "20150111233000",
    				"aifstime_utc": "20150111133000",
    				"air_temp": 25.8,
    				"apparent_t": 30.1,
    				"cloud": "-",
    				"cloud_base_m": null,
    				"cloud_oktas": null,
    				"cloud_type": "-",
    				"cloud_type_id": null,
    				"delta_t": 2.1,
    				"dewpt": 22.7,
    				"gust_kmh": 9,
    				"gust_kt": 5,
    				"lat": -27.5,
    				"lon": 153.0,
    				"press": 1009.3,
    				"press_msl": 1009.3,
    				"press_qnh": 1009.4,
    				"press_tend": "-",
    				"rain_trace": "0.0",
    				"rel_hum": 83,
    				"sea_state": "-",
    				"swell_dir_worded": "-",
    				"swell_height": null,
    				"swell_period": null,
    				"vis_km": "-",
    				"weather": "-",
    				"wind_dir": "NE",
    				"wind_spd_kmh": 4,
    				"wind_spd_kt": 2
    
  • MJBMJB Posts: 1,235
    edited 2015-01-12 15:31
    Along with the previous question about the ESP8266, I noticed that the weather website has 70KB of information on it. How do I fit that into the propeller's RAM. Can I request the website line by line from the Wiznet chip or do I need to parse the data on the fly?
    I experimented with Peter's Tachyon and this 70kB file.
    Since I don'T have the code for the page download running yet, I just loaded the page on the PC and FTP'd it to a Spinnerets SD card running Tachyon.
    So I could experiment with the stream parsing.
    If I assume a fixed file structure - which is a good guess ...
    it is easy to count the '<' start tags before the data I am interrested in i.e. the temperature values in a good editor like notepad++
    So I can easily stream parse for '<' and count the '<'.
    when I hit my target number I skip to the closing '>' then skip some fixed text and there I am.
    Using Tachyons GETWORD NUMBER the temperature gets transfered to a variable or array ...
    then continue for more or close the socket.
    This needs only minimal RAM and is quite fast.
    Doing it the full FORTH way using the Forth input parser and adapting it would be slower, since it requires dictionary lookups.
  • Private19872Private19872 Posts: 61
    edited 2015-01-14 20:46
    After searching a bit more on Wifi options, I found this (https://www.sparkfun.com/products/11048) on SparkFun. I tried to find information on getting http data but I couldn't find anything helpful in the manual. I was wondering if anyone has worked with this before to know if it would be a good choice for this project. Also, does anyone know of any objects that may have already been written to control it? Thanks.
Sign In or Register to comment.