# Smart Streetlamp

A smart streetlamp that can automatically adjusts brightness levels to conserve power.

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

### Building Instructions

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

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

### Sample Program

#### FutureBoard Program

#### KittenBlock Sample Program

```
Enable IoT server in KittenBlock and fill in the IP.
```

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

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

#### Python Sample Program

```
#Enable IoT server in KittenBlock and fill in the IP.
#/bin/python

from time import sleep
from future import *
from sugar import *
import mqttsimple
P0 = MeowPin('P0', 'ANALOG')
P1 = MeowPin('P1', 'PWM')


x = 0
switch = 0



wifi.connect(str(""), "")

mqtt = mqttsimple.MQTTClient("192.168.2.161", "mirai",port=1883)
mqtt.connect()

mqtt.subscribe("/light")

switch = "on"

while True:
  mqtt.check_msg()
  x = mqtt.mqttRead("/light")
  if bool(x):
    if "off" in x:
      switch = "off"
    if "on" in x:
      switch = "on"
  if switch == "on":
    screen.fill((0, 0, 0))
    screen.text(str("ON"),5,10,3,(0, 119, 255))
    P1.setAnalog(1024 - P0.getAnalog(10))
  else:
    screen.fill((0, 0, 0))
    screen.text(str("OFF"),5,10,3,(0, 119, 255))
    P1.setAnalog(0)
  sleep(0.5)
```

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

#### Kittenblock Program

```
Enable IoT server in KittenBlock and fill in the IP.
```

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

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

### Program Instructions

Remotely turn on or off the streetlamp by using the KittenBlock Client Program, the streetlamp will adjust its brightness based on the environment brightness.


---

# 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/smart-streetlamp.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.
