# Weather Station

This weather station can report the local weather from Hong Kong Observatory.

![](https://kittenbothk-eng.readthedocs.io/en/latest/_images/weatherstation.jpg)

### Building Instructions

[Building Instructions(Right Click->Save As)](https://github.com/kittenbothk/kittenbothk/raw/master/Kits/future_inventor/instructions/pdf/weatherstation.pdf)

### Sample Wiring Diagram

![](https://kittenbothk-eng.readthedocs.io/en/latest/_images/weatherstation_wire.png)

### Sample Program

#### KittenBlock Sample Program

![../../../\_images/weatherstation\_code.png](https://kittenbothk-eng.readthedocs.io/en/latest/_images/weatherstation_code.png)

[Download Sample Program(Right Click->Save As)](https://github.com/kittenbothk/kittenbothk/raw/master/Kits/future_inventor/instructions/sb3/weather.sb3)

#### Python Sample Program

```
#/bin/python

from time import sleep
from future import *
from sugar import *
import robotbit
import urequests
import ujson
api_url='https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en'

x = 0

screen.sync = 1

robot = robotbit.RobotBit()

robot.geekServo2kg(1, 90)

wifi.connect(str("3DJollyFab"), "goodluckjf11b")

#init hko

screen.sync = 0

while True:
  r=urequests.get(api_url)
  weather=ujson.loads(r.content)
  
  screen.fill((0, 0, 0))
  screen.text(str("Temperature:"),5,10,1,(255, 255, 255))
  screen.text(str(str(ENV().update()[0])+str("C")),5,25,2,(255, 255, 255))
  screen.text(str("Humidity:"),5,50,1,(255, 255, 255))
  screen.text(str(str(ENV().update()[1])+str("%")),5,65,2,(255, 255, 255))
  screen.text(str("UV Index:"),5,90,1,(255, 255, 255))
  screen.text(str(weather['uvindex']['data'][0]['desc']),5,105,2,(255, 255, 255))
  screen.refresh()
  if weather['uvindex']['data'][0]['desc'] == "extreme":
    robot.geekServo2kg(1, 90)
  if weather['uvindex']['data'][0]['desc'] == "very high":
    robot.geekServo2kg(1, 220)
  if weather['uvindex']['data'][0]['desc'] == "high":
    robot.geekServo2kg(1, 150)
  if weather['uvindex']['data'][0]['desc'] == "moderate" or weather['uvindex']['data'][0]['desc'] == "low":
    robot.geekServo2kg(1, 330)
  sleep(5)
```

[Download Sample Program(Right Click->Save As)](https://github.com/kittenbothk/kittenbothk/raw/master/Kits/future_inventor/instructions/py/weather.py)

### Program Instructions

Modify the program to connect to your WiFi network, FutureBoard will display the current temperature and humidity, the icon will change according to the UV index.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sharinghub-eng.kittenbot.hk/educational-kit-sets/futureboard-iot-education-kit/futureboard-iot-education-kit-instructions/weather-station.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
