<?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>Step by step guide Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/step-by-step-guide/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/step-by-step-guide/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Tue, 19 Aug 2025 16:23:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://nerd-corner.com/wp-content/uploads/2019/10/cropped-LogoNerdCorner-2-32x32.png</url>
	<title>Step by step guide Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/step-by-step-guide/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>DIY solar panel mount for 2W panels</title>
		<link>https://nerd-corner.com/diy-solar-panel-mount-for-2w-panels/</link>
					<comments>https://nerd-corner.com/diy-solar-panel-mount-for-2w-panels/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Sun, 22 Jun 2025 17:57:13 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[2W solar panel]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[mounting system]]></category>
		<category><![CDATA[Solar panel]]></category>
		<category><![CDATA[Solid Works]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[STL]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1727</guid>

					<description><![CDATA[<p>Often you don&#8217;t need a large power source to reliably charge an 18650 battery. Unfortunately, suitable, small solar panels are difficult to find &#8211; many &#8230; </p>
<p>The post <a href="https://nerd-corner.com/diy-solar-panel-mount-for-2w-panels/">DIY solar panel mount for 2W panels</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Often you don&#8217;t need a large power source to reliably charge an 18650 battery. Unfortunately, suitable, small solar panels are difficult to find &#8211; many are polycrystalline, have no housing or are merely laminated and fitted with simple eyelets for fastening. However, this is rarely ideal for stable and weatherproof outdoor installation. If you want a clean, durable installation, you need a robust housing with an adjustable bracket. For my outdoor applications, an output of around 1.5 watts is usually sufficient &#8211; a monocrystalline 2-watt panel with a corresponding solar panel mount is exactly the right choice.<i></i></p>
<p data-start="155" data-end="778"><img fetchpriority="high" decoding="async" class="zoooom aligncenter wp-image-1714" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand.jpg" alt="" width="716" height="800" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand.jpg 1393w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand-268x300.jpg 268w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand-916x1024.jpg 916w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand-768x858.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanel-stand-1374x1536.jpg 1374w" sizes="(max-width: 716px) 100vw, 716px" /></p>
<p data-start="155" data-end="778"><em><strong>This might also be interesting for you: </strong><a href="https://nerd-corner.com/diy-powerbank-with-voltage-regulator-and-voltmeter/">Do it yourself powerbank with voltage regulator and voltmeter</a></em></p>
<h2>Planning and choice of material</h2>
<p>Before I start building, I first think about where the solar panels should be mounted: One on the garden shed, two on the balcony railing and one on the weather station mast.</p>
<p>The garden shed has a straight wooden wall, which makes a flat bracket necessary. The balcony railing and the mast, on the other hand, each have a diameter of 30 mm &#8211; a bracket with a rounding is required here. So I currently need two different types of mounting.</p>
<p>I use a monocrystalline 2-watt module with an output voltage of around 6 V as the solar panel (see Figure 1.0.1). For the electrical connection to the panel, I opted for a standard 5.5×2.1 mm hollow socket (see Fig. 1.0.2). Cables and screws are not included in the illustration as they may vary depending on the application. The panels are available in packs of five or ten from various online retailers. Their dimensions are 120 × 110 mm (length × width), whereby the height can vary between 1.3 mm and 1.8 mm.<i></i></p>
<p><img decoding="async" class="aligncenter wp-image-1713 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1.jpg" alt="" width="2276" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1.jpg 2279w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1-1536x898.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter1-2048x1197.jpg 2048w" sizes="(max-width: 2276px) 100vw, 2276px" /></p>
<h2>Construction of the housing</h2>
<p>The central component for the solar panel mount is the frame. It provides both the stability and the sealing function of the housing. The frame must be torsion-resistant, be able to accommodate all the necessary threads and still remain compact. The solar panel is pressed into its seat from behind with strips so that it is tightly sealed at the front.<br />
Several screws are required to create an even contact pressure (see Figure 2.0.1).</p>
<p>There is a cover on the back (Fig. 2.0.2), which is reinforced in an X shape for stability. This cover also accommodates the hollow bushing (5.5 × 2.1 mm), which is later attached with a small bridge. One of the four pressure bars that press the panel into the frame can be seen in Figure 2.0.3. The joint holder (Fig. 2.0.4) is used to attach the panel to railings or walls. This serves as a holder for the retaining lever, which holds the housing securely in place and allows flexible alignment.</p>
<h2 data-start="175" data-end="204"><img decoding="async" class="aligncenter wp-image-1712 zoooom" style="font-family: 'Source Sans Pro', Graphik, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2.jpg" alt="" width="2265" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2.jpg 2277w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-2048x1194.jpg 2048w" sizes="(max-width: 2265px) 100vw, 2265px" /></h2>
<p>Figure 2.1.1 shows the holding arm for railing attachment with a 30 mm diameter at the end. The counterpart for the holder can be seen in Fig. 2.1.2. The bridge (Fig. 2.1.3) for attaching the hollow bushing to the cover.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1711" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1.jpg" alt="Solarpanelhalterung CAD Teile" width="2276" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1.jpg 2279w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1-1536x898.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter2-1-2048x1197.jpg 2048w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></p>
<h2>3D printing of the components</h2>
<p>For 3D printing, I chose the following print orientations for the Prusa MK4 (see Figures 3.0.1 and 3.0.2).<br />
Particularly important: The bar must of course be printed four times, as it is used on all four sides of the solar panel.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1710 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3.jpg" alt="" width="2265" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3.jpg 2277w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-2048x1194.jpg 2048w" sizes="auto, (max-width: 2265px) 100vw, 2265px" /></p>
<h3>Thread cutting</h3>
<p>Now let&#8217;s move on to my favorite activity: thread cutting. Admittedly, there is a lot to do in the frame (see Figure 3.1.1): The green markings indicate 12× M3 threads, the yellow ones 4× M3 threads.</p>
<p>There is an alternative version of the frame for those who are not the biggest fans of thread cutting. This is equipped with slots to accommodate normal M3 nuts. The matching file is called: Deckel110x120_V1-2.stl (see Figure 3.1.3).<br />
The recesses for the nuts are also clearly visible in Figures 3.1.4 and 3.1.5.</p>
<p>On the back cover (Figure 3.1.2), however, the cutting of threads can hardly be avoided: 3× M3 threads and 2× M2 threads are required here.<br />
Alternatively, self-tapping screws can also be used &#8211; this saves tools and time.</p>
<h3 data-start="162" data-end="406"><img loading="lazy" decoding="async" class="aligncenter wp-image-1709 zoooom" style="font-family: 'Source Sans Pro', Graphik, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1.jpg" alt="" width="2276" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1.jpg 2279w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1-1536x898.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter3-1-2048x1197.jpg 2048w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></h3>
<h2>Soldering and assembly</h2>
<p>Once all 3D printed parts have been cleaned and threaded, the solar panel can be connected and soldered.</p>
<h3>Electrical connections</h3>
<p>The first hurdle is to find out where the positive pole is located on the panel.<br />
There are only two soldering lugs on the back of the solar panel, but no labeling &#8211; so: plus or minus? To determine this quickly and clearly, we need a multimeter. If we set it to measure direct voltage (DC), it helps us to recognize the polarity.</p>
<p>Figure 4.0.1: The red wire (positive) of the multimeter is connected to one of the soldering lugs, the black wire (negative) to the other. If a minus sign appears in front of the measured value on the display, this means that the red wire is connected to the negative terminal &#8211; i.e. the opposite tab is the positive terminal of the solar panel.</p>
<p>Figure 4.0.2 shows the reverse configuration: the red wire is connected to the positive pole of the panel, the black wire to the negative pole. In this case, no minus sign appears in the display &#8211; the polarity is correct,<br />
and we now know for sure where the positive pole of the solar panel is.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1708 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4.jpg" alt="" width="2265" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4.jpg 2277w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2048x1194.jpg 2048w" sizes="auto, (max-width: 2265px) 100vw, 2265px" /></p>
<p>The hollow socket is now soldered to the solar panel. Figure 4.1.1 clearly shows which connections need to be connected.<br />
Figure 4.1.2 shows the finished soldering in the installed state.</p>
<p>I have also soldered a diode to the positive pole of the hollow socket (see Fig. 4.1.3).<br />
This protects against reverse current: if the connected load does not have its own protective diode, the solar panel would draw energy from the battery in the dark &#8211; and unintentionally work as a heater.</p>
<p>A typical example:<br />
If a charge controller does not have an integrated diode, the battery can discharge the panel backwards in the absence of sunlight.</p>
<p>The installation direction of the diode is crucial so that the current can only flow in one direction.</p>
<p data-start="79" data-end="137"><img loading="lazy" decoding="async" class="aligncenter wp-image-1707 zoooom" style="font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1.jpg" alt="" width="2276" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1.jpg 2279w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1-1536x898.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-1-2048x1197.jpg 2048w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></p>
<h3>Mounting the hollow bushing and inserting the panel</h3>
<p>The installation of the soldered hollow bushing on the retaining bridge is shown in Figure 4.2.1.<br />
The hollow bushing is pushed into the large opening of the retaining bridge until the thread protrudes on the other side. The nut is then placed on the thread and tightened &#8211; the result is shown in Figure 4.2.2. The solar panel is now inserted into the retaining seat of the frame (see Figure 4.2.3, red frame).<br />
If you want to increase the tightness, you can apply some elastic adhesive evenly to the seat before inserting the panel. Once the solar panel is correctly seated, the first strip is placed in position and lightly tightened with a screw in the middle (see Figure 4.2.4, magenta circle). A side view is shown in Figure 4.2.5 to illustrate this.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1706 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2.jpg" alt="" width="2264" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2.jpg 2278w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-2-2048x1194.jpg 2048w" sizes="auto, (max-width: 2264px) 100vw, 2264px" /></p>
<h3>Fastening the slats and screwing</h3>
<p>The remaining slats are attached one by one with the screw in the middle (see figure 4.3.1). Then insert the remaining screws, but do not tighten them yet (see figure 4.3.2). When the solar panel is evenly positioned, first tighten the middle screws of each strip.<br />
Then tighten all the remaining screws and retighten them after a short time. If the solar panel still has some play, you can place some shims between the solar panel and the rail until it is firmly in place. Figure 4.3.3 shows how the hollow bushing and retaining bridge are attached to the inside of the back cover.<br />
Finally, the back cover is screwed onto the frame with four screws (see Fig. 4.3.4).</p>
<h3 data-start="62" data-end="294"><img loading="lazy" decoding="async" class="aligncenter wp-image-1705 zoooom" style="font-family: 'Source Sans Pro', Graphik, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3.jpg" alt="" width="2276" height="1330" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3.jpg 2279w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3-1536x898.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-3-2048x1197.jpg 2048w" sizes="auto, (max-width: 2276px) 100vw, 2276px" /></h3>
<p>Only a few steps are required to complete the bracket:<br />
First, the M6 nut is pressed into the joint bracket (see figure 4.4.1).<br />
The holder for the railing is then attached to the joint holder with an M6 screw (see Figure 4.4.2).<br />
The joint holder is now screwed to the back cover with three M3 screws.<br />
Do not forget: The M3 nuts must be pressed into the counterholder that will later be used for mounting on the railing (see figure 4.4.4).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1704 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4.jpg" alt="" width="2264" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4.jpg 2278w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-4-2048x1194.jpg 2048w" sizes="auto, (max-width: 2264px) 100vw, 2264px" /></p>
<h2>Exploded view of the solar panel mount</h2>
<p>For a better overview, there is an exploded view of the solar panel holder in Figure 4.5.1.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1703 zoooom" src="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5.jpg" alt="" width="2264" height="1320" srcset="https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5.jpg 2278w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5-1024x597.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5-768x448.jpg 768w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5-1536x895.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2025/06/solarpanelhalter4-5-2048x1194.jpg 2048w" sizes="auto, (max-width: 2264px) 100vw, 2264px" /></p>
<h3 data-start="73" data-end="322">Note</h3>
<p data-start="73" data-end="322">Of course, there are also alternative mounting options. For instance, in a garden flower bed, plants may grow over time and gradually shade the solar panel. In this case, a holder with an aluminum rod and ground spike can be used (see Fig. 5.0.1).</p>
<p data-start="324" data-end="477">On a balcony, the panel can be attached via flower boxes that cover the railing; here too, a holder with an aluminum rod is available (see Fig. 5.0.2).</p>
<p data-start="479" data-end="578">Additionally, a holder designed for mounting on a wall or post is also provided (see Fig. 5.0.3).</p>
<p><img decoding="async" src="https://elepla.de/images/Powerbank/2W_Solarpanel_Halterrahmen/5-0.jpg" alt="5 0" /></p>
<p data-start="72" data-end="154">Furthermore, I plan to design a solar panel holder with a built-in USB-C output.</p>
<p data-start="156" data-end="444">The solar panel is an excellent addition for powering my small devices and outdoor sensors – and this holds true even in winter! Depending on your needs, you can either assemble the cables yourself or purchase them ready-made. In any case, the rule of thumb is: the shorter, the better.</p>
<p data-start="446" data-end="559">Have fun building your own version – or perhaps this project has inspired you to create something entirely new.</p>
<h2>Files for Download</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:6835041">Housing for the solar panel mount</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/diy-solar-panel-mount-for-2w-panels/">DIY solar panel mount for 2W panels</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/diy-solar-panel-mount-for-2w-panels/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Deployment of a WebApp with Kubernetes and Caddy</title>
		<link>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/</link>
					<comments>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Sun, 16 Feb 2025 18:31:48 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[App development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[Caddy]]></category>
		<category><![CDATA[Caddy Server]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[ClusterIP]]></category>
		<category><![CDATA[ConfigMap]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Domain Registration]]></category>
		<category><![CDATA[Hetzner]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Ingress]]></category>
		<category><![CDATA[Ingress Controller]]></category>
		<category><![CDATA[ip addres]]></category>
		<category><![CDATA[K3s]]></category>
		<category><![CDATA[Kubectl]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[LoadBalancer]]></category>
		<category><![CDATA[mySql]]></category>
		<category><![CDATA[Nest.js]]></category>
		<category><![CDATA[Node Port]]></category>
		<category><![CDATA[Pods]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[Reverse Proxy]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Service]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Traefik]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1695</guid>

					<description><![CDATA[<p>After describing how to create production-ready Docker images and upload them to Docker Hub in the last article, it is now time to make these &#8230; </p>
<p>The post <a href="https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/">Deployment of a WebApp with Kubernetes and Caddy</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After describing how to create production-ready Docker images and upload them to Docker Hub in the last article, it is now time to make these images available on a server. The aim is to make the web application accessible to everyone via a dedicated domain. To do this, we use a virtual private server (VPS) from Hetzner and deploy Kubernetes (k3s) with Caddy as a reverse proxy.</p>
<p><strong><em>You might also be interested in this: </em></strong><a href="https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/"><em>Create Docker images and upload them to Dockerhub</em></a></p>
<h2>Set up a VPS with Hetzner</h2>
<p>Hetzner often offers referral links with credit benefits for new customers. Of course, you can also use other providers, but Hetzner is attractively priced and offers solid services.</p>
<h3>What is a VPS?</h3>
<p>A Virtual Private Server (VPS) is a virtual server that is operated on a physical machine and acts as an independent server. It offers more control than classic shared hosting and is a cost-effective alternative to dedicated servers. Access is usually via SSH (Secure Shell), which allows us to control the server via the command line.</p>
<h3>SSH access to the VPS</h3>
<p>Once a VPS has been created, it is usually managed via a secure shell (SSH). SSH is a protocol that enables encrypted connections to remote servers. The following command is used to connect to the server:</p>
<p data-start="1137" data-end="1384"><span style="background-color: #e9ebec; color: #222222; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 15px;">ssh root@&lt;IP-Server&gt;</span></p>
<p>If an SSH key has been stored, authentication can be carried out using public key authentication, which is more secure than a password.</p>
<h3>Create a server at Hetzner</h3>
<ol>
<li>After logging into the Hetzner Cloud, we navigate to “Projects” and create a new project.</li>
<li>Select “Add server” and can configure an instance.</li>
<li>The cheapest model is often sufficient to start with. However, I recommend activating the option for an IPv4 address, as purely IPv6-based setups often cause compatibility problems.</li>
</ol>
<h3>Setting up a domain</h3>
<p>To access the application later under your own domain, you must register a domain and link it to the server.</p>
<h3>Apply for a domain at Hetzner</h3>
<ol>
<li>Register a new domain or add an existing domain in the Hetzner ConsoleH.</li>
<li>To manage DNS entries, we need to activate DNS access.</li>
</ol>
<h3>Set name servers</h3>
<p>The following name servers should be used:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">helium.ns.hetzner.de. 
hydrogen.ns.hetzner.com. 
oxygen.ns.hetzner.com.</pre>
<p>These new name servers offer better performance and flexibility compared to the old Hetzner name servers:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">ns1.first-ns.de.
robotns2.second-ns.de.
robotns3.second-ns.com.</pre>
<p>However, both nameserver variants are possible! The DNS changes take some time. However, we can use tools such as MXToolbox to check whether the changes have already taken place.</p>
<h3>Connect the domain to the server</h3>
<p>Now the IP address of the server must be linked to the domain:</p>
<ol>
<li>Switch to DNS zones in the Hetzner Cloud.</li>
<li>Select the registered domain.</li>
<li>Create a new A-Record and enter the IPv4 address of the server.</li>
<li>If available, remove the IPv6 record (AAAA) to avoid compatibility problems.</li>
</ol>
<p>You can also use <a href="http://mxtoolbox.com">MXToolbox</a> to check whether the DNS changes have already been applied.</p>
<h2>Set up Kubernetes</h2>
<p>Kubernetes is a powerful orchestration tool for containers. I use k3s, a lean Kubernetes variant that is particularly suitable for smaller environments.</p>
<h3>Install K3s on the server</h3>
<p>Connect to the server via SSH and install k3s with the following command:</p>
<pre><code class="language-sh">curl -sfL https://get.k3s.io | sh - </code></pre>
<p>The script installs k3s and starts the Kubernetes service. After installation, k3s can be checked with the following command:</p>
<pre><code class="language-sh">kubectl get nodes
</code></pre>
<p>k3s comes with its own kubectl version, so that no separate installation is necessary.</p>
<h3>Create YAML files for FE, BE, MySQL and Redis</h3>
<p>To deploy our application, we need YAML files for:</p>
<ul>
<li>Frontend (Angular)</li>
<li>Backend (NestJS)</li>
<li>Database (MySQL)</li>
<li>Session-Management (Redis)</li>
</ul>
<p>A deployment file for the backend could look like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: dockerhub-user/backend:latest
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  type: ClusterIP
</pre>
<h3>What are deployments and services?</h3>
<ul>
<li>Deployments manage the provision and scaling of containers.</li>
<li>Services ensure a stable network connection between containers.</li>
<li>ClusterIP means that the service is only accessible within the Kubernetes cluster.</li>
</ul>
<h3>Set up Caddy as a reverse proxy</h3>
<p>A reverse proxy is required to ensure that incoming traffic is distributed correctly. K3s comes with Traefik by default, but I opted for a simpler solution: Caddy. I was really surprised how little guidance or documentation there is on Caddy in combination with Kubernetes.</p>
<h3>Why Kubernetes with Caddy?</h3>
<ul>
<li>Automatic Let&#8217;s Encrypt SSL certificates</li>
<li>Simple configuration via Caddyfile</li>
<li>Built-in load balancer</li>
</ul>
<h3>Remove Traefik</h3>
<pre><code class="language-sh">kubectl delete helmrelease traefik -n kube-system
</code></pre>
<h3>Create Caddy Deployment</h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">apiVersion: apps/v1
kind: Deployment
metadata:
  name: caddy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: caddy
  template:
    metadata:
      labels:
        app: caddy
    spec:
      containers:
        - name: caddy
          image: caddy
          volumeMounts:
            - name: caddy-config
              mountPath: /etc/caddy/Caddyfile
      volumes:
        - name: caddy-config
          configMap:
            name: caddy-config
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: caddy-config
data:
  Caddyfile: |

    example.com {
        reverse_proxy backend-service:3000
    }

---
apiVersion: v1
kind: Service
metadata:
  name: caddy-service
spec:
  type: LoadBalancer
  selector:
    app: caddy
  ports:
    - port: 80
      targetPort: 80
    - port: 443
      targetPort: 443</pre>
<p>Important: Since Let&#8217;s Encrypt has a rate limit, tests should first be carried out with staging certificates!</p>
<h2>Conclusion</h2>
<p>After these steps, the application is now running in a Kubernetes cluster on a Hetzner VPS and can be accessed via its own domain. The next step would be to set up an automatic CI/CD pipeline to deploy new versions without manual effort.</p>
<p>The post <a href="https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/">Deployment of a WebApp with Kubernetes and Caddy</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create Docker images and upload them to Docker Hub</title>
		<link>https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/</link>
					<comments>https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 16 Jan 2025 18:16:16 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[Backend]]></category>
		<category><![CDATA[Backend Server]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Docker Hub]]></category>
		<category><![CDATA[Docker Images]]></category>
		<category><![CDATA[Docker Repository]]></category>
		<category><![CDATA[frontend]]></category>
		<category><![CDATA[google cloud mysql]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[mySql]]></category>
		<category><![CDATA[Nest]]></category>
		<category><![CDATA[Nest.js]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[redis session management]]></category>
		<category><![CDATA[redis session management nest.js]]></category>
		<category><![CDATA[Repository]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1691</guid>

					<description><![CDATA[<p>In this article, I will show you how to create production-ready Docker images for a web application with Angular, NestJS, MySQL and Redis and then &#8230; </p>
<p>The post <a href="https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/">Create Docker images and upload them to Docker Hub</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, I will show you how to create production-ready Docker images for a web application with Angular, NestJS, MySQL and Redis and then publish them on Docker Hub. The prerequisite is an installed Docker environment.</p>
<p><em><strong>You might also be interested in this: </strong><a href="https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/">Hosting NestJS on Vercel</a></em></p>
<h2>Creation of the Docker Compose Yml</h2>
<p>With Docker Compose, all components of an application can be defined via a single configuration file and built or started together.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">version: '3.8'

services:
  frontend:
    build: ./frontend
    ports:
      - "80:80"
    depends_on:
      - backend

  backend:
    build: ./backend
    ports:
      - "3000:3000"
    depends_on:
      - mysql
      - redis
    environment:
      - DATABASE_URL=mysql://user:password@mysql:3306/db
      - SESSION_STORE=redis://redis:6379

  mysql:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: db
    ports:
      - "3306:3306"

  redis:
    image: redis:latest
    ports:
      - "6379:6379"</pre>
<h2>Creating the env file</h2>
<p>To manage environment variables centrally, we create an .env file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">DATABASE_URL=mysql://user:password@mysql:3306/db 
SESSION_STORE=redis://redis:6379</pre>
<p>Important: All ENV variables used in the code must also appear in docker-compose.yml!</p>
<h2>Docker image for the frontend</h2>
<p>The Angular frontend must be built for production. Here is an example Dockerfile:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">FROM node:20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build --prod

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf</pre>
<p>Since we are dependent on nginx for the build, we also need a corresponding config file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">server {
  listen 80;
  server_name _;

  location / {
    root /usr/share/nginx/html;
    index index.html;
    try_files $uri $uri/ /index.html;
  }
}</pre>
<h2>Docker image for the backend</h2>
<p>The NestJS backend also needs to be built. Here is an optimized Dockerfile.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># Build stage
FROM node:20 AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build

# Production stage
FROM node:20-alpine
WORKDIR /app

COPY --from=build /app/dist ./dist
COPY package.json package-lock.json ./
RUN npm install --only=production
CMD ["node", "dist/main.js"]</pre>
<h2>Building the app with Docker Compose</h2>
<p>Once all the Dockerfiles have been configured, the images can now be built. The whole thing is really easy with Docker compose.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">docker compose up -d --build</pre>
<p>The images are then ready, the containers are built and the app can be tested locally! The last step is to upload the images to DockerHub so that they can be used more easily later for deployment on a server.</p>
<h2>Uploading to Docker Hub</h2>
<p>Uploading is explained step by step below:</p>
<ol>
<li>Create an account on <a href="https://www.docker.com/products/docker-hub/">Dockerhub</a></li>
<li>Create a repository for the frontend and backend (1 private repo is currently free)</li>
<li>Build the images and tag them:
<pre class="EnlighterJSRAW" data-enlighter-language="generic">docker tag &lt;image-id&gt; dockerAccountName/frontend:latest
docker tag &lt;image-id&gt; dockerAccountName/backend:latest</pre>
</li>
<li>Sign up and push the images:
<pre class="EnlighterJSRAW" data-enlighter-language="generic">docker login
docker push dockerAccountName/frontend:latest
docker push dockerAccountName/backend:latest</pre>
</li>
</ol>
<h2>Outlook: Deployment with Kubernetes</h2>
<p>Now that the images are on Docker Hub, nothing stands in the way of deployment. I have opted for a Kubernetes cluster on a Hetzner VPS. <a href="https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/">More information here</a>.</p>
<p>The post <a href="https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/">Create Docker images and upload them to Docker Hub</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Lessons Learned: Hosting NestJS App on Vercel</title>
		<link>https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/</link>
					<comments>https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 14 Nov 2024 07:19:52 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[cookie-sessions]]></category>
		<category><![CDATA[CORS error]]></category>
		<category><![CDATA[Cors error nest]]></category>
		<category><![CDATA[database config]]></category>
		<category><![CDATA[database hosting]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[express-sessions]]></category>
		<category><![CDATA[express.js]]></category>
		<category><![CDATA[google cloud]]></category>
		<category><![CDATA[google cloud mysql]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[internal server error vercel]]></category>
		<category><![CDATA[internal server error vercel nest]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Lessons Learned]]></category>
		<category><![CDATA[mySql]]></category>
		<category><![CDATA[Nest]]></category>
		<category><![CDATA[Nest hosting issues]]></category>
		<category><![CDATA[NestJs]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[redis session management]]></category>
		<category><![CDATA[redis session management nest.js]]></category>
		<category><![CDATA[session management]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[typescript]]></category>
		<category><![CDATA[Vercel]]></category>
		<category><![CDATA[vercel.json]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[with credentials]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=1621</guid>

					<description><![CDATA[<p>After spending hours getting my NestJS app up and running on Vercel, I figured it was time to document what I learned—not only to save &#8230; </p>
<p>The post <a href="https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/">Lessons Learned: Hosting NestJS App on Vercel</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After spending hours getting my NestJS app up and running on Vercel, I figured it was time to document what I learned—not only to save myself time in the future, but hopefully to help others avoid some of the pitfalls I ran into. Here’s a breakdown of what worked, what didn’t, and how I finally got everything running smoothly.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/import-swagger-in-node-typescript-project/" target="_blank" rel="noopener">Adding Swagger to Node Server</a></em></p>
<h3>Step 1: Setting Up NestJS Vercel hosting</h3>
<p>First things first, getting the basic setup to deploy on Vercel. Vercel is awesome for serverless, but working with NestJS needed a few tweaks. The main thing is to set up a <code>vercel.json</code> configuration file, which tells Vercel exactly how to handle your app.</p>
<p>Here’s the configuration I ended up with:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-theme="beyond">{
  "version": 2,
  "builds": [
    {
      "src": "src/main.ts",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "src/main.ts",
      "methods": [
        "GET",
        "POST",
        "PUT",
        "PATCH",
        "OPTIONS",
        "DELETE",
        "HEAD",
        "CONNECT",
        "TRACE"
      ]
    }
  ]
}
</pre>
<p>I deployed it to Vercel and got the following error:</p>
<pre>This Serverless Function has crashed. Your connection is working correctly. 
Vercel is working correctly. 500: INTERNAL_SERVER_ERROR 
Code: FUNCTION_INVOCATION_FAILED ID: bom1::sgk4v-1711014022883-1e9ed54f4c37</pre>
<p>Looking in the logs, I noticed the database connection was an issue and in addition got the following log message:</p>
<pre>No exports found in module "/var/task/app-name/src/main.js".
Did you forget to export a function or a server?</pre>
<p>Turned out I could ignore the second part of the error message and just focus on the database connection.</p>
<h3>Step 2: Configuring the Database</h3>
<p>For my app, I used a mysql database with multiple schemas. I tried several free offers, but they were not compatible with the multiple schemas approach. Therefore I ended up with hosting it on Google Cloud. I scaled it down to a price of 0.01$ per hour and used the 300$ newbie offer.</p>
<p>Allowing Vercel to connect required setting the IP to <code>0.0.0.0/0</code> in Google Cloud’s configuration, making the database accessible from any IP address. <strong>Important note</strong>: make sure you test locally before deploying to Vercel, or you’ll be dealing with errors like these:</p>
<h3>Step 3: Dealing with CORS</h3>
<p>CORS caused also some headaches. Make sure you allow <code>OPTIONS</code> for CORS preflight requests, as Vercel needed explicit permission for cross-origin requests. I ended up adding a lot of headers to make sure requests were allowed:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-theme="beyond">app.enableCors({
    origin: 'domain-name',
    credentials: true,
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS',
    allowedHeaders: [
      'Origin',
      'X-Requested-With',
      'Content-Type',
      'Accept',
      'Authorization',
    ],
  });</pre>
<h3>Step 4: Switching to <code>express-session</code> and Redis for Session Management</h3>
<p>One of the trickiest parts was getting sessions to work. I started with the <code>cookie-session</code> library, but Vercel completely ignore it. After digging into the docs and some trial and error, I switched to <code>express-session</code>, which is more popular and works nicer with Vercel’s serverless environment.</p>
<p>For some reason the import syntax has to be exactly like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-theme="beyond">import session = require('express-session');</pre>
<p>I also had to configure the session middleware with <code>trust proxy</code> enabled, since Vercel proxies requests. Here’s what the final setup looked like:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-theme="beyond">const expressApp = app.getHttpAdapter().getInstance();
expressApp.set('trust proxy', true);</pre>
<p><span style="font-size: 1.125rem;">Also s</span>etting <code>secure: true</code> and <code>sameSite: 'none'</code> was essential to ensure cookies work across HTTPS and cross-origin requests!</p>
<p>Keep in mind, with Vercel, multiple serverless instances can handle requests simultaneously, which caused session conflicts. To fix this, I connected my session storage to a Redis instance. Luckily this was super easy.</p>
<p><a href="https://redis.io/">Redis</a> keeps session data consistent, avoiding conflicts across requests, especially under load. The code I ended up with:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-theme="beyond">const expressApp = app.getHttpAdapter().getInstance();
expressApp.set('trust proxy', true);

const redisClient = createClient({
    password: process.env.REDIS_PASSWORD,
    socket: {
      host: process.env.REDIS_HOST,
      port: parseInt(process.env.REDIS_PORT, 10),
    },
  });

  redisClient
    .connect()
    .catch((err) =&gt;
      console.log('Could not establish a connection with Redis: ' + err),
    );

  redisClient.on('error', (err) =&gt; console.log('Redis error: ' + err));
  redisClient.on('connect', () =&gt;
    console.log('Connected to Redis successfully'),
  );

  app.use(
    session({
      store: new RedisStore({ client: redisClient }),
      secret: process.env.COOKIE_SECRET,
      cookie: {
        secure: process.env.NODE_ENV !== 'development',
        sameSite: process.env.NODE_ENV === 'development' ? 'lax' : 'none',
        maxAge: 86400000,
      },
    }),
  );</pre>
<p><span style="font-family: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; font-size: 1.75rem;">Step 5: Add </span><code>withCredentials</code><span style="font-family: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; font-size: 1.75rem;"> in the Frontend</span></p>
<p>This step is just a side note: For session cookies to work between the frontend and backend, <code>withCredentials</code> need to be set to <code>true</code> on my frontend’s HTTP requests. This allows cookies to be included in cross-origin requests, which is important when the frontend and backend are hosted separately. I had to make sure Angular’s HTTP client had this setting enabled.</p>
<h3>Step 6: Include font</h3>
<p>To include font files in your NestJS project, you can use the <code>compilerOptions</code> in the <code>nest-cli.json</code> file to define assets for build output, like specifying <code>"include": "**/*.ttf"</code> and <code>"outDir": "dist/src"</code>.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-title="nest-cli.json" data-enlighter-theme="beyond">{
  "$schema": "https://json.schemastore.org/nest-cli",
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "assets": [
      {
        "include": "**/*.ttf",
        "outDir": "dist/src"
      }
    ],
    "deleteOutDir": true
  }
}</pre>
<p>After the build, ensure the fonts are correctly referenced in your code using <code>path.resolve</code>, e.g., <code>path.resolve(__dirname, '../fonts/Roboto-Regular.ttf')</code>. This approach ensures the font files are bundled with the build and accessible during runtime.</p>
<h3>Final Thoughts to NestJS Vercel hosting</h3>
<p>Deploying my NestJS app on Vercel was a true roller coaster. Sometimes, I felt like I was on the verge of getting everything working perfectly, only to be hit with new errors that sent me back to troubleshooting mode. There were moments of frustration—especially around the session handling and CORS issues. But each solution brought a new high, and every error fixed felt like a little victory.</p>
<p>Now, with everything finally working smoothly, I can say it feels awesome. Seeing my app live and functioning the way I envisioned is worth all the headaches. It’s a huge relief, but even more, it’s deeply satisfying to know I’ve overcome each hurdle and can look back on what I learned. I hope this guide can save others some of those low points and help them reach that “it just works” moment a little faster!</p>
<p>The post <a href="https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/">Lessons Learned: Hosting NestJS App on Vercel</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/lessons-learned-hosting-nestjs-app-on-vercel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mini Digital Voltmeter</title>
		<link>https://nerd-corner.com/mini-digital-voltmeter/</link>
					<comments>https://nerd-corner.com/mini-digital-voltmeter/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Wed, 09 Oct 2024 15:02:19 +0000</pubDate>
				<category><![CDATA[Handcrafted]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[digital mini voltmeter]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[mini voltmeter]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Voltmeter]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1607</guid>

					<description><![CDATA[<p>If you want to measure voltage with a voltmeter or multimeter, you normally need two hands. But usually you only have one hand free. You &#8230; </p>
<p>The post <a href="https://nerd-corner.com/mini-digital-voltmeter/">Mini Digital Voltmeter</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If you want to measure voltage with a voltmeter or multimeter, you normally need two hands. But usually you only have one hand free. You can of course use crocodile clips or similar to help you, but this is usually awkward. Especially in experimental setups, you often have to measure the voltage at different points to analyze the behavior of the circuit.</p>
<p>The solution to my problem is the mini-voltmeter, which I have used many times in various projects in the past. The accuracy of the mini-voltmeter is usually sufficient and my projects tend to be in the low-voltage range. In addition, the mini voltmeters are relatively inexpensive and you can get them everywhere.</p>
<p>I also use USB multimeters to measure voltage and current, which save the values at the same time. Figure 1.0 shows some USB multimeters that can handle more or less voltage. Some devices are very expensive and the maximum number of amperes that can be measured also varies. If you only want to measure voltage and don&#8217;t have much of a budget, my project is just right for you.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1601 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1.jpg" alt="different volt meters" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p><em><strong>This might also interest you:</strong> <a href="https://nerd-corner.com/diy-powerbank-with-voltage-regulator-and-voltmeter/">Do it yourself power bank with voltage regulator and voltmeter</a></em></p>
<h2>List of components</h2>
<ul>
<li>Mini voltmeter DSN-DUM-368 /or DSN-DMU-368k (Figure 2.0.1)</li>
<li>Hollow socket 5.5&#215;2.1 (Figure 2.0.2)</li>
<li>Hollow plug 5.5&#215;2.1 (image 2.0.3)</li>
<li>USB micro adapter board optional (picture 2.0.4)</li>
<li>M2 x 10 countersunk head screw 6x (without picture)</li>
<li>M2 x 4 cylinder head screw 2x optional (without picture)</li>
<li>Cable 0.5mm² (without picture)</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1600 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2.jpg" alt="list of components" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-2-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>As can be seen in Fig. 3.0, there are two different types of mini voltmeters. The one with two cables (Figure 3.0.1) and the one with three cables (Figure 3.0.2).<br />
The main difference is that with the mini-voltmeter with two cables, the supply voltage is the same as the voltage to be measured (Figure 3.0.1).</p>
<p>However, there is a problem with this variant. If the voltage is below 4.7V, the mini-voltmeter will no longer work as it requires a supply voltage of at least 4.7V. So if you want to measure a voltage below 4.7V, you need a supply voltage above 4.7V and a separate cable to measure the voltage (Fig. 3.0.2).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1599 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/Voltmeter-3-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>You can also convert a mini-voltmeter with three cables into a mini-voltmeter with two cables. You only need to solder a bridge between +Ub and input at jumper-1 (Figure 3.1.1). Jumpers two to four are used for fine adjustment of the mini-voltmeter (Fig. 3.1.1), in some cases the step widths are printed on as in Fig. 3.0.1.<br />
How such a mini-voltmeter is constructed in detail is documented <a style="font-size: 1.125rem;" href="https://chinese-electronics-products-tested.blogspot.com/p/dsn-dvm-368-digital-voltmeter-tested.html" target="_blank" rel="noopener">here </a><span style="font-size: 1.125rem;">or </span><a style="font-size: 1.125rem;" href="https://chinese-electronics-products-tested.blogspot.com/p/dsn-dvm-368-digital-voltmeter-tested.html" target="_blank" rel="noopener">here </a><span style="font-size: 1.125rem;">for example.</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1598 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/voltmeter-3.1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Construction</h2>
<p>Because of these two different types, I have decided to construct two housings. Let&#8217;s start with the variant for the two-cable mini-voltmeter. In the past, I have installed mini-voltmeters in enclosures several times and in doing so have become familiar with the challenges of dimensional accuracy and the diversity of variants from different manufacturers. Despite supposedly standardized components, you often have to reckon with slight deviations in the dimensions. It is therefore important to take larger tolerances into account in the design.</p>
<p>One of the housings I designed was intended for the LM2587 step-up module (Figure 3.2.1). This housing seemed suitable for modification to meet the new requirements. It already contains holders for the hollow plug (2.0.3) and the hollow socket (2.0.2) that I want to use. There is also already a recess in the cover for the mini voltmeter (2.0.1). I am largely satisfied with the dimensions (Figure 3.2.2), apart from the length. What bothers me, however, is the position of the voltmeter in the lid &#8211; it should be placed more centrally, i.e. closer to the middle.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1597 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/3-2.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/3-2.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/3-2-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>First I start with the modification of the lid. I&#8217;m happy with the width and height, but the housing is too long. I therefore shorten the cover on the side where the hollow socket (2.0.2) is attached. This does not affect the holder of the hollow plug, as this is already perfectly matched to the plug. When shortening, care must be taken to ensure that the internal components do not touch and that there is sufficient space for the cabling. However, you should not overdo it with the reduction in size, as stability and feel are also important factors in a design.</p>
<p>After weighing up all the factors, I shorten the length of the housing or cover to 63.5 mm, and the position of the mini-voltmeter is now centered on the cover (Figure 4.0.1). I have removed the hole for adjusting the LM2587S (marked in white) and the ventilation slots, as no adjustment is required and no ventilation is necessary due to the low heat development.</p>
<p>In picture 4.0.2 (marked in red) you can see that I have changed the recesses or pockets, as some mini voltmeters have a flat surface instead of tabs (picture 4.0.3).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1596 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/4-0-1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>In the next step, I shorten the housing to 63.5 mm, similar to the cover. I also remove the mounting pillars for the <a href="https://nerd-corner.com/improved-lm2587s-voltage-converter-step-up-modul-dc-dc/">LM2587S</a> module, as shown in Figure 4.1.1. On the side of the hollow socket, I remove the recess and move the hole pattern 1 mm upwards, towards the cover (Fig. 4.1.2). Finally, the lettering is corrected to VOLT METER.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1595 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/4-1-1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>3D print of the first variant</h2>
<p>Let&#8217;s move on to printing the parts for our variant 1 with two cables. We only need three parts for this variant:</p>
<ul>
<li>Housing Fig. 5.0.1</li>
<li>Cover Fig. 5.0.2</li>
<li>Hollow socket holder Fig. 5.0.3</li>
</ul>
<p>There are no special requirements for printing these parts and no special material is needed. In this case, I used inexpensive PLA from a reliable manufacturer. The printing was done on a Prusa MK4 with the usual standard settings.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1594 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/5-0.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/5-0.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/5-0-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>When reworking the printed parts for variant one, only four M2 threads need to be cut into the housing (Fig. 6.0.1) and two M2 threads on the mounting bridge for the hollow bushing (Fig. 6.0.2). Two M2 threads must also be cut in the cover (Figure 6.0.3). Alternatively, self-tapping screws can be used or the parts can be partially glued.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1593 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/6-0.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/6-0.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/6-0-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Soldering and wiring the first variant</h2>
<p>Once all the parts for variant one have been printed and processed, the hollow socket is soldered to the cables. The positive and negative poles to which the cables are soldered are marked in Figure 6.1.1 (Figure 6.1.2). The cables of the hollow socket and the mini voltmeter are then screwed into the hollow plug (Fig. 6.1.3). Whether the cables are twisted or soldered at the ends is a matter of taste. I always connect the cables of the mini-voltmeter to the current output. Figure 6.1.4 shows the complete inner workings soldered and wired. To stabilize the solder joints on the mini-voltmeter, I reinforced them with a small drop of hot glue. Finally, the hollow socket is inserted into the back of the housing and the hollow plug is pushed into the recess provided (Fig. 6.1.5).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1592 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/6-1.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/6-1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/6-1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>In the penultimate step, I push the mini-voltmeter into the cut-out provided in the cover and secure it by screwing or gluing it in place (Fig. 6.2.1). The cover is then screwed to the housing (Figure 6.2.2). Finally, carry out a function test (Figure 6.2.3).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1591 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/6-2.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/6-2.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/6-2-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Construction of the second variant</h2>
<p>If you do not want to measure or display the voltage below 4.7 V with the mini-voltmeter, you can stop at this point. However, as I mentioned at the beginning, it is possible to operate these mini-voltmeters with three cables. This option is available if jumper1 (Figure 3.1.1) is not set or not bridged. As the mini-voltmeter requires a minimum supply voltage of 4.7 V in order to function, we need a second voltage source that is above this limit.</p>
<p>In variant one of the housing, however, there is only one input, which is why a second current input is required. As I don&#8217;t want to change the dimensions of the housing and there is hardly any space for a second hollow socket, an alternative solution is needed. The solution is a micro-USB board (Figure 2.0.4), which is flat and based on the widely used micro-USB standard.</p>
<p>The question now arises as to where the second connection should be positioned. A side connection would take up too much space, e.g. on a table, as the cable would protrude upwards or downwards at a 90° angle. For me, the best solution is to place the USB port on the same side as the hollow socket.</p>
<p>The next question concerns the mounting of the micro USB board: should it be attached directly to the housing or simply glued on? After careful consideration, I decided to mount the board on the retaining bridge of the hollow socket (Figures 5.0.3, 6.0.2 and 7.0.1). In picture 7.0.2 you can see how I attached a plate to the holder bridge. This plate has two M2 threaded holes (marked in white) for attaching the micro USB board and two cut-outs for cables and solder.</p>
<p>On the housing (Figure 7.0.3), the drilling pattern (marked red) must be moved 1.5 mm towards the cover to create space for the slot of the micro USB connector. The slot (marked yellow) is positioned below the hollow socket.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1590" style="font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2024/10/7-0.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/7-0.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/7-0-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Printing is relatively quick. We need the housing with USB slot (Fig. 8.0.1), the cover (Fig. 8.0.2) and the new holder for the hollow socket and USB board (Fig. 8.0.3).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1589 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/8-0.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/8-0.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/8-0-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>In the post-processing of the printed parts for variant “two”, the thread must now be cut. M2 4x on the housing (Fig. 9.0.1) and 4x M2 mounting bridge for the hollow socket and USB board (Fig. 9.0.2). Two M2 threads must also be cut on the cover (Fig. 9.0.3).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1588 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/9-0.jpg" alt="" width="2310" height="1374" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/9-0.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-1024x609.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-768x457.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-1536x913.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-2048x1218.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-890x530.jpg 890w, https://nerd-corner.com/wp-content/uploads/2024/10/9-0-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Soldering and screwing the second variant</h2>
<p>The parts must now be soldered and screwed together, as in variant one (Fig. 6.1). It should be noted that there is now an additional cable and the wiring is different to variant one. The mini-voltmeter is now powered externally via the micro-USB connection. The negative pole is routed from the hollow socket (9.1.3) to the USB board (9.1.1), then to the mini-voltmeter (9.1.2) and finally to the hollow plug (9.1.4).</p>
<p>The positive cable for the power supply of the mini-voltmeter (9.1.2) goes from the positive pole of the micro USB (9.1.1) directly to the positive pole of the mini-voltmeter (9.1.2). The main power cable runs from the positive pole of the hollow socket (9.1.3) to the positive pole of the hollow plug (9.1.4). The test lead runs directly from the mini-voltmeter (9.1.2) to the positive pole of the hollow plug (9.1.4).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1587 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/9-1.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/9-1.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/9-1-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Figure 9.2.1 shows how to screw the USB board (9.1.1) to the hollow socket holder (9.0.2). Figure 9.2.2 shows the hollow socket 9.1.3 and the USB board 9.1.1 completely soldered, screwed to the hollow socket holder and then fixed again with hot glue. The result can be seen in picture 9.2.1.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1586 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/9-2.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/9-2.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/9-2-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>After successfully soldering and gluing, I assemble the mini-voltmeter variant “two”. First, I insert the retaining bridge for the hollow socket and USB board into the back of the housing and screw it in from the outside (Fig. 9.3.1).</p>
<p>The hollow plug is then inserted into the recess provided and pressed down to the bottom (Fig. 9.3.2). Now press the mini-voltmeter into the cover and either screw or glue it in place (Fig. 9.3.3). Finally, the cover is fitted and screwed on with the M2 screws (Fig. 9.3.4).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1585 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/9-3.jpg" alt="" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/9-3.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/9-3-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<h2>Function test</h2>
<p>Now it&#8217;s time for the essential function test. For this we need a micro USB power supply unit and a 12V power supply unit with a 5.5&#215;2.1 mm hollow plug. First, I connect the micro USB power supply, which supplies 5V, to the housing. The display of the mini-voltmeter lights up and shows zero (Figure 9.4.1). This is the expected result, as there is still no voltage on the line to be measured. Only when I connect the 12V power supply unit with hollow plug does the mini-voltmeter correctly display 12V (Fig. 9.4.2).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1603 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/10/9-4.jpg" alt="DIY voltmeter" width="2310" height="1371" srcset="https://nerd-corner.com/wp-content/uploads/2024/10/9-4.jpg 2319w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-300x178.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-1024x608.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-768x456.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-1536x911.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-2048x1215.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2024/10/9-4-445x265.jpg 445w" sizes="auto, (max-width: 2310px) 100vw, 2310px" /></p>
<p>Everything works perfectly and adds value for me in the workshop.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1602 size-full" src="https://nerd-corner.com/wp-content/uploads/2024/10/Mini_Voltmeter.gif" alt="mini digital voltmeter" width="781" height="492" /></p>
<p>&nbsp;</p>
<h2>Files to download</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:6531794">Mini digital voltmeter</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/mini-digital-voltmeter/">Mini Digital Voltmeter</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/mini-digital-voltmeter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using a barrel jack as a switch</title>
		<link>https://nerd-corner.com/using-a-barrel-jack-as-a-switch/</link>
					<comments>https://nerd-corner.com/using-a-barrel-jack-as-a-switch/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Tue, 18 Jun 2024 17:11:28 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[barrel jack]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[Powerbank]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[user guide]]></category>
		<category><![CDATA[Voltmeter]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1577</guid>

					<description><![CDATA[<p>In many everyday devices, such as battery-operated radios, lamps, torches and especially laptops, a barrel jack is used for the power supply. In these cases, &#8230; </p>
<p>The post <a href="https://nerd-corner.com/using-a-barrel-jack-as-a-switch/">Using a barrel jack as a switch</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In many everyday devices, such as battery-operated radios, lamps, torches and especially laptops, a barrel jack is used for the power supply. In these cases, the barrel jack often serves as a switch: as soon as a plug is inserted, the power supply from the battery, rechargeable battery or other source is interrupted and the device is supplied with power directly from the plug, thus saving the battery. The primary circuit is disconnected purely mechanically.</p>
<p><em><strong>This might also be interesting for you: </strong><a href="https://nerd-corner.com/diy-powerbank-with-voltage-regulator-and-voltmeter/">Do it yourself powerbank with voltage regulator and voltmeter</a></em></p>
<h2>List of components</h2>
<p>To demonstrate the function, I have decided on a small test setup. I need the following for my test setup:</p>
<ul>
<li>Barrel jack 5,5 x 2,1 (1.0.1)</li>
<li>Voltmeter (1.0.2)</li>
<li>5V power supply unit (1.0.3)</li>
<li>Barrel jack holder (1.0.4)</li>
<li>Barrel jack Bridge(1.0.5)</li>
<li>Some cables (1.0.6)</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1569 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/06/1-0.jpg" alt="Hohlbuchse komponenten" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/1-0.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/1-0-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/1-0-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/1-0-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/1-0-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/1-0-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<h2>Assembly instructions for bracket and bridge</h2>
<p>The first step is to print the holder (1.0.4) and the bridge (1.0.5) with the 3D printer. After cleaning the printed parts, I cut two M2 threads into the holder (see 2.0.1). If you prefer to work with self-tapping screws, you can skip this step. The barrel jack is then pushed into the large hole in the bridge (2.0.2) and screwed tight with the nut on the front of the bridge (2.0.3). Fitting the bridge to the bracket is also very simple: Slide the bridge with the recesses on the right and left over the two cylinder surfaces on the bracket (2.0.4) and secure it with M2 screws (2.0.5). The bracket and bridge with the barrel jack fitted form a very stable unit that can absorb large forces. If everything is fitted correctly, the barrel jack should not protrude, but should be recessed by 0.3 to 0.5 mm.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1574 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/06/2-0.jpg" alt="jack socket hohlstecker" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/2-0.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/2-0-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/2-0-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/2-0-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/2-0-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/2-0-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<h2>Wiring and soldering the barrel jack</h2>
<p>Now we come to the core of this article: wiring and soldering the barrel jack. I use pre-assembled plugs and sockets that already contain crimped cables and a strain relief. The colour coding of the cables is also practical, as red stands for plus and black for minus (3.0.1).</p>
<p>The barrel jack with switching function usually has three solder lugs. The negative pole is always switched, i.e. in figure 3.0.2 this corresponds to number two. The negative pole of the primary power supply, e.g. battery or accumulator, is also soldered on here. Solder lug number one is intended for the common positive terminal; all positive connections are soldered here. The negative pole to the consumers in the device is soldered to soldering lug number three. Figure 3.0.3 shows the complete soldering of the barrel jack.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1573" src="https://nerd-corner.com/wp-content/uploads/2024/06/3-0.jpg" alt="jack socket hohlstecker" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/3-0.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/3-0-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/3-0-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/3-0-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/3-0-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/3-0-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<h2>Assembly and connection</h2>
<p>After successful soldering, you can now continue with the rest of the test setup. Firstly, the holder with the soldered barrel jack is screwed onto a wooden plate (4.0.1). The two mini-voltmeters are then attached to the wooden plate (4.0.2). The mini voltmeters are a creation of Nerd Corner. <a href="https://nerd-corner.com/diy-powerbank-with-voltage-regulator-and-voltmeter/">If you are interested in such housings, you can read the corresponding article and download the STL files at the following link.</a></p>
<p>Now I connect the cables soldered to the barrel jack to the mini-voltmeters (see Figure 4.0.2, pink frame). Next, I connect the primary power source to my 5V power supply and switch it on (see Figure 4.0.3, yellow frame). After switching on the power supply, a voltage is present at both mini voltmeters: 5.35 volts at the supply (red circle) and 5.28 volts at the load (green circle).</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1572 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/06/4-0.jpg" alt="jack socket hohlstecker" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/4-0.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/4-0-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/4-0-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/4-0-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/4-0-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/4-0-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<h2>Integration of the second power source</h2>
<p>As the current flows cleanly via the barrel jack to the consumer, the second power source now comes into play. I operate this with 12 V in order to have a clear difference to the primary power supply. Figure 4.1.1 shows the second power supply with 12.2 volts (turquoise frame).</p>
<p>Now I plug the second power supply with 12 volts into the barrel jack (Figure 4.1.2, blue frame). After a short delay, the value on the consumer&#8217;s mini-voltmeter changes to 12 volts (green frame). Nothing has changed on the primary power supply; it remains plugged in and switched on (red frame). The value is still 5.34 volts, which is 0.01 volts lower than before the second power supply was plugged in, but this is due to the fluctuations of the 5V power supply.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1571 zoooom" src="https://nerd-corner.com/wp-content/uploads/2024/06/4-1.jpg" alt="jack socket hohlstecker" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/4-1.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/4-1-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/4-1-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/4-1-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/4-1-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/4-1-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<p>As a final step, I remove the 5 volt power supply unit from the primary circuit to check whether there really is no voltage on the primary circuit. Figure 4.2.1 in the yellow frame remains dark and so the test was successful!</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1570" src="https://nerd-corner.com/wp-content/uploads/2024/06/4-2.jpg" alt="barrel jack switch hohlstecker" width="2280" height="1332" srcset="https://nerd-corner.com/wp-content/uploads/2024/06/4-2.jpg 2291w, https://nerd-corner.com/wp-content/uploads/2024/06/4-2-300x175.jpg 300w, https://nerd-corner.com/wp-content/uploads/2024/06/4-2-1024x598.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2024/06/4-2-768x449.jpg 768w, https://nerd-corner.com/wp-content/uploads/2024/06/4-2-1536x897.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2024/06/4-2-2048x1196.jpg 2048w" sizes="auto, (max-width: 2280px) 100vw, 2280px" /></p>
<p>&nbsp;</p>
<h2>Files for Downloading</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:6313994">Barrel jack holder and bridge</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/using-a-barrel-jack-as-a-switch/">Using a barrel jack as a switch</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/using-a-barrel-jack-as-a-switch/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WeMos D1 R2 &#8211; Host entire website with html, css &#038; js</title>
		<link>https://nerd-corner.com/wemos-d1-r2-host-entire-website-with-html-css-js/</link>
					<comments>https://nerd-corner.com/wemos-d1-r2-host-entire-website-with-html-css-js/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Wed, 06 Mar 2024 12:18:52 +0000</pubDate>
				<category><![CDATA[Arduino projects]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Arduino with Wifi]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[communication technique]]></category>
		<category><![CDATA[control Arduino with browser]]></category>
		<category><![CDATA[data transfer]]></category>
		<category><![CDATA[entire website]]></category>
		<category><![CDATA[ESP8266]]></category>
		<category><![CDATA[ESP8266 with mDNS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[local network]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Webserver]]></category>
		<category><![CDATA[website hosting]]></category>
		<category><![CDATA[WeMos]]></category>
		<category><![CDATA[WeMos D1]]></category>
		<category><![CDATA[WeMos D1 in Arduino IDE]]></category>
		<category><![CDATA[WeMos D1 mini]]></category>
		<category><![CDATA[WeMos D1 R2]]></category>
		<category><![CDATA[WeMOS D1 Webserver]]></category>
		<category><![CDATA[WIFI]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1547</guid>

					<description><![CDATA[<p>The first part of the WeMos series explained the setup and Wi-Fi integration. Building on this, this article describes step by step how to host &#8230; </p>
<p>The post <a href="https://nerd-corner.com/wemos-d1-r2-host-entire-website-with-html-css-js/">WeMos D1 R2 &#8211; Host entire website with html, css &#038; js</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The first part of the WeMos series explained the setup and Wi-Fi integration. Building on this, this article describes step by step how to host a complete website with HTML pages, CSS styling and JavaScript functions on a WeMos. The whole thing is pretty simple and incredibly helpful! I can&#8217;t believe how hard it is to find proper instructions for this important function anywhere on the internet.</p>
<p>I often see blog articles where the HTML code is embedded in the Arduino file. You can do this for a mini demonstration, but it&#8217;s complete rubbish for everyday use. It is far too confusing and as soon as the project grows it is no longer usable.</p>
<p>The proper alternative is to set up a folder called &#8220;data&#8221; and store the web pages in this folder as html files. In addition, the styling is saved as a CSS file and functions can even be executed via a JavaScript file. So everything is 1:1 like on a normal web server!</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/wemos-d1-r2-setup-and-wifi-integration/">WeMos D1 R2 first steps and Wifi integration</a></em></p>
<h2>List of components</h2>
<ul>
<li>Arduino IDE (development environment)</li>
<li>WeMos D1 R2</li>
</ul>
<h2>The setup of the file system (officially SPIFFS) needs to be done once and is very easy:</h2>
<p><a href="https://nerd-corner.com/wemos-d1-r2-setup-and-wifi-integration/">(First you should have completed the basic setup from the first part!)</a></p>
<ol>
<li>Download a copy of the file &#8220;ESP8266FS-0.2.0.zip&#8221; from GitHub and unzip it</li>
<li>Place the file esp8266fs.jar in the Arduino tool directory. The path looks like this: [home_dir]\Arduino\tools\ESP8266FS\tool\esp8266fs.jar (See picture) I had to create the path part tools\ESP8266FS\tool\ in the Arduino folder myself.<img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1531" src="https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-file-path-esp8266fs.jar-.png" alt="Screenshot file path esp8266fs.jar" width="1080" height="335" srcset="https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-file-path-esp8266fs.jar-.png 1190w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-file-path-esp8266fs.jar--300x93.png 300w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-file-path-esp8266fs.jar--1024x318.png 1024w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-file-path-esp8266fs.jar--768x238.png 768w" sizes="auto, (max-width: 1080px) 100vw, 1080px" /></li>
<li>Restart the Arduino IDE.</li>
</ol>
<p>That&#8217;s it already! You can now see the new item &#8220;ESP8266 Sketch Data Upload&#8221; in the Arduino IDE under Tools.</p>
<h2>How can I use the new file system now?</h2>
<ol>
<li>Create an additional folder with the name &#8220;data&#8221; in your current WeMos project folder. As shown in the following image</li>
</ol>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1528" src="https://nerd-corner.com/wp-content/uploads/2024/03/Wemos-data-folder.png" alt="Wemos data folder" width="1040" height="324" srcset="https://nerd-corner.com/wp-content/uploads/2024/03/Wemos-data-folder.png 1146w, https://nerd-corner.com/wp-content/uploads/2024/03/Wemos-data-folder-300x93.png 300w, https://nerd-corner.com/wp-content/uploads/2024/03/Wemos-data-folder-1024x319.png 1024w, https://nerd-corner.com/wp-content/uploads/2024/03/Wemos-data-folder-768x239.png 768w" sizes="auto, (max-width: 1040px) 100vw, 1040px" /></p>
<ol start="2">
<li>Place the files you want to upload in the &#8216;data&#8217; directory</li>
<li>In the Arduino IDE, select the WeMos in the &#8216;Tools&#8217; menu and select a size for &#8216;Flash Size&#8217;</li>
<li>Close the dialogue box for the serial monitor!</li>
<li>Select the &#8216;ESP8266 Sketch Data Upload&#8217; option from the &#8216;Tools&#8217; menu.</li>
</ol>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1529" src="https://nerd-corner.com/wp-content/uploads/2024/03/data-folder-upload.png" alt="Data folder upload" width="805" height="518" srcset="https://nerd-corner.com/wp-content/uploads/2024/03/data-folder-upload.png 851w, https://nerd-corner.com/wp-content/uploads/2024/03/data-folder-upload-300x193.png 300w, https://nerd-corner.com/wp-content/uploads/2024/03/data-folder-upload-768x495.png 768w" sizes="auto, (max-width: 805px) 100vw, 805px" /></p>
<p>As soon as the upload is complete, the message window of the Arduino IDE shows 100% upload.</p>
<h2>WeMos example programme for switching the OnBoard LED on and off</h2>
<p>Similar to the first part, the web server will control the OnBoard LED. The code from the first part also serves as the basis. The revised code looks like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="atomic" data-enlighter-title="D1_webserver_filesystem">#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include &lt;ESP8266mDNS.h&gt;

ESP8266WebServer server(80);

void setup() {
  Serial.begin(115200); //Baudrate
  Serial.println("ESP starts");

  WiFi.begin("NerdCornerWiFi","NerdCornerPassword");


  Serial.print("Connecting...");

  while(WiFi.status()!=WL_CONNECTED){ //Loop which makes a point every 500ms until the connection process has finished

    delay(500);
    Serial.print(".");
  }
  Serial.println();

  Serial.print("Connected! IP-Address: ");
  Serial.println(WiFi.localIP()); //Displaying the IP Address

  if (MDNS.begin("nerd-corner")) {
    Serial.println("DNS started, available with: ");
    Serial.println("http://nerd-corner.local/");
  }

  server.serveStatic("/", SPIFFS, "/", "max-age=86400");
  SPIFFS.begin();

  server.onNotFound([](){ 
    server.send(404, "text/plain", "Landing page not found! Don't forget to name your landing page 'index.html'!");  
  });
 
  server.on("/led", HTTP_POST, []() {    
     
    const String ledState = server.arg("ledstate");
    if(ledState=="on"){
      switchLedOn();
    }
    else if(ledState=="off"){
      switchLedOff();
    }
    server.send(200, "text/json", "{\"result\":\"ok\"}");
  });

  server.begin();
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  server.handleClient();
  MDNS.update();

}

void switchLedOff(){ 
  digitalWrite(LED_BUILTIN, HIGH);   // turn the D1 LED off 
}

void switchLedOn(){ 
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED on 
}</pre>
<p>I would like to point out a few special features. For example, we have added the following:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="atomic">server.serveStatic("/", SPIFFS, "/", "max-age=86400"); 
SPIFFS.begin();</pre>
<p>Without these two lines, access to the files in the &#8220;data&#8221; folder would not be possible. Please note that the name &#8220;index.html&#8221; is set as the default for the landing page. However, you can change this if you really want to.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="atomic">server.on("/led", HTTP_POST, []() {    
     
    const String ledState = server.arg("ledstate");
    if(ledState=="on"){
      switchLedOn();
    }
    else if(ledState=="off"){
      switchLedOff();
      }
      server.send(200, "text/json", "{\"result\":\"ok\"}");
  });</pre>
<p>The &#8220;/led&#8221; endpoint receives the commands from the web server. If the command is &#8220;on&#8221;, the LED is switched on and if &#8220;off&#8221;, the LED is switched off.</p>
<h2>Wemos website for switching the WeMos OnBoard LED on and off</h2>
<p>The example website has a very simple structure. It primarily consists of 2 buttons for switching the LED on and off.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1536" src="https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control.jpeg" alt="Website Wemos control LED" width="875" height="1946" srcset="https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control.jpeg 921w, https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control-135x300.jpeg 135w, https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control-461x1024.jpeg 461w, https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control-768x1708.jpeg 768w, https://nerd-corner.com/wp-content/uploads/2024/03/Webseite-Wemos-Control-691x1536.jpeg 691w" sizes="auto, (max-width: 875px) 100vw, 875px" /></p>
<p>The folder structure of the website is very clearly organised. There is a main page with the name &#8220;index.html&#8221;. This name is common worldwide for the main pages and is also automatically recognised by WeMos. There is also a &#8220;CSS&#8221; folder for styling and a &#8220;JS&#8221; folder for functions.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1537" src="https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-data-file-system.png" alt="Screenshot esp8266 data file system" width="1045" height="347" srcset="https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-data-file-system.png 1152w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-data-file-system-300x100.png 300w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-data-file-system-1024x340.png 1024w, https://nerd-corner.com/wp-content/uploads/2024/03/Screenshot-data-file-system-768x255.png 768w" sizes="auto, (max-width: 1045px) 100vw, 1045px" /></p>
<p>We link the styles in the header area of the website. There is a standard bootstrap, which automatically makes everything a bit nicer, and a custom styles file with my own customisations. The functions of the website are also linked in the header area. I use the jQuery standard to send requests from the website to the WeMos. My own custom functions are in the &#8220;index.js&#8221;.</p>
<p>Please note that the jQuery file must be included BEFORE your own file, otherwise no jQuery commands can be used in your own code! The custom functions are then used by the buttons. The HTML code of the page looks as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="html" data-enlighter-theme="atomic">&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;&lt;/html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    /&gt;
    &lt;script type="text/javascript" src="js/jquery-3.5.1.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="./js/index.js"&gt;&lt;/script&gt;
    &lt;link rel="stylesheet" href="css/bootstrap.min.css" /&gt;
    &lt;link rel="stylesheet" href="css/custom-style.css" /&gt;
    &lt;title&gt;D1 Webserver&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h1&gt;D1 Webserver with filesystem&lt;/h1&gt;
    &lt;p&gt;
      This is an example for a WeMos Webserver with a filesystem. You can easily
      create webpages with html, css and js!
    &lt;/p&gt;

    &lt;h3&gt;Example to turn on and off the built in LED&lt;/h3&gt;
    &lt;button class="button-style" onclick="changeLEDState('on')"&gt;Turn on&lt;/button&gt;
    &lt;button class="button-style" onclick="changeLEDState('off')"&gt;
      Turn off
    &lt;/button&gt;

    &lt;h3&gt;Example to demo a JS function&lt;/h3&gt;
    &lt;button class="button-style" onclick="showAlert()"&gt;Show alert&lt;/button&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Special attention is paid to the JavaScript function &#8220;changeLEDState(value)&#8221;</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js" data-enlighter-theme="atomic">function changeLEDState(value) {
  $.post("/led", { ledstate: value });
}</pre>
<p>Because jQuery is used for communication with the WeMos, a simple dollar sign with the corresponding request command is sufficient. A value is also sent with this POST request, which is either &#8220;on&#8221; or &#8220;off&#8221; to switch the LED on and off.</p>
<p>The web page can be downloaded as a zip file below.</p>
<h2>Files to download</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/1540/?tmstv=1756337102" rel="nofollow" id="download-link-1540" data-redirect="false" >
	Wemos example webserver to control OnBoard LED</a>
</li>
</ul>
<p>The post <a href="https://nerd-corner.com/wemos-d1-r2-host-entire-website-with-html-css-js/">WeMos D1 R2 &#8211; Host entire website with html, css &#038; js</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/wemos-d1-r2-host-entire-website-with-html-css-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Enable TensorFlow GPU under Windows</title>
		<link>https://nerd-corner.com/enable-tensorflow-gpu-under-windows/</link>
					<comments>https://nerd-corner.com/enable-tensorflow-gpu-under-windows/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Tue, 09 May 2023 21:40:43 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[graphics card]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[ML]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Tensorflow]]></category>
		<category><![CDATA[TensorFlow GPU]]></category>
		<category><![CDATA[Tensorflow guide]]></category>
		<category><![CDATA[user guide]]></category>
		<category><![CDATA[Windows]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1376</guid>

					<description><![CDATA[<p>I am currently working on a hobby project where I want to translate German sentences into Bavarian using AI, for example on the website Dialektl.com. &#8230; </p>
<p>The post <a href="https://nerd-corner.com/enable-tensorflow-gpu-under-windows/">Enable TensorFlow GPU under Windows</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I am currently working on a hobby project where I want to translate German sentences into Bavarian using AI, for example on the website <a href="http://dialektl.com" target="_blank" rel="noopener">Dialektl.com</a>. I am working with Tensorflow, an open source platform for machine learning and deep learning. Tensorflow is one of the most widely used libraries for Deep Learning because it offers a wide range of features and a very active developer community. For almost all machine learning models, the training process is extremely computationally expensive. To increase the speed of the training process, it is recommended to use the computer&#8217;s graphics card (GPU) instead of the processor (CPU).</p>
<p>My naive thought was that Tensorflow would automatically use the GPU. However, you first have to follow the step-by-step instructions below in order for Tensorflow to recognise and use the GPU at all.</p>
<p><em><strong>You might also be interested in:</strong> <a href="https://nerd-corner.com/tensorflow-js-vs-tensorflow-python/">Should I use Tensorflow.js or Tensorflow (Python)?</a></em></p>
<p><strong>DISCLAIMER: As of version 2.11, Tensorflow no longer supports GPUs under Windows! Either change the operating system or downgrade Tensorflow to version 2.10. In addition, a graphics card from NVIDIA is required!</strong></p>
<h3>1. Checking the desired CUDA and cuDNN versions</h3>
<p>First, you should find out which CUDA and cuDNN version you need for TensorFlow. The website lists all versions of Tensorflow and the desired CUDA versions or cuDNN versions:<a href="https://www.tensorflow.org/install/source_windows#gpu"> https://www.tensorflow.org/install/source_windows#gpu</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1372 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/tensorflow_requirements.png" alt="tensorflow requirements" width="1120" height="562" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/tensorflow_requirements.png 1128w, https://nerd-corner.com/wp-content/uploads/2023/05/tensorflow_requirements-300x151.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/tensorflow_requirements-1024x514.png 1024w, https://nerd-corner.com/wp-content/uploads/2023/05/tensorflow_requirements-768x385.png 768w" sizes="auto, (max-width: 1120px) 100vw, 1120px" /></p>
<h2>2. Checking your own graphics card</h2>
<p>As already mentioned in the disclaimer, the graphics card must be from NVIDIA. On the website <a href="https://developer.nvidia.com/cuda-gpus" target="_blank" rel="noopener">https://developer.nvidia.com/cuda-gpus</a> you can search for your own GPU and check the &#8220;Compute Capability&#8221;. The minimum requirement for Tensorflow is a value of 3.5, but this is fulfilled by all current graphics cards.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1371 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/cuda-architectures.png" alt="cuda architectures" width="1120" height="158" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/cuda-architectures.png 1129w, https://nerd-corner.com/wp-content/uploads/2023/05/cuda-architectures-300x42.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/cuda-architectures-1024x144.png 1024w, https://nerd-corner.com/wp-content/uploads/2023/05/cuda-architectures-768x108.png 768w" sizes="auto, (max-width: 1120px) 100vw, 1120px" /></p>
<h2>3. Installing the latest NVIDIA drivers</h2>
<p>To enable the GPU for TensorFlow, the latest NVIDIA drivers must be installed. Simply go to the NVIDIA website and download the latest driver for your graphics card.</p>
<h2>4. Install Visual Studio (optional)</h2>
<p>In TensorFlow, some parts of the library have been written in C++ to maximise performance. Therefore, installing Visual Studio can help improve the compatibility and performance of TensorFlow:<a style="font-size: 1.125rem; color: midnightblue; outline: 0px;" href="https://visualstudio.microsoft.com/de/vs/"> https://visualstudio.microsoft.com/de/vs/</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1370 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/vs-studio-download.png" alt="Visual studio installer" width="690" height="304" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/vs-studio-download.png 694w, https://nerd-corner.com/wp-content/uploads/2023/05/vs-studio-download-300x132.png 300w" sizes="auto, (max-width: 690px) 100vw, 690px" /></p>
<p>It is sufficient to select individual components here. I have selected everything with C++ in &#8220;Compiler, Buildtools and Runtimes&#8221; and also MS Build, which in turn automatically installs a few more components. All in all, however, over 25 GB!</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1369 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/VS-studio-components.png" alt="choose components in visual studio" width="880" height="751" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/VS-studio-components.png 885w, https://nerd-corner.com/wp-content/uploads/2023/05/VS-studio-components-300x256.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/VS-studio-components-768x655.png 768w" sizes="auto, (max-width: 880px) 100vw, 880px" /></p>
<h2>5. Install CUDA Toolkit</h2>
<p>The CUDA Toolkit is a toolkit for CUDA application development provided by NVIDIA. TensorFlow requires CUDA to run on the GPU. Simply download and install the version of the CUDA toolkit requested in step 1 from the NVIDIA website: <a href="https://developer.nvidia.com/cuda-downloads">https://developer.nvidia.com/cuda-downloads</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1368 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/Cuda-toolkit-download.png" alt="download cuda toolkit" width="1130" height="889" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/Cuda-toolkit-download.png 1135w, https://nerd-corner.com/wp-content/uploads/2023/05/Cuda-toolkit-download-300x236.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/Cuda-toolkit-download-1024x806.png 1024w, https://nerd-corner.com/wp-content/uploads/2023/05/Cuda-toolkit-download-768x604.png 768w" sizes="auto, (max-width: 1130px) 100vw, 1130px" /></p>
<h2>6. Installing the cuDNN libraries</h2>
<p>cuDNN is a library of deep learning primitives provided by NVIDIA. TensorFlow also requires cuDNN to run on the GPU. cuDNN is free, but you have to create an account as NVIDIA Developer: <a href="https://developer.nvidia.com/rdp/cudnn-download">https://developer.nvidia.com/rdp/cudnn-download</a></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1367 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download.png" alt="cuDNN download" width="1710" height="875" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download.png 1717w, https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download-300x154.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download-1024x524.png 1024w, https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download-768x393.png 768w, https://nerd-corner.com/wp-content/uploads/2023/05/cuDNN-download-1536x786.png 1536w" sizes="auto, (max-width: 1710px) 100vw, 1710px" /></p>
<p>After the download, the content must be unpacked. The content is moved to the &#8220;NVIDIA GPU Computing Toolkit&#8221; in the &#8220;Programs&#8221; folder. After moving, copy the file path of the &#8220;bin&#8221; folder.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1366 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/unzip-cuDNN.png" alt="unzip cuDNN" width="670" height="226" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/unzip-cuDNN.png 673w, https://nerd-corner.com/wp-content/uploads/2023/05/unzip-cuDNN-300x101.png 300w" sizes="auto, (max-width: 670px) 100vw, 670px" /></p>
<h2>7. Set PATH variable</h2>
<p>Open the environment variables by simply typing the term into the Windows search. Then edit the system variable &#8220;path&#8221; and add a new entry with the file path of the &#8220;bin&#8221; folder from the previous step.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1365 zoooom" src="https://nerd-corner.com/wp-content/uploads/2023/05/path-variable.png" alt="Set path variable for tensorflow gpu" width="1220" height="203" srcset="https://nerd-corner.com/wp-content/uploads/2023/05/path-variable.png 1223w, https://nerd-corner.com/wp-content/uploads/2023/05/path-variable-300x50.png 300w, https://nerd-corner.com/wp-content/uploads/2023/05/path-variable-1024x170.png 1024w, https://nerd-corner.com/wp-content/uploads/2023/05/path-variable-768x127.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></p>
<h2>8. Creating a virtual environment</h2>
<p>It is recommended to install TensorFlow in a virtual environment to avoid conflicts with other Python packages. Ideally using Anaconda. Simply download and install here: <a href="https://www.anaconda.com/download">https://www.anaconda.com/download</a></p>
<p>Then start the Anaconda Navigator. Create a new environment under Environments &gt; Create. Then click on Home again and launch an existing Python IDE from here. Additional IDEs such as PyCharm should also be automatically displayed here after the download.</p>
<h2>9. Verify Tensorflow GPU support</h2>
<p>To check whether the TensorFlow GPU support was successfully detected, the Tensorflow package should first be installed in the Python IDE. But note that under Windows the GPU is only recognised up to version 2.10! In the following versions it is no longer recognised! Tensorflow 2.10 must therefore be installed.</p>
<p>Then run the following code to display a list of available GPUs:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python">import tensorflow as tf

tf.config.list_physical_devices('GPU')</pre>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/enable-tensorflow-gpu-under-windows/">Enable TensorFlow GPU under Windows</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/enable-tensorflow-gpu-under-windows/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Glare free lamp and powerbank</title>
		<link>https://nerd-corner.com/glare-free-lamp-and-powerbank/</link>
					<comments>https://nerd-corner.com/glare-free-lamp-and-powerbank/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 26 Dec 2022 15:31:51 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[3D print]]></category>
		<category><![CDATA[Akku]]></category>
		<category><![CDATA[Battery management system]]></category>
		<category><![CDATA[Battery shield V3]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[CAD design]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[DIY Powerbank]]></category>
		<category><![CDATA[glare free]]></category>
		<category><![CDATA[glare free lamp]]></category>
		<category><![CDATA[housing]]></category>
		<category><![CDATA[led]]></category>
		<category><![CDATA[led strip]]></category>
		<category><![CDATA[Powerbank]]></category>
		<category><![CDATA[Solid Works]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Taschenlampe]]></category>
		<category><![CDATA[Verkabelung]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1320</guid>

					<description><![CDATA[<p>I bought a new 3D printer with a closed build chamber. At some point I noticed that one of the two extruders was clogged. The &#8230; </p>
<p>The post <a href="https://nerd-corner.com/glare-free-lamp-and-powerbank/">Glare free lamp and powerbank</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I bought a new 3D printer with a closed build chamber. At some point I noticed that one of the two extruders was clogged. The issue was, to unclog the extruder I needed light, because the build room light only works when the printer is on. When the printer is on, the fans would also start spinning, and those can quickly break if you slip off with the hex key. Therefore, I preferred to use a flashlight.</p>
<p>The flashlight was hard to position properly and it dazzled. For this reason, I came up with the idea of developing my own glare-free lamp, which you can simply place on the heating bed and is not blinding. Preferably wireless with a powerbank. <a href="https://nerd-corner.com/review-battery-shield-v3-diy-powerbank-with-lipo-18650/" target="_blank" rel="noopener">I had already built my own powerbank</a> with the Battery Shield V3, which I used as a basis this time.</p>
<p><em><strong>This might also be interesting for you:</strong> <a href="https://nerd-corner.com/review-battery-shield-v3-diy-powerbank-with-lipo-18650/" target="_blank" rel="noopener">Own powerbank with the Battery Shield V3</a></em></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1299 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-scaled.jpg" alt="Glare free blendfreie Lampe" width="2500" height="1141" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-300x137.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-1024x467.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-768x350.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-1536x701.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/glarefree_lamp_titelbild-2048x935.jpg 2048w" sizes="auto, (max-width: 2500px) 100vw, 2500px" /></p>
<h2>List of components</h2>
<ul>
<li>1 x Hollow socket 5,5&#215;2,1</li>
<li>1 x Battery Shield V3</li>
<li>1 x LiPo 18650 3500mAh</li>
<li>1 x rocker switch 250V/3A mounting dimension 15&#215;10,5mm</li>
<li>4 x hexagon socket head screws M2 x6</li>
<li>6 x raised countersunk head screws M2 x 20</li>
<li>17 x 5V SMD2835 LED strips</li>
<li>5 x jumper cable</li>
</ul>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1300 aligncenter" src="https://nerd-corner.com/wp-content/uploads/2022/12/PBLamp.gif" alt="glare free lamp belndfreie Lampe GIF" width="469" height="289" /></p>
<h2>Choice of LED</h2>
<p>Since <a href="https://nerd-corner.com/review-battery-shield-v3-diy-powerbank-with-lipo-18650/" target="_blank" rel="noopener">the basic housing of the powerbank with the Battery shield V3 was already finished</a>, I mainly had to think about the lighting. LEDs with 5V or 3V should be used as illuminants, because the Battery shield V3 provides either 5V or 3V. For my purposes a lower lumen value is sufficient. After a short research I found suitable LED strips.</p>
<p>The light temperature of my LED strip is 6500K also called cold white. This light contains a lot of blue, which makes it easy to work with and details become visible quickly. Since the Battery shield V3 has three additional 5V and one USB A output, powering the LEDs is no problem.</p>
<p>The LEDs for the glare-free lamp are SMD2835. These are 2.5 mm wide and 3.5 mm long and have a slightly lower luminosity than a SMD5050. How much the LEDs consume is critical to the lamp&#8217;s burn time, as the power supply from the battery is limited.</p>
<h2>Construction of the cover and middle cover</h2>
<p>As already mentioned in the previous section, the base case of the powerbank is not changed. Instead, the LEDs are glued onto an inner cover. The middle cover also serves as a support for the hollow socket for the 3V output. Furthermore, a breakthrough was contructed to pass through the cables from the on-off switch. The slanted openings of the intermediate cover should help to apply adhesive to the LED strips from behind if necessary.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1311 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs.jpg" alt="Zwischendeckel der Lampe" width="1600" height="782" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs.jpg 1619w, https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs-300x147.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs-1024x500.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs-768x375.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zwischendeckel-fur-LEDs-1536x750.jpg 1536w" sizes="auto, (max-width: 1600px) 100vw, 1600px" /></p>
<p>For the top side (the lid, where the light shines through) it became a little more complex. On the one hand, enough light should shine through, but on the other hand, it must not dazzle! Of course, a crystal clear lid would be ideal for the light yield, but as I said, then it would possibly dazzle. To strike a balance between effective light output and freedom from glare, several factors must be taken into account:</p>
<ul>
<li>Material selection (filament)</li>
<li>Distance to the light source</li>
<li>Thickness of the lens</li>
<li>Printing strategy</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1312 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-scaled.jpg" alt="Deckel der Lampe" width="2500" height="1077" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-scaled.jpg 2560w, https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-300x129.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-1024x441.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-768x331.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-1536x662.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/Deckel-der-Lampe-2048x882.jpg 2048w" sizes="auto, (max-width: 2500px) 100vw, 2500px" /></p>
<p>The choice of material for the anti-glare lamp was &#8220;ivory&#8221;. The distance to the illuminant is 10.5 mm and the layer thickness (material thickness) is 1 mm. The layer height is 0.25 mm, i.e. one millimeter results in four layers, with the first layer applied 45° to the left and the second layer 45° to the right. Due to the different directions of the layers, the light is refracted again and again and becomes glare-free. This is a subjective perception and the designation glare-free therefore does not apply to all people.</p>
<h2>Assembly</h2>
<ul>
<li>
<h5>Soldering the parts to the jumper cables:<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-1303 size-large zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp-665x1024.jpg" alt="zusammenbau shield v3 powerbank" width="665" height="1024" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp-665x1024.jpg 665w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp-195x300.jpg 195w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp-768x1182.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp-998x1536.jpg 998w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt1_glarefree_lamp.jpg 1167w" sizes="auto, (max-width: 665px) 100vw, 665px" /></h5>
</li>
<li>
<h5>Cutting and gluing the LED strips: The LED strip is separated into two times 6 LEDs and once 5 LEDs and glued to the intermediate cover. The cable opening on the lid for the plug must remain free:<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-1304 size-large zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-1024x576.jpg" alt="Zusammenbau blendfreie Lampe mit LEDs" width="1024" height="576" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-1024x576.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-300x169.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-768x432.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-1536x865.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-2048x1153.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt2b_glarefree_lamp-scaled.jpg 2560w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></h5>
</li>
<li>
<h5>Attach the hollow bushing to the intermediate cover:<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-1305 size-large zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt3_glarefree_lamp-1024x789.jpg" alt="Zusammenbau holbuchse anbringen" width="1024" height="789" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt3_glarefree_lamp-1024x789.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt3_glarefree_lamp-300x231.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt3_glarefree_lamp-768x592.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt3_glarefree_lamp.jpg 1081w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></h5>
</li>
<li>
<h5>Screw the battery shield into the housing after the ten threads have been previously cut into the housing.</h5>
</li>
<li>
<h5>Press the rocker switch into the cover:<img loading="lazy" decoding="async" class="aligncenter wp-image-1306 size-large zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt4_glarefree_lamp-1024x471.jpg" alt="zusammbau shield v3 powerbank kippschalter" width="1024" height="471" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt4_glarefree_lamp-1024x471.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt4_glarefree_lamp-300x138.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt4_glarefree_lamp-768x353.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt4_glarefree_lamp.jpg 1473w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></h5>
</li>
<li>
<h5>Press LiPo 18650 into the receptacle</h5>
</li>
<li>
<h5>Connect cable and turn on:<img loading="lazy" decoding="async" class="aligncenter wp-image-1307 size-large" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-1024x622.jpg" alt="Zusammenbau Schritte glare free" width="1024" height="622" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-1024x622.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-300x182.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-768x467.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-1536x933.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-2048x1244.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt5_glarefree_lamp-scaled.jpg 2560w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></h5>
</li>
<li>
<h5>If all LEDs light up, place the middle cover on the housing and then place the cover on the middle cover and screw it down:<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-1308 size-large zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-1024x623.jpg" alt="Zusammenbau Endschritt blendfrei" width="1024" height="623" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-1024x623.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-300x182.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-768x467.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-1536x934.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-2048x1245.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2022/12/Zusammenbau_schritt_ende_glarefree_lamp-scaled.jpg 2560w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></h5>
</li>
</ul>
<h2>Glare free lamp CAD design</h2>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1294 size-large" src="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp-1024x543.jpg" alt="CAD Glare free lamp" width="1024" height="543" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp-1536x814.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp.jpg 1620w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>For the threads, the holes are designed for core hole diameter, i.e. for M2 for diameter 1.6 mm. You can tap the thread with the tap or form (press in) with a screw. Personally, I prefer the thread cutting. The two graphics show where the threads have to be cut on the housing.</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1295 size-large" src="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp2-1024x510.jpg" alt="CAD glare free lamp" width="1024" height="510" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp2-1024x510.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp2-300x149.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp2-768x383.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_glarefree_lamp2.jpg 1124w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h2>Further notes</h2>
<p>Some may wonder why the rocker switch sticks out of the lid and is not recessed. It makes it easier to turn the lamp on and off.  Most of the time you only have one hand free and can&#8217;t really reach into the recess, but if the rocker switch sticks out it&#8217;s easier to operate it. Nevertheless, I have also designed a version with recessed rocker switch, which you can download in the download section!</p>
<p>The power of the lamp is about 1.4 watts. At 5.05 V the current is therefore 0.27 A, which is no problem for the Battery Shield V3 and the LiPo. The burn time of the lamp is about 5 hours in continuous operation. For this data, I used a Samsung 18650 with 3500 mAh. The powerbank can be used in parallel to run the lamp. However, the total current should not exceed 3A.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1302" src="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_seitlich_in_einzelteile.jpg" alt="CAD blendfreie Lampe glarefree" width="1201" height="1259" srcset="https://nerd-corner.com/wp-content/uploads/2022/12/CAD_seitlich_in_einzelteile.jpg 1271w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_seitlich_in_einzelteile-286x300.jpg 286w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_seitlich_in_einzelteile-977x1024.jpg 977w, https://nerd-corner.com/wp-content/uploads/2022/12/CAD_seitlich_in_einzelteile-768x805.jpg 768w" sizes="auto, (max-width: 1201px) 100vw, 1201px" /></p>
<p>I use this lamp not only for my 3D printer, but also for soldering, reading or as a night light. The powerbank is also extremely light with 127g.</p>
<h2>Download files</h2>
<ul>
<li><a href="https://www.thingiverse.com/thing:5430271" target="_blank" rel="noopener">STL files of the glare free lamp</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/glare-free-lamp-and-powerbank/">Glare free lamp and powerbank</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/glare-free-lamp-and-powerbank/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Import Swagger in Node TypeScript Project</title>
		<link>https://nerd-corner.com/import-swagger-in-node-typescript-project/</link>
					<comments>https://nerd-corner.com/import-swagger-in-node-typescript-project/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Wed, 26 Oct 2022 17:10:41 +0000</pubDate>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[Api]]></category>
		<category><![CDATA[Backend]]></category>
		<category><![CDATA[Backend Server]]></category>
		<category><![CDATA[Backend with Swagger]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[Endpoints]]></category>
		<category><![CDATA[express.js]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Node with Swagger and Typescript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Swagger]]></category>
		<category><![CDATA[swagger documentation]]></category>
		<category><![CDATA[Swagger express]]></category>
		<category><![CDATA[Swagger.json]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1287</guid>

					<description><![CDATA[<p>I recently coded a Node server with express.js in Typescript. This is a typical combination for backend development. It is especially beneficial if you already &#8230; </p>
<p>The post <a href="https://nerd-corner.com/import-swagger-in-node-typescript-project/">Import Swagger in Node TypeScript Project</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I recently coded a Node server with express.js in Typescript. This is a typical combination for backend development. It is especially beneficial if you already have experience with frontend development in Typescript. In general I strongly recommend to use Typescript instead of Javascript for frontend as well as backend development. Typescript uses Javascript but is type based and therefore not as error prone!</p>
<p>Also, the focus should always be on clean code and it should be properly documented. Especially when a project gets bigger, proper documented work pays off. For example, to document REST endpoints it is recommended to use Swagger. The Swagger API documentation provides an overview of all endpoints and even the possibility to interact with them.</p>
<p><strong><em>This might also be interesting for you: </em></strong><a href="https://nerd-corner.com/how-to-build-a-custom-angular-reactive-svg-form-with-clickable-elements/" target="_blank" rel="noopener"><em>Angular Form with clickable SVG</em></a></p>
<h2>List of components</h2>
<ul>
<li>IDE (for example VS Code)</li>
<li>Node.js</li>
</ul>
<h2>Documentation with swagger</h2>
<p>Although Swagger is quite well known, I could not find a detailed implementation guide. Therefore I would like to explain 2 ways to implement Swagger in an existing node server. The first way is to add Swagger parameters directly to each endpoint. This is probably the faster variant, but can get messy depending on the number of endpoints. The second option is to create a &#8220;swagger.json&#8221; file that summarizes the parameters of the endpoints.</p>
<p>To use Swagger the following library and its type extension will be needed:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">npm install --save  swagger-ui-express
npm install --save-dev @types/swagger-ui-express</pre>
<p>Swagger creates documentation of the endpoints:</p>
<p><img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-1271" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu.jpg" alt="Example Swagger Docu" width="1647" height="853" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu.jpg 1847w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-300x155.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-1024x531.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-768x398.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerDocu-1536x796.jpg 1536w" sizes="auto, (max-width: 1647px) 100vw, 1647px" /></p>
<p>These can be opened and you can see an example request and an example response:</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1273 zoooom" style="font-size: 1.125rem;" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint.jpg" alt="Example Swagger Endpoint 1" width="1657" height="840" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint.jpg 1757w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-300x152.jpg 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-1024x519.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-768x389.jpg 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint-1536x779.jpg 1536w" sizes="auto, (max-width: 1657px) 100vw, 1657px" /><img loading="lazy" decoding="async" class="aligncenter wp-image-1272 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2.png" alt="Example Swagger Endpoint 2" width="1657" height="803" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2.png 1757w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-300x145.png 300w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-1024x496.png 1024w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-768x372.png 768w, https://nerd-corner.com/wp-content/uploads/2022/10/exampleSwaggerEndpoint2-1536x744.png 1536w" sizes="auto, (max-width: 1657px) 100vw, 1657px" /></p>
<p>The &#8220;Try it out&#8221; button can be used to interact directly with the endpoint.</p>
<h2>Swagger API documentation with params</h2>
<p>This variant is more recommended for smaller projects. First, these two Swagger libraries must be integrated into the project:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">npm install --save-dev @types/swagger-jsdoc 
npm install --save swagger-jsdoc</pre>
<p>The libraries are configured in app.ts or for non Typescript users app.js. Due to the configuration set here, the documentation is located in &#8220;/api-docs&#8221;:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="app.ts">import express from "express";
import bodyParser from "body-parser";
import exampleRoutes from "./routes/example-route";
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";

const app = express();

const options = {
  definition: {
    openapi: "3.0.1",
    info: {
      title: "REST API for Swagger Documentation",
      version: "1.0.0",
    },
    schemes: ["http", "https"],
    servers: [{ url: "http://localhost:3000/" }],
  },
  apis: [
    `${__dirname}/routes/example-route.ts`,
    "./dist/routes/example-route.js",
  ],
};

const swaggerSpec = swaggerJSDoc(options);

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use(bodyParser.json());
app.use(exampleRoutes);

app.listen(3000);</pre>
<p>The endpoint is described with the parameters as follows:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="example-route.ts">import { Router } from "express";
import { exampleFunction } from "../controller/example";

const router = Router();

/**
 * @swagger
 * /example:
 *      post:
 *          summary: Send the text to the server
 *          tags:
 *              - ExampleEndpoints
 *          description: Send a message to the server and get a response added to the original text.
 *          requestBody:
 *              required: true
 *              content:
 *                  application/json:
 *                      schema:
 *                          type: object
 *                          properties:
 *                              responseText:
 *                                  type: string
 *                                  example: This is some example string! This is an endpoint
 *          responses:
 *              201:
 *                  description: Success
 *                  content:
 *                      application/json:
 *                          schema:
 *                              type: object
 *                              properties:
 *                                  text:
 *                                      type: string
 *                                      example: This is some example string!
 *              404:
 *                  description: Not found
 *              500:
 *                  description: Internal server error
 */
router.post("/example", exampleFunction);

export default router;
</pre>
<h2>Swagger API documentation with swagger.json</h2>
<p>To have a better overview and not to mix the documentation with the actual code, it is recommended to use one, or even more json files. When using TypeScript, the Swagger.json file must be placed in the rootDirectory:</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1276 zoooom" src="https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson.jpg" alt="Foulder Structure with Swagger.json" width="170" height="344" srcset="https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson.jpg 199w, https://nerd-corner.com/wp-content/uploads/2022/10/foulderStructureOfSwaggerJson-148x300.jpg 148w" sizes="auto, (max-width: 170px) 100vw, 170px" /></p>
<p>Again, the configuration is first defined in app.ts or, for non-Typescript users, in app.js. The domain path &#8220;/api-docs&#8221; is also selected here for the documentation:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="typescript" data-enlighter-title="app.ts">import express from "express";
import bodyParser from "body-parser";
import exampleRoutes from "./routes/example-route";
import swaggerUi from "swagger-ui-express";

import * as swaggerDocument from "./swagger.json";

const app = express();

app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(bodyParser.json());

app.use(exampleRoutes);

app.listen(3000);</pre>
<p>Important note: To import JSON files into a Typescript project this must be allowed in tsconfig.json. Also, the JSON file must be located in the root directory.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json" data-enlighter-title="tsconfig.json">{
  "compilerOptions": {
    "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
    "module": "commonjs" /* Specify what module code is generated. */,
    "rootDir": "./src" /* Specify the root folder within your source files. */,
    "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
    "resolveJsonModule": true /* Enable importing .json files. */,
    "outDir": "./dist" /* Specify an output folder for all emitted files. */,
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
    "strict": true /* Enable all strict type-checking options. */,
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  }
}</pre>
<p>The previous Swagger documentation with parameters would thus look like this in swagger.json:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="json">{
  "openapi": "3.0.1",
  "info": {
    "title": "REST API for Swagger Documentation",
    "version": "1.0.0"
  },
  "schemes": ["http"],
  "servers": [{ "url": "http://localhost:3000/" }],
  "paths": {
    "/example": {
      "post": {
        "tags": ["ExampleEndpoints"],
        "summary": "Send a text to the server",
        "description": "Send a message to the server and get a response added to the original text.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExampleSchemaHeader"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExampleSchemaBody"
                }
              }
            }
          },
          "404": { "description": "Not found" },
          "500": { "description": "Internal server error" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExampleSchemaBody": {
        "properties": {
          "responseText": {
            "type": "string",
            "example": "This is some example string! This is an endpoint"
          }
        }
      },
      "ExampleSchemaHeader": {
        "required": ["text"],
        "properties": {
          "text": {
            "type": "string",
            "example": "This is some example string!"
          }
        }
      }
    }
  }
}
</pre>
<h2>Download files</h2>
<ul>
<li><a href="https://github.com/hanneslim/Node-with-swagger-params" target="_blank" rel="noopener">Github example projcet for swagger params</a></li>
<li><a href="https://github.com/hanneslim/node-with-swagger-json" target="_blank" rel="noopener">Github example project for swagger.json</a></li>
</ul>
<p>The post <a href="https://nerd-corner.com/import-swagger-in-node-typescript-project/">Import Swagger in Node TypeScript Project</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/import-swagger-in-node-typescript-project/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
