Meteodaten empfangen Python openweathermap.org

holoratte

Member
Hallo Zusammen,

auf openweathermap.org kann man sich einen Account anlegen un danach mit einer simplen Abfrage eine 5-Tages Wetterforhersage zusenden lassen.
Wenn man den Ardumower über einen Raspi oder PC steuert, könnte man einen Mähplan für die nächsten Tage erstellen und z.B.: nur bei Sonneschein, oder wenn es nicht regnet mähen lassen.
Ich habe mal ein wenig mit dem Python API- "pyowm" gespielt...


Code:
from pyowm import OWM
from pyowm import timeutils
print (timeutils.next_three_hours())

# Have a pro subscription? Then use:
# owm = pyowm.OWM(API_key='your-API-key', subscription_type='pro')

# Search for current weather in London (Great Britain)


def weatherForecast():


    # Query for 3 hours weather forecast for the next 5 days over London
    fc = owm.three_hours_forecast('London,UK')
    f = fc.get_forecast()
    print (f.get_reception_time())
    print (f.get_interval())
    print (len(f))
    for weather in f:
      print (weather.get_reference_time('iso'),weather.get_status(), weather.get_rain())
      print ("will be rainy: ", fc.will_be_rainy_at(weather.get_reference_time('iso')))
      print ("will be snowy: ", fc.will_be_snowy_at(weather.get_reference_time('iso')))

##    observation = owm.weather_at_place('London,UK')
##    w = observation.get_weather()
##
##    print(w)                      # <Weather - reference time=2013-12-18 09:20,
##                                  # status=Clouds>
##
##    # Weather details
##    print w.get_wind()                  # {'speed': 4.6, 'deg': 330}
##    print w.get_humidity()              # 87
##    print w.get_temperature('celsius')  # {'temp_max': 10.5, 'temp': 9.7, 'temp_min': 9.0}
##    print w.get_rain()


if __name__ == '__main__':
    owm = OWM('your-API-key')  # You MUST provide a valid API key
    weatherForecast()

Ausgabe:
Code:
('2018-04-15 12:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-15 15:00:00+00', u'Clouds', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-15 18:00:00+00', u'Rain', {u'3h': 0.03104})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-15 21:00:00+00', u'Rain', {u'3h': 0.04834})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 00:00:00+00', u'Rain', {u'3h': 0.15448})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 03:00:00+00', u'Rain', {u'3h': 1.09462})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 06:00:00+00', u'Rain', {u'3h': 0.15841})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 09:00:00+00', u'Rain', {u'3h': 0.00406})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 12:00:00+00', u'Rain', {u'3h': 0.03532})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 15:00:00+00', u'Rain', {u'3h': 0.0944})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 18:00:00+00', u'Rain', {u'3h': 0.03855})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-16 21:00:00+00', u'Rain', {u'3h': 0.06703})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-17 00:00:00+00', u'Rain', {u'3h': 0.01667})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-17 03:00:00+00', u'Rain', {u'3h': 0.11761})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-17 06:00:00+00', u'Rain', {u'3h': 0.01297})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-17 09:00:00+00', u'Rain', {u'3h': 0.01722})
('will be rainy: ', True)
('will be snowy: ', False)
('2018-04-17 12:00:00+00', u'Clear', {u'3h': 5.0000000000106e-05})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-17 15:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-17 18:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-17 21:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 00:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 03:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 06:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 09:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 12:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 15:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 18:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-18 21:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 00:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 03:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 06:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 09:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 12:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 15:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 18:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-19 21:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-20 00:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-20 03:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-20 06:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
('2018-04-20 09:00:00+00', u'Clear', {})
('will be rainy: ', False)
('will be snowy: ', False)
 
Hi Holoratte.
Very good, Today i finish to implement the Timer into the RPI remote code and maybe this can help to skip a day without the use on the RainSensor.

But The main problem is that actualy the PI can't receive the WIFI(with Internet access) everywhere in the garden so it's why i configure it as HotSpot and the PC or Tablet connect directly to the PI and infortunatly no internet connection.
The test i made show me a good working wifi with my PC at max 5Ml and the Samsung Tablet a 7 8 ML.

But if the station is wifi(Internet) Covered this can be very cool.

By.
 
Hi Bernard,

are you using Python for the Raspi control? if so,would you mind sharing your timer code?
I am trying to do something similar but with remote PC and an RF24_Mesh-Network. The goal is that the charging station, mower and remote-PC can talk to each other.
My rain sensor will be in the charging station and that will call back the mower if it will detect unexpected rain.
The remote PC will send mower start if the weather will be good in the next 3h.

Gruess

Chris
 
Hallo,

