<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>micropytho Archives - Digital Urban</title>
	<atom:link href="https://www.digitalurban.org/blog/tag/micropytho/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.digitalurban.org/blog/tag/micropytho/</link>
	<description>Data, Cities, IoT, Writing, Music and Making Things</description>
	<lastBuildDate>Wed, 12 Nov 2025 11:39:35 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.digitalurban.org/wp-content/uploads/2012/07/Dulogosm-1.png</url>
	<title>micropytho Archives - Digital Urban</title>
	<link>https://www.digitalurban.org/blog/tag/micropytho/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ships Lamp Wind Speed Gauge</title>
		<link>https://www.digitalurban.org/blog/2025/11/12/ships-lamp-wind-speed-gauge/</link>
		
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Wed, 12 Nov 2025 11:39:29 +0000</pubDate>
				<category><![CDATA[Making]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[iot]]></category>
		<category><![CDATA[micropytho]]></category>
		<category><![CDATA[physical objects]]></category>
		<guid isPermaLink="false">https://www.digitalurban.org/?p=170079118</guid>

					<description><![CDATA[<p>Our MicroPython project turns a strip of NeoPixel LEDs into a “ship&#8217;s lamp&#8221; style wind speed gauge. It connects to an MQTT broker to receive real-time wind speed data and...</p>
<p>The post <a href="https://www.digitalurban.org/blog/2025/11/12/ships-lamp-wind-speed-gauge/">Ships Lamp Wind Speed Gauge</a> appeared first on <a href="https://www.digitalurban.org">Digital Urban</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Our MicroPython project turns a strip of NeoPixel LEDs into a “ship&#8217;s lamp&#8221; style wind speed gauge. It connects to an MQTT broker to receive real-time wind speed data and translates it into a flickering, color-coded light.</p>
<p>The light simulates an oil lamp by staying &#8220;steady&#8221; for a random period and then &#8220;flickering&#8221; for a short time by rapidly dimming and brightening &#8211; the flicker speed changes acording to the wind speed. The full code and details are available on <a href="https://github.com/ucl-casa-ce/Open-Gauges">Github as part of the ever growing Open Gauges Project</a>.</p>
<div id="attachment_170079120" style="width: 1034px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-170079120" class="wp-image-170079120 size-large" src="https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025-1024x768.jpeg" alt="Ships Lamp" width="1024" height="768" srcset="https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025-1024x768.jpeg 1024w, https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025-300x225.jpeg 300w, https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025-768x576.jpeg 768w, https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025-1536x1152.jpeg 1536w, https://www.digitalurban.org/wp-content/uploads/2025/11/shipslamp2025.jpeg 2016w" sizes="(max-width: 1024px) 100vw, 1024px" /><p id="caption-attachment-170079120" class="wp-caption-text">Ships Lamp</p></div>
<h2>Features</h2>
<ul>
<li><strong>Real-time Data:</strong> Connects to an MQTT broker to subscribe to a wind speed topic.</li>
<li><strong>Weather Map Gradient:</strong> Displays wind speed using an intuitive &#8220;weather map&#8221; color gradient:
<ul>
<li><strong>0 mph:</strong> Off (Black)</li>
<li><strong>1-10 mph:</strong> Solid Green</li>
<li><strong>10-20 mph:</strong> Fades from Green → Yellow</li>
<li><strong>20-30 mph:</strong> Fades from Yellow → Orange</li>
<li><strong>30-40 mph:</strong> Fades from Orange → Red</li>
<li><strong>40+ mph:</strong> Solid Red</li>
</ul>
</li>
<li><strong>Realistic Flicker Effect:</strong> The light doesn&#8217;t just stay solid; it cycles between a &#8220;steady&#8221; phase (10-60s) and a &#8220;flicker&#8221; phase (5-15s) to simulate a real lamp.</li>
<li><strong>Asynchronous &amp; Resilient:</strong> Built using <code>uasyncio</code> and <code>mqtt_as</code>. The <code>mqtt_as</code> library automatically handles and recovers from WiFi or MQTT broker disconnections, re-subscribing to topics as needed.</li>
<li><strong>Hardware Watchdog:</strong> Uses the Pico&#8217;s built-in <code>machine.WDT</code> (Watchdog Timer) to automatically reboot the device <em>only</em> if the main code loop freezes, ensuring high reliability. (This replaces the old 60-minute timer).</li>
<li><strong>Status LEDs:</strong> Provides a heartbeat flash on one LED and a WiFi status indicator on another.</li>
</ul>
<h2>Hardware Requirements<strong style="font-size: 16px;"><img decoding="async" style="font-weight: 400;" src="https://github.com/ucl-casa-ce/Open-Gauges/raw/main/Contributed/ShipsLamp/shipslamp.jpeg" alt="MQTT Ships Lamp" /></strong></h2>
<ul>
<li><strong>Raspberry Pi Pico W:</strong> (or any Pico with a WiFi-capable board).</li>
<li><strong>NeoPixel LED Strip:</strong> The code is configured for a strip, but can be any WS812B/NeoPixel compatible LEDs.</li>
<li><strong>Power Supply:</strong> A sufficient power supply for your LED strip (a strip of 60 LEDs can draw several amps at full brightness).</li>
<li><strong>A Ships Lamp (old or new).</strong></li>
</ul>
<h3>Default Pinout (Pico W)</h3>
<ul>
<li><strong>NeoPixel Data:</strong> <code>GP15</code></li>
<li><strong>Blue LED (Heartbeat):</strong> <code>blue_led</code> (defined in <code>config.py</code>, often the onboard LED).</li>
<li><strong>WiFi LED:</strong> <code>wifi_led</code> (defined in <code>config.py</code>).</li>
</ul>
<h2>Software &amp; Dependencies</h2>
<p>This project relies on a few key MicroPython libraries that you must have on your Pico:</p>
<ol>
<li><strong><code>neopixel.py</code>:</strong> The standard Adafruit NeoPixel library for MicroPython.</li>
<li><strong><code>mqtt_as.py</code>:</strong> A robust, asynchronous MQTT client. You can find it <a href="https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as/mqtt_as.py" target="_blank" rel="noopener noreferrer">here</a>.</li>
<li><strong><code>config.py</code>:</strong> A file you must create to hold your credentials and pin definitions.</li>
</ol>
<h2>Configuration</h2>
<p>You <strong>must</strong> create a <code>config.py</code> file in the root of your Pico&#8217;s filesystem. This file should contain:</p>
<ol>
<li>Your WiFi and MQTT broker credentials.</li>
<li>Definitions for your <code>wifi_led</code> and <code>blue_led</code>.</li>
</ol>
<p>The <code>mqtt_as</code> library expects the <code>config.py</code> to contain a <code>config</code> dictionary.</p>
<p><strong>Example <code>config.py</code>:</strong></p>
<pre class="wp-block-code"><code># config.py
from machine import Pin

# --- WiFi Configuration ---
config['wifi_led'] = Pin("WL_GPIO0", Pin.OUT) # Onboard LED on Pico W
config['ssid'] = 'YOUR_WIFI_SSID'
config['wifi_pw'] = 'YOUR_WWIFI_PASSWORD'

# --- MQTT Configuration ---
# This example is for the open broker mqtt.cetools.org
config['server'] = 'mqtt.cetools.org'
config['port'] = 1884
config['client_id'] = 'pico_ships_lamp' # Or any unique ID

# --- Optional: For Secured Brokers ---
# If your broker requires a username and password, add these lines:
# config['user'] = 'YOUR_MQTT_USER'
# config['password'] = 'YOUR_MQTT_PASSWORD'

# --- Other Hardware ---
# This is for the heartbeat LED
blue_led = Pin(10, Pin.OUT) # Example: an external LED on GP10
</code></pre>
<h2>Running the Project</h2>
<ol>
<li>Upload <code>main.py</code>, <code>neopixel.py</code>, <code>mqtt_as.py</code>, and your <code>config.py</code> to your Raspberry Pi Pico.</li>
<li>Reset the device.</li>
<li>The device will automatically connect to your WiFi and MQTT broker.</li>
<li>It will subscribe to the topic <code>personal/ucfnaps/downhamweather/windSpeed_mph</code>.</li>
<li>As messages are published to that topic, the ship&#8217;s lamp will spring to life!</li>
</ol>
<h2>Customizing</h2>
<ul>
<li><strong>LED Count:</strong> Change the <code>numpix</code> variable at the top of <code>main.py</code> to match your strip.</li>
<li><strong>Data Pin:</strong> Change the <code>15</code> in <code>pixels = Neopixel(numpix, 0, 15, "GRB")</code> to match your data pin.</li>
<li><strong>MQTT Topic:</strong> Change the a topic name in the <code>conn_han</code> function to subscribe to your own data source.</li>
</ul>
<p>The post <a href="https://www.digitalurban.org/blog/2025/11/12/ships-lamp-wind-speed-gauge/">Ships Lamp Wind Speed Gauge</a> appeared first on <a href="https://www.digitalurban.org">Digital Urban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
