# HomeStation - A Pico W powered webpage dashboard

**URL:** <https://forum.core-electronics.com.au/t/homestation-a-pico-w-powered-webpage-dashboard/14900>\
**Category:** Projects\
**Created:** [20 August 2022 14:42 UTC](https://forum.core-electronics.com.au/t/homestation-a-pico-w-powered-webpage-dashboard/14900 "2022-08-20T14:42:04Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Liam120347](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/liam120347/32/5003_2.png) [@Liam120347](https://forum.core-electronics.com.au/u/Liam120347)\
**Post date:** [27 September 2022 05:55 UTC](https://forum.core-electronics.com.au/t/homestation-a-pico-w-powered-webpage-dashboard/14900/4 "2022-09-27T05:55:39Z")

</div>

Howdy all,

### Let's make a super easy-to-use webserver!!

The main goal was to strip away much of the technical code and expose sensors in a Pythonic fashion - like a dictionary!  
Thats right, all of the code you see in the two examples is what we need

If we wanted to see the state of a potentiometer and button the code would look like the following:

- Make a function that returns your value, check out Tim’s Python Workshop for some pointers 😃  
[https://core-electronics.com.au/courses/python-workshop/](https://core-electronics.com.au/courses/python-workshop/)

```auto
import homestation
from machine import Pin,ADC

ssid = 'your wifi name'
password = 'your wifi password'

adc = ADC(Pin(26))
button = Pin(14, Pin.IN, Pin.PULL_DOWN)

def getPot():
    return (adc.read_u16()*3.3/(65536))

def getButton():
    return button.value()

sensorData = {
    "Button": getPot,
    "Potentiometer :": getButton,
}

homestation.homestation_Run(ssid,password,sensorData)

```

![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/7/7dfd9665ea14caa1b1edf50da158541c62004898.png)

  
  

### And say if we wanted the temperature, pressure, humidity and light values?
\*Here's a cool bit!\*

```auto
# HomeStation - Liam Howell - https://github.com/LiamHowell/HomeStation
import homestation

from PiicoDev_Unified import sleep_ms

from PiicoDev_BME280 import PiicoDev_BME280
from PiicoDev_VEML6030 import PiicoDev_VEML6030

# Create PiicoDev sensor objects
atmo = PiicoDev_BME280()
lght = PiicoDev_VEML6030()

import secrets 
# Configure your WiFi SSID and password
ssid = secrets.ssid_s
password = secrets.password_s

def atmoList():
    tempC, presPa, humRH = atmo.values()
    return tempC, presPa/100, humRH #[degC,hPa,RH]

sensorData = {
    ".Atmo": atmoList,
    "Temperature :": ['Atmo',0],
    "Pressure: ": ['Atmo',1],
    "Humidity: ": ['Atmo',2],
    "Light: ": lght.read,
}

homestation.homestation_Run(ssid,password,sensorData)

```

If a single function returns a few values we can ‘pack’ them inside the dictionary, just add a dot to the front of the name of the actual sensor, instead of the function name use a list with the name of the sensor and which position it is passed from

![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/7/7b281b514d60bbaf503f8e8f467d48a458dcdc58.png)

Any questions, suggestions or feedback please let me know!

The `homestation.py` library can be found [on GitHub: https://github.com/LiamHowell/HomeStation](https://github.com/LiamHowell/HomeStation)

---

_[View the full topic](https://forum.core-electronics.com.au/t/homestation-a-pico-w-powered-webpage-dashboard/14900)._