ein toller Ansatz! Ich habe mich zeitweise mit Wettervorhersagen beschäftigt (hier für den Bosch Indego mit einem eigens entwickelten Web Interface: http://grauonline.de/wordpress/wp-content/uploads/indego_web_interface1.png).
Meine Erfahrung mit "Wettervorhersagen" war dass die Daten hin- und wieder nicht zum aktuellen Wetter vor Ort passen wollen :) (insbesondere an Orten vor Bergen). Mein Fazit war: für richtig gute Ergebnisse muss man eine eigene Wetterstation bauen:

Was also messen? Genau betrachtet hat Rasenmähen m.E. besonders viel mit Rasenfeuchte zu tun. Ist der Rasen zu feucht braucht m.E. nicht gemäht werden - auch hier wieder ein spezielles und vermutl. nicht allgemeines Problem: bei nassem Boden suhlt sich der Roboter mit Lehm zu und kommt dann nur schwer die Berge hoch (ob der Roboter Ardumower, Robomow oder Indego heisst spielt keine Rolle - die Ardumower Orignal-Räder mit den großen Ausschnitten funktionieren bei feuchtem Boden und Lehm wohl noch am besten...).

So sieht es also aus wenn der Roboter einmal bei feuchtem Lehmboden unterwegs war:
robomow_rain.jpg


Daher habe ich mir eine kleine " "Bodenwetterstation" " gekauft und zum Testen mit einem Handy und einer Basic APP ausgelesen (http://grauonline.de/wordpress/?page_id=2673). Der Sensor liest Luftfeuchte, Bodenleitfähigkeit, Temperatur und Licht.

Mit diesem Sensor werde ich experimentieren und schauen ob die Bodenfeuchte ein gutes Kriterium für Rasenmähen ist :) Der Sensor könnte direkt mit dem Ardumower per Bluetooth 4.0 (BLE) ausgelesen werden und z.B. in der Nähe der Ladestation oder sogar in der Mitte des Gartens sitzen.

PS: die Lösung über Open Weather Map ist wirklich gut - vielleicht lassen sich die Wetterdaten vom aktuellen Ort ja "einspeisen" :) Der Xiaomi Sensor kann übrings auch mit dem Rasperry ausgelesen werden: https://loads.pickle.me.uk/2017/03/19/raspberry-pi-zero-w-and-mi-flora-plant-monitor https://blog.moneybag.de/fhem-xiaomi-pflanzensensor-feuchtigkeit-helligkeit-temperatur-per-bluetooth-messen/ https://zsiti.eu/xiaomi-miflora-plant-sensor-pimatic-raspberry-pi-3/
Gruss,
Alexander
Attachment: https://forum.ardumower.de/data/media/kunena/attachments/905/robomow_rain.jpg/
 
Zuletzt bearbeitet von einem Moderator:
Noch sind wir am experimentieren - Bluetooth 4.0 (BLE) Module ("HM10") sind für den Shop bestellt und werden bald getestet...

PS: Der Raspberry 3 hat bereits Bluetooth 4.0 eingebaut :)
 
Hi Holoratte.

You can find the first small description of the result here https://www.ardumower.de/index.php/...3-mainboard/1484-pcb-1-3-und-raspberry#14869.
All the Code is dev in Python3 with idle3 into a raspberry PI 3B on the table .
The PC use VNC or MobaXterm.
A lot of soft has to be present into the (like Bossac to remote flash,or acces point setting or for plotting etc..)
The timer is finish and the code is into the ZIP and it's actualy in Dev.
You need to put the folder PiArdumower into home/pi/Documents/ the code is locate into PyArdu16.py so you can search for Timer.
But you also need to flash the DUE with the correct version to work.

But in fact all the parameter use in AZURIT are copied into the Pi (see robot.py) and the Raspberry send or receive NMEA sentence to set the Setting or start Something.
A new class RpiRemote locate into the Due manage the communication and the Pfod.cpp use also new function to interact with PI etc......
As you can see all is possible.
Example of PFOD command send by PI:

Code:
def ButtonRight_click():
    send_pfo_message('nr','1','2','3','4','5','6',)
def ButtonLeft_click():
    send_pfo_message('nl','1','2','3','4','5','6',)
def ButtonReverse_click():
    ButtonForward.configure(state='disabled')
    send_pfo_message('nb','1','2','3','4','5','6',)
def ButtonStop_click():
    ButtonForward.configure(state='normal')
    ButtonReverse.configure(state='normal')
    send_pfo_message('ns','1','2','3','4','5','6',)
     

def button_home_click():
    send_pfo_message('rh','1','2','3','4','5','6',)
    
def button_track_click():
    send_pfo_message('rk','1','2','3','4','5','6',)

def button_off_click():
    send_pfo_message('ro','1','2','3','4','5','6',)


The PI code is very long because the Tkinter GUI is not very usefull but it's work very well.

Do not hesitate for more info.

By.
14042018_2018-04-15.zip

Attachment: https://forum.ardumower.de/data/media/kunena/attachments/3545/14042018_2018-04-15.zip/
 
Zuletzt bearbeitet von einem Moderator:
Oben