<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.waterwaysinwhittlesea.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jeremy</id>
	<title>Sensors in Schools - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://www.waterwaysinwhittlesea.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jeremy"/>
	<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php/Special:Contributions/Jeremy"/>
	<updated>2026-09-29T20:18:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.4</generator>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10570</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10570"/>
		<updated>2025-06-10T07:09:07Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Tiny House: Smart Temperature Monitoring System =&lt;br /&gt;
&lt;br /&gt;
'''Tiny House''' is a weather and temperature monitoring system for small homes, using a Raspberry Pi Pico W, multiple sensors, and MQTT for remote data access. This wiki provides setup, usage, troubleshooting, and API documentation.&lt;br /&gt;
&lt;br /&gt;
== Contents ==&lt;br /&gt;
* [[#Introduction|Introduction]]&lt;br /&gt;
* [[#Hardware Setup|Hardware Setup]]&lt;br /&gt;
* [[#Software Setup|Software Setup]]&lt;br /&gt;
* [[#Configuration|Configuration]]&lt;br /&gt;
* [[#File Structure|File Structure]]&lt;br /&gt;
* [[#Usage|Usage]]&lt;br /&gt;
* [[#Local Graphing|Local Graphing]]&lt;br /&gt;
* [[#Web Dashboard|Web Dashboard]]&lt;br /&gt;
* [[#Testing Without Sensors|Testing Without Sensors]]&lt;br /&gt;
* [[#Troubleshooting|Troubleshooting]]&lt;br /&gt;
* [[#API Documentation|API Documentation]]&lt;br /&gt;
* [[#License|License]]&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Tiny House monitors temperatures in multiple locations using high-accuracy sensors. Data is sent to an MQTT broker for real-time viewing via graphs or a web dashboard. The system is robust, supports offline data storage, and is easy to set up.&lt;br /&gt;
&lt;br /&gt;
== Hardware Setup ==&lt;br /&gt;
=== Required Components ===&lt;br /&gt;
* Raspberry Pi Pico W&lt;br /&gt;
* PiicoDev TMP117 sensor&lt;br /&gt;
* 3x DS18X20 temperature sensors&lt;br /&gt;
* PiicoDev RTC module&lt;br /&gt;
* Relay, motor, and wiring&lt;br /&gt;
* WiFi access&lt;br /&gt;
&lt;br /&gt;
=== Pin Connections ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Component           !! Pin on Pico W&lt;br /&gt;
|-&lt;br /&gt;
| Motor DIR           || GP21&lt;br /&gt;
| Motor PWM           || GP26&lt;br /&gt;
| Relay               || GP15&lt;br /&gt;
| UART                || GPIO 0 (pin 1 pair)&lt;br /&gt;
| Temp Sensors        || GPIOs 0 / 2 / 3&lt;br /&gt;
| Reset Button        || GP22&lt;br /&gt;
| I2C (TMP117 + RTC)  || SDA = GP4, SCL = GP5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* Daisy-chain TMP117 and RTC using PiicoDev connectors.&lt;br /&gt;
* Connect temp sensors to the appropriate GPIO pins.&lt;br /&gt;
* Power on your Pico W.&lt;br /&gt;
&lt;br /&gt;
== Software Setup ==&lt;br /&gt;
# Install MicroPython on your Pico W.&lt;br /&gt;
# Install Thonny IDE (or another MicroPython IDE).&lt;br /&gt;
# Upload all project files to the Pico W.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;env.py&amp;lt;/code&amp;gt; with your WiFi and MQTT details.&lt;br /&gt;
# Run &amp;lt;code&amp;gt;main.py&amp;lt;/code&amp;gt; using Thonny.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
Edit &amp;lt;code&amp;gt;env.py&amp;lt;/code&amp;gt; to set:&lt;br /&gt;
* &amp;lt;code&amp;gt;WLANSSID&amp;lt;/code&amp;gt;: WiFi network name&lt;br /&gt;
* &amp;lt;code&amp;gt;WLANPASSWD&amp;lt;/code&amp;gt;: WiFi password&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_CLIENT_ID&amp;lt;/code&amp;gt;: Unique MQTT client ID&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_SERVER&amp;lt;/code&amp;gt;: MQTT broker address&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_USER&amp;lt;/code&amp;gt;: MQTT username&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_PASSWORD&amp;lt;/code&amp;gt;: MQTT password&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_TOPIC_DATA&amp;lt;/code&amp;gt;: Topic for temperature data&lt;br /&gt;
* &amp;lt;code&amp;gt;MQTT_TOPIC_STATUS&amp;lt;/code&amp;gt;: Topic for system status&lt;br /&gt;
&lt;br /&gt;
== File Structure ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
MicroPico/&lt;br /&gt;
├── main.py               # Main logic&lt;br /&gt;
├── env.py                # WiFi &amp;amp; MQTT config&lt;br /&gt;
├── lib/&lt;br /&gt;
│   ├── PiicoDev_TMP117.py&lt;br /&gt;
│   ├── PiicoDev_Unified.py&lt;br /&gt;
│   ├── PiicoDev_RV3028.py&lt;br /&gt;
│   └── umqtt/simple.py&lt;br /&gt;
weatherGraph.py           # Local graphing&lt;br /&gt;
dummy_data_publisher.py   # Simulated test data&lt;br /&gt;
Graph-Site-Docker/&lt;br /&gt;
├── flaskSite.py&lt;br /&gt;
├── Docker_Build-and-Run.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
# Flash the MicroPico files to your Raspberry Pi Pico W.&lt;br /&gt;
# Ensure &amp;lt;code&amp;gt;env.py&amp;lt;/code&amp;gt; is configured with your WiFi and MQTT credentials.&lt;br /&gt;
# Set up an MQTT broker (e.g., Mosquitto, HiveMQ, or Adafruit IO).&lt;br /&gt;
# Power up the Pico W to start collecting and publishing temperature data.&lt;br /&gt;
&lt;br /&gt;
=== Pump and Relay Control ===&lt;br /&gt;
* The system can control a pump (forward/backward/stop) and a relay for automation.&lt;br /&gt;
* See &amp;lt;code&amp;gt;main.py&amp;lt;/code&amp;gt; for example usage.&lt;br /&gt;
&lt;br /&gt;
== Local Graphing ==&lt;br /&gt;
# Install Python 3 and required packages: &amp;lt;code&amp;gt;pip install -r requirements.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;python weatherGraph.py&amp;lt;/code&amp;gt; to display real-time temperature graphs.&lt;br /&gt;
&lt;br /&gt;
== Web Dashboard ==&lt;br /&gt;
# Navigate to &amp;lt;code&amp;gt;Graph-Site-Docker&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Create a &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file with your API keys and MQTT settings.&lt;br /&gt;
# Run &amp;lt;code&amp;gt;./Docker_Build-and-Run.sh false true 1.0.0&amp;lt;/code&amp;gt; to launch the web server.&lt;br /&gt;
# Access the dashboard at http://localhost:5000&lt;br /&gt;
&lt;br /&gt;
=== Manual Docker Build/Run ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
docker buildx build --platform linux/amd64,linux/arm64 \&lt;br /&gt;
  -t jezzcomputers/pyapp-image:latest \&lt;br /&gt;
  --push .&lt;br /&gt;
docker run -d --restart unless-stopped --name pyapp-container --env-file &amp;amp;lt;path-to-your-env-file&amp;amp;gt; -p 5000:5000 jezzcomputers/pyapp-image:latest&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Without Sensors ==&lt;br /&gt;
Run &amp;lt;code&amp;gt;python dummy_data_publisher.py&amp;lt;/code&amp;gt; to simulate temperature data for testing the dashboard and graphing tools.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Problem                 !! Solution&lt;br /&gt;
|-&lt;br /&gt;
| Pico not connecting     || Check &amp;lt;code&amp;gt;env.py&amp;lt;/code&amp;gt; WiFi settings, ensure network is available.&lt;br /&gt;
| MQTT issues             || Ensure broker is running, test with simulator, check credentials.&lt;br /&gt;
| Sensor errors           || Recheck wiring or use &amp;lt;code&amp;gt;dummy_data_publisher.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
| Docker site not working || Verify Docker is installed and &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; is valid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Additional Tips ===&lt;br /&gt;
* Check the status LED on the Pico W (solid means connected).&lt;br /&gt;
* Use &amp;lt;code&amp;gt;docker logs pyapp-container&amp;lt;/code&amp;gt; for Docker troubleshooting.&lt;br /&gt;
* For sensor problems, try running the dummy data publisher.&lt;br /&gt;
&lt;br /&gt;
== API Documentation ==&lt;br /&gt;
=== MQTT Topics ===&lt;br /&gt;
* &amp;lt;code&amp;gt;JezzComputers/feeds/data&amp;lt;/code&amp;gt;: Publishes temperature data.&lt;br /&gt;
* &amp;lt;code&amp;gt;JezzComputers/feeds/status&amp;lt;/code&amp;gt;: Publishes system status.&lt;br /&gt;
&lt;br /&gt;
==== Data Format Example ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: {&lt;br /&gt;
    &amp;quot;year&amp;quot;: 2023,&lt;br /&gt;
    &amp;quot;month&amp;quot;: 6,&lt;br /&gt;
    &amp;quot;day&amp;quot;: 15,&lt;br /&gt;
    &amp;quot;hour&amp;quot;: 14,&lt;br /&gt;
    &amp;quot;minute&amp;quot;: 30,&lt;br /&gt;
    &amp;quot;second&amp;quot;: 45&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;in_house_temp&amp;quot;: 22.3,&lt;br /&gt;
  &amp;quot;thermal_mass_temp&amp;quot;: 20.8,&lt;br /&gt;
  &amp;quot;cont_box_temp&amp;quot;: 24.1,&lt;br /&gt;
  &amp;quot;error&amp;quot;: null&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Status Format Example ====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;context&amp;quot;: &amp;quot;System Status&amp;quot;,&lt;br /&gt;
  &amp;quot;doClearLogs&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
  &amp;quot;year&amp;quot;: 2023,&lt;br /&gt;
  &amp;quot;month&amp;quot;: 6,&lt;br /&gt;
  &amp;quot;day&amp;quot;: 15,&lt;br /&gt;
  &amp;quot;hour&amp;quot;: 14,&lt;br /&gt;
  &amp;quot;ampm&amp;quot;: &amp;quot;PM&amp;quot;,&lt;br /&gt;
  &amp;quot;minute&amp;quot;: 30,&lt;br /&gt;
  &amp;quot;second&amp;quot;: 45&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== License ==&lt;br /&gt;
This project is licensed under the [https://opensource.org/licenses/MIT MIT License]. You are free to use, modify, and distribute this code as long as you include the original copyright.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
''For questions, improvements, or to contribute, visit the project repository or use the discussion page.''&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:TinyHouse_Save_Data_Flow.png&amp;diff=10544</id>
		<title>File:TinyHouse Save Data Flow.png</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:TinyHouse_Save_Data_Flow.png&amp;diff=10544"/>
		<updated>2025-02-21T23:50:27Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: Jeremy uploaded a new version of File:TinyHouse Save Data Flow.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10543</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10543"/>
		<updated>2025-02-21T23:49:37Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Import the flow */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize temperature sensors&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Initialize the time dictionary&lt;br /&gt;
time: dict[str, any] = {}&lt;br /&gt;
&lt;br /&gt;
# Function to set the current time&lt;br /&gt;
def setTime():&lt;br /&gt;
    try:&lt;br /&gt;
        print(&amp;quot;Fetching time from API...&amp;quot;)&lt;br /&gt;
        response = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;, timeout=10)&lt;br /&gt;
        data = response.json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
        time.update({&lt;br /&gt;
            &amp;quot;Date&amp;quot;: f&amp;quot;{int(data[8:10])}/{int(data[5:7])}/{int(data[:4])}&amp;quot;,&lt;br /&gt;
            &amp;quot;Hour&amp;quot;: (int(data[11:13]) if int(data[11:13]) &amp;lt;= 12 else int(data[11:13]) - 12),&lt;br /&gt;
            &amp;quot;AM/PM&amp;quot;: &amp;quot;PM&amp;quot; if int(data[11:13]) &amp;gt; 12 else &amp;quot;AM&amp;quot;,&lt;br /&gt;
            &amp;quot;Minute&amp;quot;: int(data[14:16]),&lt;br /&gt;
            &amp;quot;Second&amp;quot;: int(data[17:19])&lt;br /&gt;
        })&lt;br /&gt;
        response.close()&lt;br /&gt;
        print(&amp;quot;Time successfully set.&amp;quot;)&lt;br /&gt;
        return time&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Time Fetching Error&amp;quot;, e)&lt;br /&gt;
        print(&amp;quot;Failed to fetch time.&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;yourSSID&amp;quot;, &amp;quot;yourPASSWD&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(f'Error time: {time}')&lt;br /&gt;
        f.write(f'({context} at time: {time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': str(time),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Getting time...')&lt;br /&gt;
    setTime()  # Sync time dict with online time&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Saving Data With Node-RED=&lt;br /&gt;
&lt;br /&gt;
Install Node-RED then import the flow.&lt;br /&gt;
&lt;br /&gt;
==Install Node-RED==&lt;br /&gt;
Run the following commands in the Raspberry pi terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable nodered.service&lt;br /&gt;
&lt;br /&gt;
node-red-start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then access the flows menu at [http://localhost:1880 localhost:1880]&lt;br /&gt;
&lt;br /&gt;
==Import the flow==&lt;br /&gt;
&lt;br /&gt;
[[File:TinyHouse Save Data Flow.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;tab&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;TechSchool TinyHouse (balcony)&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;info&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;env&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;1f6e3812c0e0c41b&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;inject&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;props&amp;quot;: [],&lt;br /&gt;
        &amp;quot;repeat&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
        &amp;quot;crontab&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;once&amp;quot;: true,&lt;br /&gt;
        &amp;quot;onceDelay&amp;quot;: 0.1,&lt;br /&gt;
        &amp;quot;topic&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 150,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c1646b9e6d680755&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;cfb974a7e537d86f&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;http request&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;method&amp;quot;: &amp;quot;GET&amp;quot;,&lt;br /&gt;
        &amp;quot;ret&amp;quot;: &amp;quot;obj&amp;quot;,&lt;br /&gt;
        &amp;quot;paytoqs&amp;quot;: &amp;quot;ignore&amp;quot;,&lt;br /&gt;
        &amp;quot;url&amp;quot;: &amp;quot;https://dweet.io/get/latest/dweet/for/TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;tls&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;persist&amp;quot;: false,&lt;br /&gt;
        &amp;quot;proxy&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;insecureHTTPParser&amp;quot;: false,&lt;br /&gt;
        &amp;quot;authType&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;senderr&amp;quot;: false,&lt;br /&gt;
        &amp;quot;headers&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 450,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c9eaaaa486180cad&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;function&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;function 1&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;// Create a dictionary to hold all the variables\nvar payload = {\n    outdoor_temp: msg.payload.with[0].content.outdoor_temp,\n    in_house_temp: msg.payload.with[0].content.in_house_temp,\n    last_error_time: msg.payload.with[0].content.last_error_time,\n    last_error: msg.payload.with[0].content.last_error,\n    cont_box_temp: msg.payload.with[0].content.cont_box_temp,\n    timestamp: msg.payload.with[0].content.timestamp\n};\n\n// Assign the dictionary to msg.payload\nmsg.payload = payload;\n\nreturn msg;&amp;quot;,&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;timeout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;noerr&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;initialize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;finalize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;libs&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 720,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
                &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
                &amp;quot;278bf827fb413c13&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;file&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;filename&amp;quot;: &amp;quot;/home/admin/TinyHouse-Data/data.txt&amp;quot;,&lt;br /&gt;
        &amp;quot;filenameType&amp;quot;: &amp;quot;str&amp;quot;,&lt;br /&gt;
        &amp;quot;appendNewline&amp;quot;: true,&lt;br /&gt;
        &amp;quot;createDir&amp;quot;: false,&lt;br /&gt;
        &amp;quot;overwriteFile&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;encoding&amp;quot;: &amp;quot;none&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 990,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
                &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
                &amp;quot;0c4082018898d6d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 240,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;74a9d5dbf20e1b23&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;492dd0d2535dc611&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 480,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 440,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9653a2a329f451d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 560,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.in_house_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
                &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
                &amp;quot;492dd0d2535dc611&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.cont_box_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
                &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
                &amp;quot;9653a2a329f451d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c9eaaaa486180cad&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;gap&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;start&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;inout&amp;quot;: &amp;quot;out&amp;quot;,&lt;br /&gt;
        &amp;quot;septopics&amp;quot;: true,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
        &amp;quot;topi&amp;quot;: &amp;quot;topic&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 590,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
                &amp;quot;6073ca1837c5d125&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6073ca1837c5d125&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Timestamp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.mydate}} {{msg.mytimes}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 730,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c1646b9e6d680755&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;simpletime&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;mydate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myymd&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myyear&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonth&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthn&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydom&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydoy&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myday&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydayf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhourpm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhour&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytime&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytimes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminute&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminutes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mysecond&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymillis&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myepoch&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myrawdate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mypm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 290,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;cfb974a7e537d86f&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;278bf827fb413c13&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error Time&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error_time}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 920,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 900,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0c4082018898d6d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.outdoor_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
                &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
                &amp;quot;74a9d5dbf20e1b23&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Misc.&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 4,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_tab&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;icon&amp;quot;: &amp;quot;dashboard&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;hidden&amp;quot;: false&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10542</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10542"/>
		<updated>2025-02-21T23:35:07Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize temperature sensors&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Initialize the time dictionary&lt;br /&gt;
time: dict[str, any] = {}&lt;br /&gt;
&lt;br /&gt;
# Function to set the current time&lt;br /&gt;
def setTime():&lt;br /&gt;
    try:&lt;br /&gt;
        print(&amp;quot;Fetching time from API...&amp;quot;)&lt;br /&gt;
        response = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;, timeout=10)&lt;br /&gt;
        data = response.json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
        time.update({&lt;br /&gt;
            &amp;quot;Date&amp;quot;: f&amp;quot;{int(data[8:10])}/{int(data[5:7])}/{int(data[:4])}&amp;quot;,&lt;br /&gt;
            &amp;quot;Hour&amp;quot;: (int(data[11:13]) if int(data[11:13]) &amp;lt;= 12 else int(data[11:13]) - 12),&lt;br /&gt;
            &amp;quot;AM/PM&amp;quot;: &amp;quot;PM&amp;quot; if int(data[11:13]) &amp;gt; 12 else &amp;quot;AM&amp;quot;,&lt;br /&gt;
            &amp;quot;Minute&amp;quot;: int(data[14:16]),&lt;br /&gt;
            &amp;quot;Second&amp;quot;: int(data[17:19])&lt;br /&gt;
        })&lt;br /&gt;
        response.close()&lt;br /&gt;
        print(&amp;quot;Time successfully set.&amp;quot;)&lt;br /&gt;
        return time&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Time Fetching Error&amp;quot;, e)&lt;br /&gt;
        print(&amp;quot;Failed to fetch time.&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;yourSSID&amp;quot;, &amp;quot;yourPASSWD&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(f'Error time: {time}')&lt;br /&gt;
        f.write(f'({context} at time: {time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': str(time),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Getting time...')&lt;br /&gt;
    setTime()  # Sync time dict with online time&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Saving Data With Node-RED=&lt;br /&gt;
&lt;br /&gt;
Install Node-RED then import the flow.&lt;br /&gt;
&lt;br /&gt;
==Install Node-RED==&lt;br /&gt;
Run the following commands in the Raspberry pi terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable nodered.service&lt;br /&gt;
&lt;br /&gt;
node-red-start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then access the flows menu at [http://localhost:1880 localhost:1880]&lt;br /&gt;
&lt;br /&gt;
==Import the flow==&lt;br /&gt;
&lt;br /&gt;
[[File:TinyHouse Save Data Flow.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;tab&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;TechSchool TinyHouse (balcony)&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;info&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;env&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;1f6e3812c0e0c41b&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;inject&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;props&amp;quot;: [],&lt;br /&gt;
        &amp;quot;repeat&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
        &amp;quot;crontab&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;once&amp;quot;: true,&lt;br /&gt;
        &amp;quot;onceDelay&amp;quot;: 0.1,&lt;br /&gt;
        &amp;quot;topic&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 150,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c1646b9e6d680755&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;cfb974a7e537d86f&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;http request&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;method&amp;quot;: &amp;quot;GET&amp;quot;,&lt;br /&gt;
        &amp;quot;ret&amp;quot;: &amp;quot;obj&amp;quot;,&lt;br /&gt;
        &amp;quot;paytoqs&amp;quot;: &amp;quot;ignore&amp;quot;,&lt;br /&gt;
        &amp;quot;url&amp;quot;: &amp;quot;https://dweet.io/get/latest/dweet/for/TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;tls&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;persist&amp;quot;: false,&lt;br /&gt;
        &amp;quot;proxy&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;insecureHTTPParser&amp;quot;: false,&lt;br /&gt;
        &amp;quot;authType&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;senderr&amp;quot;: false,&lt;br /&gt;
        &amp;quot;headers&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 450,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c9eaaaa486180cad&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;function&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;function 1&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;// Create a dictionary to hold all the variables\nvar payload = {\n    outdoor_temp: msg.payload.with[0].content.outdoor_temp,\n    in_house_temp: msg.payload.with[0].content.in_house_temp,\n    last_error_time: msg.payload.with[0].content.last_error_time,\n    last_error: msg.payload.with[0].content.last_error,\n    cont_box_temp: msg.payload.with[0].content.cont_box_temp,\n    timestamp: msg.payload.with[0].content.timestamp\n};\n\n// Assign the dictionary to msg.payload\nmsg.payload = payload;\n\nreturn msg;&amp;quot;,&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;timeout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;noerr&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;initialize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;finalize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;libs&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 720,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
                &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
                &amp;quot;278bf827fb413c13&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;file&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;filename&amp;quot;: &amp;quot;/home/admin/TinyHouse-Data/data.txt&amp;quot;,&lt;br /&gt;
        &amp;quot;filenameType&amp;quot;: &amp;quot;str&amp;quot;,&lt;br /&gt;
        &amp;quot;appendNewline&amp;quot;: true,&lt;br /&gt;
        &amp;quot;createDir&amp;quot;: false,&lt;br /&gt;
        &amp;quot;overwriteFile&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;encoding&amp;quot;: &amp;quot;none&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 990,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
                &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
                &amp;quot;0c4082018898d6d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;d0158bd8fdb0e410&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;inject&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;props&amp;quot;: [],&lt;br /&gt;
        &amp;quot;repeat&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;crontab&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;once&amp;quot;: false,&lt;br /&gt;
        &amp;quot;onceDelay&amp;quot;: 0.1,&lt;br /&gt;
        &amp;quot;topic&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 150,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c1646b9e6d680755&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 240,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;74a9d5dbf20e1b23&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;492dd0d2535dc611&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 480,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 440,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9653a2a329f451d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 560,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.in_house_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
                &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
                &amp;quot;492dd0d2535dc611&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.cont_box_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
                &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
                &amp;quot;9653a2a329f451d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c9eaaaa486180cad&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;gap&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;start&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;inout&amp;quot;: &amp;quot;out&amp;quot;,&lt;br /&gt;
        &amp;quot;septopics&amp;quot;: true,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
        &amp;quot;topi&amp;quot;: &amp;quot;topic&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 590,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
                &amp;quot;6073ca1837c5d125&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6073ca1837c5d125&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Timestamp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.mydate}} {{msg.mytimes}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 730,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c1646b9e6d680755&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;simpletime&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;mydate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myymd&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myyear&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonth&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthn&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydom&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydoy&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myday&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydayf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhourpm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhour&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytime&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytimes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminute&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminutes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mysecond&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymillis&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myepoch&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myrawdate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mypm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 290,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;cfb974a7e537d86f&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;278bf827fb413c13&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error Time&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error_time}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 920,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 900,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0c4082018898d6d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.outdoor_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
                &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
                &amp;quot;74a9d5dbf20e1b23&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Misc.&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 4,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_tab&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;icon&amp;quot;: &amp;quot;dashboard&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;hidden&amp;quot;: false&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:TinyHouse_Save_Data_Flow.png&amp;diff=10541</id>
		<title>File:TinyHouse Save Data Flow.png</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:TinyHouse_Save_Data_Flow.png&amp;diff=10541"/>
		<updated>2025-02-21T23:34:10Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10540</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10540"/>
		<updated>2025-02-21T23:30:44Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize temperature sensors&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Initialize the time dictionary&lt;br /&gt;
time: dict[str, any] = {}&lt;br /&gt;
&lt;br /&gt;
# Function to set the current time&lt;br /&gt;
def setTime():&lt;br /&gt;
    try:&lt;br /&gt;
        print(&amp;quot;Fetching time from API...&amp;quot;)&lt;br /&gt;
        response = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;, timeout=10)&lt;br /&gt;
        data = response.json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
        time.update({&lt;br /&gt;
            &amp;quot;Date&amp;quot;: f&amp;quot;{int(data[8:10])}/{int(data[5:7])}/{int(data[:4])}&amp;quot;,&lt;br /&gt;
            &amp;quot;Hour&amp;quot;: (int(data[11:13]) if int(data[11:13]) &amp;lt;= 12 else int(data[11:13]) - 12),&lt;br /&gt;
            &amp;quot;AM/PM&amp;quot;: &amp;quot;PM&amp;quot; if int(data[11:13]) &amp;gt; 12 else &amp;quot;AM&amp;quot;,&lt;br /&gt;
            &amp;quot;Minute&amp;quot;: int(data[14:16]),&lt;br /&gt;
            &amp;quot;Second&amp;quot;: int(data[17:19])&lt;br /&gt;
        })&lt;br /&gt;
        response.close()&lt;br /&gt;
        print(&amp;quot;Time successfully set.&amp;quot;)&lt;br /&gt;
        return time&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Time Fetching Error&amp;quot;, e)&lt;br /&gt;
        print(&amp;quot;Failed to fetch time.&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;yourSSID&amp;quot;, &amp;quot;yourPASSWD&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(f'Error time: {time}')&lt;br /&gt;
        f.write(f'({context} at time: {time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': str(time),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Getting time...')&lt;br /&gt;
    setTime()  # Sync time dict with online time&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Saving Data With Node-RED=&lt;br /&gt;
&lt;br /&gt;
Install Node-RED then import the flow.&lt;br /&gt;
&lt;br /&gt;
==Install Node-RED==&lt;br /&gt;
Run the following commands in the Raspberry pi terminal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
bash &amp;lt;(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable nodered.service&lt;br /&gt;
&lt;br /&gt;
node-red-start&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then access the flows menu at [http://localhost:1880 localhost:1880]&lt;br /&gt;
&lt;br /&gt;
==Import the flow==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;tab&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;TechSchool TinyHouse (balcony)&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;info&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;env&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;1f6e3812c0e0c41b&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;inject&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;props&amp;quot;: [],&lt;br /&gt;
        &amp;quot;repeat&amp;quot;: &amp;quot;3600&amp;quot;,&lt;br /&gt;
        &amp;quot;crontab&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;once&amp;quot;: true,&lt;br /&gt;
        &amp;quot;onceDelay&amp;quot;: 0.1,&lt;br /&gt;
        &amp;quot;topic&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 150,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c1646b9e6d680755&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;cfb974a7e537d86f&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;http request&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;method&amp;quot;: &amp;quot;GET&amp;quot;,&lt;br /&gt;
        &amp;quot;ret&amp;quot;: &amp;quot;obj&amp;quot;,&lt;br /&gt;
        &amp;quot;paytoqs&amp;quot;: &amp;quot;ignore&amp;quot;,&lt;br /&gt;
        &amp;quot;url&amp;quot;: &amp;quot;https://dweet.io/get/latest/dweet/for/TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;tls&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;persist&amp;quot;: false,&lt;br /&gt;
        &amp;quot;proxy&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;insecureHTTPParser&amp;quot;: false,&lt;br /&gt;
        &amp;quot;authType&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;senderr&amp;quot;: false,&lt;br /&gt;
        &amp;quot;headers&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 450,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c9eaaaa486180cad&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;function&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;function 1&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;// Create a dictionary to hold all the variables\nvar payload = {\n    outdoor_temp: msg.payload.with[0].content.outdoor_temp,\n    in_house_temp: msg.payload.with[0].content.in_house_temp,\n    last_error_time: msg.payload.with[0].content.last_error_time,\n    last_error: msg.payload.with[0].content.last_error,\n    cont_box_temp: msg.payload.with[0].content.cont_box_temp,\n    timestamp: msg.payload.with[0].content.timestamp\n};\n\n// Assign the dictionary to msg.payload\nmsg.payload = payload;\n\nreturn msg;&amp;quot;,&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;timeout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;noerr&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;initialize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;finalize&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;libs&amp;quot;: [],&lt;br /&gt;
        &amp;quot;x&amp;quot;: 720,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
                &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
                &amp;quot;278bf827fb413c13&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;e5672fb79ce78898&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;file&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;filename&amp;quot;: &amp;quot;/home/admin/TinyHouse-Data/data.txt&amp;quot;,&lt;br /&gt;
        &amp;quot;filenameType&amp;quot;: &amp;quot;str&amp;quot;,&lt;br /&gt;
        &amp;quot;appendNewline&amp;quot;: true,&lt;br /&gt;
        &amp;quot;createDir&amp;quot;: false,&lt;br /&gt;
        &amp;quot;overwriteFile&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;encoding&amp;quot;: &amp;quot;none&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 990,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
                &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
                &amp;quot;0c4082018898d6d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;d0158bd8fdb0e410&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;inject&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;props&amp;quot;: [],&lt;br /&gt;
        &amp;quot;repeat&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;crontab&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;once&amp;quot;: false,&lt;br /&gt;
        &amp;quot;onceDelay&amp;quot;: 0.1,&lt;br /&gt;
        &amp;quot;topic&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 150,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;c1646b9e6d680755&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 240,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;74a9d5dbf20e1b23&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_gauge&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;gtype&amp;quot;: &amp;quot;gage&amp;quot;,&lt;br /&gt;
        &amp;quot;title&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;°C&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{value}}&amp;quot;,&lt;br /&gt;
        &amp;quot;min&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;max&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#00b500&amp;quot;,&lt;br /&gt;
            &amp;quot;#e6e600&amp;quot;,&lt;br /&gt;
            &amp;quot;#ca3838&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;seg1&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;seg2&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;diff&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;492dd0d2535dc611&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 480,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1480,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 440,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9653a2a329f451d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_chart&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;chartType&amp;quot;: &amp;quot;line&amp;quot;,&lt;br /&gt;
        &amp;quot;legend&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
        &amp;quot;xformat&amp;quot;: &amp;quot;HH:mm:ss&amp;quot;,&lt;br /&gt;
        &amp;quot;interpolate&amp;quot;: &amp;quot;linear&amp;quot;,&lt;br /&gt;
        &amp;quot;nodata&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;dot&amp;quot;: false,&lt;br /&gt;
        &amp;quot;ymin&amp;quot;: &amp;quot;0&amp;quot;,&lt;br /&gt;
        &amp;quot;ymax&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlder&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;removeOlderPoints&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;removeOlderUnit&amp;quot;: &amp;quot;86400&amp;quot;,&lt;br /&gt;
        &amp;quot;cutout&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;useOneColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;useUTC&amp;quot;: false,&lt;br /&gt;
        &amp;quot;colors&amp;quot;: [&lt;br /&gt;
            &amp;quot;#1f77b4&amp;quot;,&lt;br /&gt;
            &amp;quot;#aec7e8&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff7f0e&amp;quot;,&lt;br /&gt;
            &amp;quot;#2ca02c&amp;quot;,&lt;br /&gt;
            &amp;quot;#98df8a&amp;quot;,&lt;br /&gt;
            &amp;quot;#d62728&amp;quot;,&lt;br /&gt;
            &amp;quot;#ff9896&amp;quot;,&lt;br /&gt;
            &amp;quot;#9467bd&amp;quot;,&lt;br /&gt;
            &amp;quot;#c5b0d5&amp;quot;&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;outputs&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;useDifferentColor&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1490,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 560,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            []&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0d98891e68f96021&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.in_house_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;be65b487c1c28224&amp;quot;,&lt;br /&gt;
                &amp;quot;fabb4071a67bbe96&amp;quot;,&lt;br /&gt;
                &amp;quot;492dd0d2535dc611&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;9fe81e1427c3b3f4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.cont_box_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 520,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;f0e92fc90ddf1ec3&amp;quot;,&lt;br /&gt;
                &amp;quot;11f200d35a47323d&amp;quot;,&lt;br /&gt;
                &amp;quot;9653a2a329f451d3&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c9eaaaa486180cad&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;func&amp;quot;: &amp;quot;rbe&amp;quot;,&lt;br /&gt;
        &amp;quot;gap&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;start&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;inout&amp;quot;: &amp;quot;out&amp;quot;,&lt;br /&gt;
        &amp;quot;septopics&amp;quot;: true,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
        &amp;quot;topi&amp;quot;: &amp;quot;topic&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 590,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;3e8484dcd165936c&amp;quot;,&lt;br /&gt;
                &amp;quot;6073ca1837c5d125&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6073ca1837c5d125&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Timestamp&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.mydate}} {{msg.mytimes}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 730,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 400,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;c1646b9e6d680755&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;simpletime&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;mydate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myymd&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myyear&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonth&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthn&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymonthf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydom&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydoy&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myday&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mydayf&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhourpm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myhour&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytime&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mytimes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminute&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myminutes&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mysecond&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mymillis&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myepoch&amp;quot;: true,&lt;br /&gt;
        &amp;quot;myrawdate&amp;quot;: true,&lt;br /&gt;
        &amp;quot;mypm&amp;quot;: true,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 290,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 380,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;cfb974a7e537d86f&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;278bf827fb413c13&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error Time&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error_time}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 920,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 360,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;65ab310cd48fc227&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_text&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;group&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;height&amp;quot;: 0,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;label&amp;quot;: &amp;quot;Last Error&amp;quot;,&lt;br /&gt;
        &amp;quot;format&amp;quot;: &amp;quot;{{msg.payload.last_error}}&amp;quot;,&lt;br /&gt;
        &amp;quot;layout&amp;quot;: &amp;quot;row-spread&amp;quot;,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;style&amp;quot;: false,&lt;br /&gt;
        &amp;quot;font&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;fontSize&amp;quot;: 16,&lt;br /&gt;
        &amp;quot;color&amp;quot;: &amp;quot;#000000&amp;quot;,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 900,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 320,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: []&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0c4082018898d6d3&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;change&amp;quot;,&lt;br /&gt;
        &amp;quot;z&amp;quot;: &amp;quot;16a6d7b3b7d65baf&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;rules&amp;quot;: [&lt;br /&gt;
            {&lt;br /&gt;
                &amp;quot;t&amp;quot;: &amp;quot;set&amp;quot;,&lt;br /&gt;
                &amp;quot;p&amp;quot;: &amp;quot;payload&amp;quot;,&lt;br /&gt;
                &amp;quot;pt&amp;quot;: &amp;quot;msg&amp;quot;,&lt;br /&gt;
                &amp;quot;to&amp;quot;: &amp;quot;payload.outdoor_temp&amp;quot;,&lt;br /&gt;
                &amp;quot;tot&amp;quot;: &amp;quot;msg&amp;quot;&lt;br /&gt;
            }&lt;br /&gt;
        ],&lt;br /&gt;
        &amp;quot;action&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;property&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;from&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;to&amp;quot;: &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;reg&amp;quot;: false,&lt;br /&gt;
        &amp;quot;x&amp;quot;: 1300,&lt;br /&gt;
        &amp;quot;y&amp;quot;: 280,&lt;br /&gt;
        &amp;quot;wires&amp;quot;: [&lt;br /&gt;
            [&lt;br /&gt;
                &amp;quot;2a06f008a3efac15&amp;quot;,&lt;br /&gt;
                &amp;quot;488d2b8e0879420e&amp;quot;,&lt;br /&gt;
                &amp;quot;74a9d5dbf20e1b23&amp;quot;&lt;br /&gt;
            ]&lt;br /&gt;
        ]&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;40710314a2a7b8c6&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Outdoor Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 1,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;6bf64c6ebecdd8a4&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;In House Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 2,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;a81cd77a8bf32b4d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Control Box Temp&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 3,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;8852e72e5635321d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_group&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Misc.&amp;quot;,&lt;br /&gt;
        &amp;quot;tab&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;order&amp;quot;: 4,&lt;br /&gt;
        &amp;quot;disp&amp;quot;: true,&lt;br /&gt;
        &amp;quot;width&amp;quot;: 6,&lt;br /&gt;
        &amp;quot;collapse&amp;quot;: false,&lt;br /&gt;
        &amp;quot;className&amp;quot;: &amp;quot;&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;0649c51a78a7619d&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot;: &amp;quot;ui_tab&amp;quot;,&lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;TinyHouse&amp;quot;,&lt;br /&gt;
        &amp;quot;icon&amp;quot;: &amp;quot;dashboard&amp;quot;,&lt;br /&gt;
        &amp;quot;disabled&amp;quot;: false,&lt;br /&gt;
        &amp;quot;hidden&amp;quot;: false&lt;br /&gt;
    }&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10527</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10527"/>
		<updated>2025-02-10T09:14:11Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize temperature sensors&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Initialize the time dictionary&lt;br /&gt;
time: dict[str, any] = {}&lt;br /&gt;
&lt;br /&gt;
# Function to set the current time&lt;br /&gt;
def setTime():&lt;br /&gt;
    try:&lt;br /&gt;
        print(&amp;quot;Fetching time from API...&amp;quot;)&lt;br /&gt;
        response = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;, timeout=10)&lt;br /&gt;
        data = response.json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
        time.update({&lt;br /&gt;
            &amp;quot;Date&amp;quot;: f&amp;quot;{int(data[8:10])}/{int(data[5:7])}/{int(data[:4])}&amp;quot;,&lt;br /&gt;
            &amp;quot;Hour&amp;quot;: (int(data[11:13]) if int(data[11:13]) &amp;lt;= 12 else int(data[11:13]) - 12),&lt;br /&gt;
            &amp;quot;AM/PM&amp;quot;: &amp;quot;PM&amp;quot; if int(data[11:13]) &amp;gt; 12 else &amp;quot;AM&amp;quot;,&lt;br /&gt;
            &amp;quot;Minute&amp;quot;: int(data[14:16]),&lt;br /&gt;
            &amp;quot;Second&amp;quot;: int(data[17:19])&lt;br /&gt;
        })&lt;br /&gt;
        response.close()&lt;br /&gt;
        print(&amp;quot;Time successfully set.&amp;quot;)&lt;br /&gt;
        return time&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Time Fetching Error&amp;quot;, e)&lt;br /&gt;
        print(&amp;quot;Failed to fetch time.&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;yourSSID&amp;quot;, &amp;quot;yourPASSWD&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(f'Error time: {time}')&lt;br /&gt;
        f.write(f'({context} at time: {time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': str(time),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Getting time...')&lt;br /&gt;
    setTime()  # Sync time dict with online time&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10455</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10455"/>
		<updated>2024-12-18T04:09:28Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize RTC and temperature sensors&lt;br /&gt;
RTC = PiicoDev_RV3028()&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Function to set RTC time from an online API&lt;br /&gt;
def fixtime():&lt;br /&gt;
    data = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;).json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
    RTC.year, RTC.month, RTC.day = int(data[:4]), int(data[5:7]), int(data[8:10])&lt;br /&gt;
    hour = int(data[11:13])&lt;br /&gt;
    RTC.hour, RTC.ampm = (hour-12, &amp;quot;PM&amp;quot;) if hour &amp;gt; 12 else (hour, &amp;quot;AM&amp;quot;)&lt;br /&gt;
    RTC.minute, RTC.second = int(data[14:16]), int(data[17:19])&lt;br /&gt;
    RTC.setDateTime()&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;YourSSID&amp;quot;, &amp;quot;YourPASSWD&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
    reset()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    error_time = RTC.timestamp()&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(error_time)&lt;br /&gt;
        f.write(f'({context} at time: {error_time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': RTC.timestamp(),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    fixtime()  # Sync RTC with online time&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10454</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10454"/>
		<updated>2024-12-18T04:08:39Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import json, onewire, ds18x20&lt;br /&gt;
from os import stat&lt;br /&gt;
from utime import sleep&lt;br /&gt;
from machine import Pin, reset&lt;br /&gt;
from urequests import get, post&lt;br /&gt;
from network import WLAN, STA_IF&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize pins for controlling power and the on-board LED&lt;br /&gt;
DONE = Pin(22, Pin.OUT)&lt;br /&gt;
LED = Pin(&amp;quot;LED&amp;quot;, Pin.OUT); LED.off()&lt;br /&gt;
&lt;br /&gt;
# Initialize RTC and temperature sensors&lt;br /&gt;
RTC = PiicoDev_RV3028()&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))&lt;br /&gt;
onewire_scan = [onewire_sensor.scan(), onewire_sensor2.scan()]&lt;br /&gt;
&lt;br /&gt;
# Setup WLAN&lt;br /&gt;
wlan = WLAN(STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
&lt;br /&gt;
# Function to set RTC time from an online API&lt;br /&gt;
def fixtime():&lt;br /&gt;
    data = get(&amp;quot;https://worldtimeapi.org/api/timezone/Australia/Melbourne&amp;quot;).json()[&amp;quot;datetime&amp;quot;]&lt;br /&gt;
    RTC.year, RTC.month, RTC.day = int(data[:4]), int(data[5:7]), int(data[8:10])&lt;br /&gt;
    hour = int(data[11:13])&lt;br /&gt;
    RTC.hour, RTC.ampm = (hour-12, &amp;quot;PM&amp;quot;) if hour &amp;gt; 12 else (hour, &amp;quot;AM&amp;quot;)&lt;br /&gt;
    RTC.minute, RTC.second = int(data[14:16]), int(data[17:19])&lt;br /&gt;
    RTC.setDateTime()&lt;br /&gt;
&lt;br /&gt;
# Function to read the file content, optionally returning the last line&lt;br /&gt;
def getFileContent(filename, last_line=False):&lt;br /&gt;
    try:&lt;br /&gt;
        file_size = stat(filename)[6]&lt;br /&gt;
        if file_size == 0:&lt;br /&gt;
            return None&lt;br /&gt;
        with open(filename) as f:&lt;br /&gt;
            return f.readlines()[-1].strip() if last_line else f.read()&lt;br /&gt;
    except OSError:&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
# Function to connect to WiFi network&lt;br /&gt;
def connect_to_wifi():&lt;br /&gt;
    wlan.connect(&amp;quot;TechGuest&amp;quot;, &amp;quot;techschool&amp;quot;)&lt;br /&gt;
    for _ in range(21):&lt;br /&gt;
        if wlan.isconnected():&lt;br /&gt;
            print('Network config:', wlan.ifconfig())&lt;br /&gt;
            return&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
    log_error(&amp;quot;WiFi Connection Error&amp;quot;, &amp;quot;Timeout&amp;quot;)&lt;br /&gt;
    DONE.on()&lt;br /&gt;
    reset()&lt;br /&gt;
&lt;br /&gt;
# Function to log errors with a timestamp&lt;br /&gt;
def log_error(context, exception):&lt;br /&gt;
    error_time = RTC.timestamp()&lt;br /&gt;
    with open(&amp;quot;time.txt&amp;quot;, &amp;quot;w&amp;quot;) as t, open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;) as f:&lt;br /&gt;
        t.write(error_time)&lt;br /&gt;
        f.write(f'({context} at time: {error_time}) Containing: {exception}\n')&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor.read_temp(onewire_scan[0][0])&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        return onewire_sensor2.read_temp(onewire_scan[1][0])&lt;br /&gt;
    else:&lt;br /&gt;
        log_error(&amp;quot;getData Error&amp;quot;, f&amp;quot;incorrect input: {whichOne}&amp;quot;)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Function to post data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'in_house_temp': getData(2),&lt;br /&gt;
        'cont_box_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': RTC.timestamp(),&lt;br /&gt;
        'last_error_time': getFileContent(&amp;quot;time.txt&amp;quot;),&lt;br /&gt;
        'last_error': getFileContent(&amp;quot;errors.txt&amp;quot;, last_line=True)&lt;br /&gt;
    }&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    try:&lt;br /&gt;
        response = post('https://dweet.io/dweet/for/TinyHouse', data=json.dumps(data), headers=headers)&lt;br /&gt;
        out = response.text&lt;br /&gt;
        response.close()&lt;br /&gt;
        return out&lt;br /&gt;
    except Exception as e:&lt;br /&gt;
        log_error(&amp;quot;Posting Error&amp;quot;, e)&lt;br /&gt;
        return None&lt;br /&gt;
&lt;br /&gt;
# Main execution block&lt;br /&gt;
try:&lt;br /&gt;
    connect_to_wifi()  # Connect to WiFi&lt;br /&gt;
    LED.on()  # Turn on the LED to indicate activity&lt;br /&gt;
    print('Starting data posting...')&lt;br /&gt;
    fixtime()  # Sync RTC with online time&lt;br /&gt;
    print(postData())  # Post temperature data&lt;br /&gt;
    LED.off()  # Turn off the LED after completing data posting&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    log_error(&amp;quot;Main Execution Error&amp;quot;, e)&lt;br /&gt;
    LED.off()&lt;br /&gt;
    DONE.on()  # Set DONE pin high to remove power&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10438</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10438"/>
		<updated>2024-12-07T02:13:15Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(&amp;quot;your_ssid&amp;quot;, &amp;quot;your_passwd&amp;quot;)  # Connect to the WiFi network&lt;br /&gt;
    #wlan.connect(&amp;quot;TechGuest&amp;quot;, &amp;quot;techschool&amp;quot;)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
            f.write(f'(LN:37) Wifi Error at time: {rtc.timestamp()}. Containing: WiFi connection timeout')&lt;br /&gt;
            f.close&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:43) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
        f.write(f'(LN:63) getData Error at time: {rtc.timestamp()}. Containing: incorrect input: {whichOne}, value should be 0, 1 or 2')&lt;br /&gt;
        f.close&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'outdoor_temp2': getData(2),  # Get outdoor temperature from the second sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp()  # Get the current timestamp from the RTC&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:95) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10437</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10437"/>
		<updated>2024-12-07T02:06:46Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'outdoor_temp2': getData(2),  # Get outdoor temperature from the second sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp()  # Get the current timestamp from the RTC&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 25.3125,&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-07 01:05:57 PM&amp;quot;,&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 25.5,&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 25.97656&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10436</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10436"/>
		<updated>2024-12-07T01:40:50Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'outdoor_temp2': getData(2),  # Get outdoor temperature from the second sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp()  # Get the current timestamp from the RTC&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 22.431&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 22.332&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 22.4879&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-2 12:30 AM&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10435</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10435"/>
		<updated>2024-12-07T01:40:11Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse in the 'RAW' tab&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;outdoor_temp&amp;quot;: 22.431&lt;br /&gt;
  &amp;quot;outdoor_temp2&amp;quot;: 22.332&lt;br /&gt;
  &amp;quot;indoor_temp&amp;quot;: 22.4879&lt;br /&gt;
  &amp;quot;timestamp&amp;quot;: &amp;quot;2024-12-2 12:30 AM&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10434</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10434"/>
		<updated>2024-12-07T01:29:54Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs, jumper wires etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10433</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10433"/>
		<updated>2024-12-07T01:29:24Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screws/standoffs etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10432</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10432"/>
		<updated>2024-12-07T01:29:10Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
+ Any other USB cables, screw/standoffs etc.&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10431</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10431"/>
		<updated>2024-12-07T01:26:33Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/battery-box-4x-aa-switched-jst.html Battery box to go with Pico power timer]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-cable-100mm.html PiicoDev cables (x2)]&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10430</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10430"/>
		<updated>2024-12-07T01:22:57Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10429</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10429"/>
		<updated>2024-12-07T01:22:10Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10428</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10428"/>
		<updated>2024-12-07T01:21:27Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/makerverse-nano-power-timer-hat-for-raspberry-pi-pico.html Power timer for Pico]&lt;br /&gt;
* [https://core-electronics.com.au/professional-solderless-breadboard-400-tie-points-metal-backing-plate.html High quality breadboard]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-platform-for-raspberry-pi-pico.html Plate to attach everything to]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
* [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
* Optional:&lt;br /&gt;
** [https://core-electronics.com.au/makerverse-plant-io-shim.html Shim used for easier sensor connection]&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10427</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10427"/>
		<updated>2024-12-07T01:14:28Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Explanations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Turns the Pico off for 1-hour&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10426</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10426"/>
		<updated>2024-12-07T01:13:06Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at https://dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10425</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10425"/>
		<updated>2024-12-07T01:12:20Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at [https://dweet.io/follow/TinyHouse]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10424</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10424"/>
		<updated>2024-12-07T01:11:04Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at [dweet.io/follow/TinyHouse]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10423</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10423"/>
		<updated>2024-12-07T01:10:41Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output at dweet.io/follow/TinyHouse&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fix When Next data comes through&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10422</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10422"/>
		<updated>2024-12-07T01:09:10Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Explanations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Try/Except:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs the Trys to:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
**If it can't do any of these it will log the error to a file&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10421</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10421"/>
		<updated>2024-12-07T01:07:25Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
DONE = Pin(22, Pin.OUT) # setting this pin High will remove power, and wait for the next interval&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    # print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:40) Wifi Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    f = open(&amp;quot;errors.txt&amp;quot;, &amp;quot;a&amp;quot;)&lt;br /&gt;
    f.write(f'(LN:88) Posting Error at time: {rtc.timestamp()}. Containing: {e}')&lt;br /&gt;
    f.close&lt;br /&gt;
    led.off()&lt;br /&gt;
    DONE.on()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10420</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10420"/>
		<updated>2024-12-07T01:01:14Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
# Initialize components&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT)  # Assign LED pin for output&lt;br /&gt;
rtc = PiicoDev_RV3028()  # Initialize Real-Time Clock (RTC) module&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1, 0, 0, 0])  # Initialize Precision Temperature Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28)))  # Initialize first OneWire Temperature Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12)))  # Initialize second OneWire Temperature Sensor&lt;br /&gt;
&lt;br /&gt;
# Scan for connected OneWire sensors&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan())  # Scan for the first OneWire sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan())  # Scan for the second OneWire sensor&lt;br /&gt;
print(onewire_scan)  # Print scanned addresses of OneWire sensors&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)  # Create a WLAN object in Station mode&lt;br /&gt;
wlan.active(True)  # Activate the WLAN interface&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)  # Connect to the WiFi network&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():  # Wait for the connection to be established&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)  # Pause for a second before checking again&lt;br /&gt;
        timeout += 1  # Increment timeout counter&lt;br /&gt;
        if timeout &amp;gt; 20:  # Check if timeout limit is reached&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)  # Raise an exception if timeout occurs&lt;br /&gt;
    print('Network config:', wlan.ifconfig())  # Print network configuration details&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)  # Print any connection errors&lt;br /&gt;
    machine.reset()  # Reset the machine in case of failure&lt;br /&gt;
&lt;br /&gt;
# Function to get temperature data based on sensor index&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp()  # Convert temperature for the first sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Read temperature from the first sensor&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()  # Read temperature from the precision sensor&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp()  # Convert temperature for the second sensor&lt;br /&gt;
        sleep(1)  # Allow time for temperature conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Read temperature from the second sensor&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')  # Print error for invalid input&lt;br /&gt;
&lt;br /&gt;
# Function to post temperature data to a remote server&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),  # Get outdoor temperature from the first sensor&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),  # Get indoor temperature from the precision sensor&lt;br /&gt;
        'timestamp': rtc.timestamp(),  # Get the current timestamp from the RTC&lt;br /&gt;
        'outdoor_temp2': getData(2)  # Get outdoor temperature from the second sensor&lt;br /&gt;
    }&lt;br /&gt;
    # Convert data dictionary to JSON format and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}  # Specify content type for the request&lt;br /&gt;
    # Make the POST request to the server&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text  # Get the response text&lt;br /&gt;
    response.close()  # Close the response to free resources&lt;br /&gt;
    return out  # Return the server response&lt;br /&gt;
&lt;br /&gt;
# Main loop to continuously post data&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()  # Turn on LED indicator&lt;br /&gt;
    print(postData())  # Post data and print server response&lt;br /&gt;
    led.off()  # Turn off LED indicator&lt;br /&gt;
    sleep(60)  # Wait for 60 seconds before repeating&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10419</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10419"/>
		<updated>2024-12-07T00:58:49Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0, 1 or 2')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10418</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10418"/>
		<updated>2024-12-03T21:51:20Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Connect Sensors To Pico W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter boards (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_with_connector_2.jpg&amp;diff=10417</id>
		<title>File:Pico with connector 2.jpg</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_with_connector_2.jpg&amp;diff=10417"/>
		<updated>2024-12-03T21:47:23Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: Jeremy uploaded a new version of File:Pico with connector 2.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:OneWire_3ping-connector.jpg&amp;diff=10416</id>
		<title>File:OneWire 3ping-connector.jpg</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:OneWire_3ping-connector.jpg&amp;diff=10416"/>
		<updated>2024-12-03T21:46:21Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: Jeremy uploaded a new version of File:OneWire 3ping-connector.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_Full_View.jpg&amp;diff=10415</id>
		<title>File:Pico Full View.jpg</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_Full_View.jpg&amp;diff=10415"/>
		<updated>2024-12-03T21:44:12Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: Jeremy uploaded a new version of File:Pico Full View.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10414</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10414"/>
		<updated>2024-12-03T06:57:38Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Explanations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up four sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10413</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10413"/>
		<updated>2024-12-03T06:54:55Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Connect Sensors To Pico W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin and for my second OneWire sensor I chose pin 12))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10412</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10412"/>
		<updated>2024-12-03T06:52:38Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* [https://www.dfrobot.com/product-203.html Plugable Terminal V2 (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10411</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10411"/>
		<updated>2024-12-03T06:49:20Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor (x2)]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10410</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10410"/>
		<updated>2024-12-03T06:48:57Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Required Items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor x2]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10409</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10409"/>
		<updated>2024-12-03T06:47:53Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Connect Sensors To Pico W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board (there are two)&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_Full_View.jpg&amp;diff=10408</id>
		<title>File:Pico Full View.jpg</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=File:Pico_Full_View.jpg&amp;diff=10408"/>
		<updated>2024-12-03T06:44:03Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: Jeremy uploaded a new version of File:Pico Full View.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10407</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10407"/>
		<updated>2024-12-03T06:38:33Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Explanations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects four pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10406</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10406"/>
		<updated>2024-12-03T06:37:53Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Explanations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you call it with 2, it reads the second outdoor temperature sensor&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects three pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The second outdoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10405</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10405"/>
		<updated>2024-12-03T06:34:29Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* main.py */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_sensor2 = ds18x20.DS18X20(onewire.OneWire(Pin(12))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = []&lt;br /&gt;
onewire_scan.append(onewire_sensor.scan()) #[0] = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
onewire_scan.append(onewire_sensor2.scan()) #[1] = onewire_sensor2.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
print(onewire_scan)&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    elif whichOne == 2:&lt;br /&gt;
        onewire_sensor2.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp2 = onewire_sensor2.read_temp(onewire_scan[1][0])  # Pass the first ROM address in the list&lt;br /&gt;
        return outdoor_temp2&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp(),&lt;br /&gt;
        'outdoor_temp2': getData(2)&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects three pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10404</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10404"/>
		<updated>2024-12-01T00:54:08Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Connect Sensors To Pico W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire to Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects three pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10403</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10403"/>
		<updated>2024-12-01T00:51:25Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
'''1. Initial Setup:'''&lt;br /&gt;
&lt;br /&gt;
*The code starts by setting up three sensors:&lt;br /&gt;
**An LED light that can be turned on and off&lt;br /&gt;
**A real-time clock (RTC) to keep track of time&lt;br /&gt;
**Two temperature sensors: one precision sensor inside (TMP117) and one waterproof sensor outside (DS18X20)&lt;br /&gt;
&lt;br /&gt;
'''2. WiFi Connection:'''&lt;br /&gt;
&lt;br /&gt;
*The code tries to connect to WiFi using a username (ssid) and password&lt;br /&gt;
*If it can't connect within 20 seconds, it will restart the device&lt;br /&gt;
*Once connected, it shows the network information&lt;br /&gt;
&lt;br /&gt;
'''3. getData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function can read from either temperature sensor&lt;br /&gt;
*If you call it with 0, it reads the outdoor temperature&lt;br /&gt;
*If you call it with 1, it reads the indoor temperature&lt;br /&gt;
*If you use any other number, it gives an error message&lt;br /&gt;
&lt;br /&gt;
'''4. postData Function:'''&lt;br /&gt;
&lt;br /&gt;
*This function collects three pieces of information:&lt;br /&gt;
**The outdoor temperature&lt;br /&gt;
**The indoor temperature&lt;br /&gt;
**The current time from the clock&lt;br /&gt;
*It packages this information together&lt;br /&gt;
*It sends this data to a website called &amp;quot;dweet.io&amp;quot; where it can be stored and viewed&lt;br /&gt;
*The data is sent to a specific channel called &amp;quot;TinyHouse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''5. Main Loop:'''&lt;br /&gt;
&lt;br /&gt;
*The program runs forever in a loop that:&lt;br /&gt;
*Turns the LED on&lt;br /&gt;
*Sends the temperature data&lt;br /&gt;
*Turns the LED off&lt;br /&gt;
*Waits for 60 seconds (1 minute)&lt;br /&gt;
*Repeats&lt;br /&gt;
&lt;br /&gt;
Think of it like a weather station that:&lt;br /&gt;
&lt;br /&gt;
*Takes temperature readings from inside and outside your house&lt;br /&gt;
*Adds a timestamp to know when the readings were taken&lt;br /&gt;
*Sends this information to the internet every minute&lt;br /&gt;
*Turns an LED on when it is sending data, so you know it's working&lt;br /&gt;
*Turns the LED off when it has finished sending data&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10402</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10402"/>
		<updated>2024-12-01T00:35:50Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
Still need to add&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.0.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10401</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10401"/>
		<updated>2024-12-01T00:33:33Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
Still need to add&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.*.*', '255.255.255.0', '192.168.*.*', '192.168.*.*')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10400</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10400"/>
		<updated>2024-12-01T00:28:33Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* For Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
Still need to add&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.100.130', '255.255.255.0', '192.168.100.219', '192.168.100.219')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10399</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10399"/>
		<updated>2024-11-30T06:00:12Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation (for advanced users)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
Still need to add&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
If everything is setup correctly you should se a similar output in the Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
MPY: soft reboot&lt;br /&gt;
72&lt;br /&gt;
Network config: ('192.168.100.130', '255.255.255.0', '192.168.100.219', '192.168.100.219')&lt;br /&gt;
{&amp;quot;this&amp;quot;:&amp;quot;succeeded&amp;quot;,&amp;quot;by&amp;quot;:&amp;quot;dweeting&amp;quot;,&amp;quot;the&amp;quot;:&amp;quot;dweet&amp;quot;,&amp;quot;with&amp;quot;:{&amp;quot;thing&amp;quot;:&amp;quot;TinyHouse&amp;quot;,&amp;quot;created&amp;quot;:&amp;quot;2024-11-30T05:58:41.887Z&amp;quot;,&amp;quot;content&amp;quot;:{&amp;quot;outdoor_temp&amp;quot;:23.5625,&amp;quot;timestamp&amp;quot;:&amp;quot;2024-11-30 04:58:33 PM&amp;quot;,&amp;quot;indoor_temp&amp;quot;:24.04688},&amp;quot;transaction&amp;quot;:&amp;quot;fe7831d5-2423-4154-a2e8-29480c4130af&amp;quot;}}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
	<entry>
		<id>http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10398</id>
		<title>Smart Cities - Tiny House at Home (Alternate way)</title>
		<link rel="alternate" type="text/html" href="http://www.waterwaysinwhittlesea.org/index.php?title=Smart_Cities_-_Tiny_House_at_Home_(Alternate_way)&amp;diff=10398"/>
		<updated>2024-11-30T05:57:49Z</updated>

		<summary type="html">&lt;p&gt;Jeremy: /* Connect Raspberry Pi Pico */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Required Items=&lt;br /&gt;
* [https://core-electronics.com.au/raspberry-pi-pico-wh.html Raspberry pi pico wh (wireless with headers)]&lt;br /&gt;
* [https://core-electronics.com.au/temperature-sensor-waterproof-ds18b20.html OneWire temperature sensor]&lt;br /&gt;
* Other sensors:&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-precision-temperature-sensor-tmp117.html Precision temperature sensor]&lt;br /&gt;
** [https://core-electronics.com.au/piicodev-real-time-clock-rv3028.html RTC - Real Time Clock]&lt;br /&gt;
* Breadboard to join sensors + required cables/jumper wires&lt;br /&gt;
&lt;br /&gt;
=Installing Thonny IDE=&lt;br /&gt;
&lt;br /&gt;
Follow installation steps for your os&lt;br /&gt;
&lt;br /&gt;
==For Windows/Mac==&lt;br /&gt;
visit the thonny website and download the latest windows installer https://thonny.org/&lt;br /&gt;
&lt;br /&gt;
==For Linux==&lt;br /&gt;
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
bash &amp;lt;(wget -O - https://thonny.org/installer-for-linux)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re-using an existing Python installation (for advanced users)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pip3 install thonny&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Connect Sensors To Pico W=&lt;br /&gt;
The final assembly should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Pico Full View.jpg|600px]]&lt;br /&gt;
&lt;br /&gt;
Daisy chain the piicodev modules together then plug into 3V3, SDA/SCL and GND&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev temp sensor.jpg|500px]]&lt;br /&gt;
Temp Sensor&lt;br /&gt;
&lt;br /&gt;
[[File:Piicodev RTC.jpg|500px]]&lt;br /&gt;
RTC&lt;br /&gt;
&lt;br /&gt;
Connect the onewire temperature sensor into the raspberry pi pico (GND, PWR and SIG (I chose pin 28 for my SIG pin))&lt;br /&gt;
&lt;br /&gt;
[[File:OneWire 3ping-connector.jpg|500px]]&lt;br /&gt;
OneWire adapter board&lt;br /&gt;
&lt;br /&gt;
[[File:Pico with connector 2.jpg|500px]]&lt;br /&gt;
OneWire - Pico (GP28)&lt;br /&gt;
&lt;br /&gt;
=Thonny IDE Setup=&lt;br /&gt;
Steps to setup Thonny for use with pico w&lt;br /&gt;
&lt;br /&gt;
==Connect Raspberry Pi Pico==&lt;br /&gt;
Connect the pico to your computer using a micro-USB to USB-A cable&lt;br /&gt;
&lt;br /&gt;
Open Thonny IDE&lt;br /&gt;
&lt;br /&gt;
Click 'Configure Interpreter' or the hamburger menu on the bottom right&lt;br /&gt;
&lt;br /&gt;
[[File:Configure_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
Select 'MicroPython (Raspberry Pi Pico)'&lt;br /&gt;
&lt;br /&gt;
[[File:Select_Interpreter.png]]&lt;br /&gt;
&lt;br /&gt;
==Install Required Packages==&lt;br /&gt;
Ensure Raspberry pi pico is connected&lt;br /&gt;
&lt;br /&gt;
Select 'Tools' -&amp;gt; 'Manage packages...'&lt;br /&gt;
&lt;br /&gt;
[[File:Install Libs.png]]&lt;br /&gt;
&lt;br /&gt;
Search for and install 'network' 'onewire' 'piicodev' 'smbus2'&lt;br /&gt;
&lt;br /&gt;
[[File:Required Libs.png]]&lt;br /&gt;
&lt;br /&gt;
This should install the required libraries and put them in a folder called 'lib'&lt;br /&gt;
&lt;br /&gt;
[[File:Folder Libs.png]]&lt;br /&gt;
&lt;br /&gt;
=Programming The Pico W=&lt;br /&gt;
Code and explanation of some sections of the code&lt;br /&gt;
&lt;br /&gt;
==main.py==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from machine import *&lt;br /&gt;
from utime import sleep&lt;br /&gt;
import json&lt;br /&gt;
import socket&lt;br /&gt;
import network&lt;br /&gt;
import urequests&lt;br /&gt;
import onewire, ds18x20&lt;br /&gt;
from PiicoDev_RV3028 import PiicoDev_RV3028&lt;br /&gt;
from PiicoDev_TMP117 import PiicoDev_TMP117&lt;br /&gt;
&lt;br /&gt;
led = Pin(&amp;quot;LED&amp;quot;, Pin.OUT) #Assign led&lt;br /&gt;
rtc = PiicoDev_RV3028() #Assign RTC&lt;br /&gt;
tempSensor = PiicoDev_TMP117(asw=[1,0,0,0]) #Assign Precision Temp Sensor&lt;br /&gt;
onewire_sensor = ds18x20.DS18X20(onewire.OneWire(Pin(28))) #Find Onewire Temp Sensor&lt;br /&gt;
onewire_scan = onewire_sensor.scan() #Assign Onewire Temp Sensor&lt;br /&gt;
&lt;br /&gt;
# Network setup&lt;br /&gt;
wlan = network.WLAN(network.STA_IF)&lt;br /&gt;
wlan.active(True)&lt;br /&gt;
try:&lt;br /&gt;
    wlan.connect(ssid, password)&lt;br /&gt;
    timeout = 0&lt;br /&gt;
    while not wlan.isconnected():&lt;br /&gt;
        print('Waiting for connection...')&lt;br /&gt;
        sleep(1)&lt;br /&gt;
        timeout += 1&lt;br /&gt;
        if timeout &amp;gt; 20:&lt;br /&gt;
            raise Exception(&amp;quot;WiFi connection timeout&amp;quot;)&lt;br /&gt;
    print('Network config:', wlan.ifconfig())&lt;br /&gt;
except Exception as e:&lt;br /&gt;
    print(f&amp;quot;WiFi connection error: {e}&amp;quot;)&lt;br /&gt;
    machine.reset()&lt;br /&gt;
&lt;br /&gt;
def getData(whichOne):&lt;br /&gt;
    if whichOne == 0:&lt;br /&gt;
        onewire_sensor.convert_temp() #Gets Temperature&lt;br /&gt;
        sleep(1) #Allow time for temp conversion&lt;br /&gt;
        outdoor_temp = onewire_sensor.read_temp(onewire_scan[0])&lt;br /&gt;
#        print(f&amp;quot;Onewire Temperature: {outdoor_temp}°C&amp;quot;)&lt;br /&gt;
        return outdoor_temp&lt;br /&gt;
    elif whichOne == 1:&lt;br /&gt;
#        print(f&amp;quot;Precision Temperature: {tempSensor.readTempC()}°C&amp;quot;)&lt;br /&gt;
        return tempSensor.readTempC()&lt;br /&gt;
    else:&lt;br /&gt;
        print(f'incorrect input: {whichOne}, value should be 0 or 1')&lt;br /&gt;
&lt;br /&gt;
def postData():&lt;br /&gt;
    # Create data dictionary with both temperatures and timestamp&lt;br /&gt;
    data = {&lt;br /&gt;
        'outdoor_temp': getData(0),&lt;br /&gt;
        'indoor_temp': tempSensor.readTempC(),&lt;br /&gt;
        'timestamp': rtc.timestamp()&lt;br /&gt;
    }&lt;br /&gt;
    # Convert to JSON and set headers&lt;br /&gt;
    json_data = json.dumps(data)&lt;br /&gt;
    headers = {'Content-Type': 'application/json'}&lt;br /&gt;
    # Make the POST request&lt;br /&gt;
    response = urequests.post(&lt;br /&gt;
        'https://dweet.io/dweet/for/TinyHouse',&lt;br /&gt;
        data=json_data,&lt;br /&gt;
        headers=headers&lt;br /&gt;
    )&lt;br /&gt;
    out = response.text&lt;br /&gt;
    response.close()&lt;br /&gt;
    return out&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    led.on()&lt;br /&gt;
    print(postData())&lt;br /&gt;
    led.off()&lt;br /&gt;
    sleep(60)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Explanations==&lt;br /&gt;
Still need to add&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
Still need to add&lt;/div&gt;</summary>
		<author><name>Jeremy</name></author>
	</entry>
</feed>