<?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>App development Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/category/app-development/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/category/app-development/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Sun, 16 Mar 2025 18:49:48 +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>App development Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/category/app-development/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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>How to add custom icon pins to Google Maps Xamarin App</title>
		<link>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/</link>
					<comments>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 13 Apr 2020 11:51:24 +0000</pubDate>
				<category><![CDATA[App development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[App with Google Maps]]></category>
		<category><![CDATA[custom Google Maps marker]]></category>
		<category><![CDATA[custom Google Maps pin]]></category>
		<category><![CDATA[icons on google map]]></category>
		<category><![CDATA[Xamarin]]></category>
		<category><![CDATA[Xamarin Forms]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=508</guid>

					<description><![CDATA[<p>We explained in the last post how to integrate Google Maps in a Xamarin Forms application. In this post we make a further step an &#8230; </p>
<p>The post <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">How to add custom icon pins to Google Maps Xamarin App</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We explained in the <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">last post</a> how to integrate Google Maps in a Xamarin Forms application. In this post we make a further step an show you how to change the standard Google Maps marker pin to custom icon pins in Google Maps.</p>
<h2>List of components</h2>
<ul>
<li>Visual Studio (free)</li>
</ul>
<h2>Setting a pin on the Google Map an choose a starting point</h2>
<p>Let&#8217;s start to put a few markers on the map. The code is pretty simple. In the &#8220;MainPage.xaml.cs&#8221; include the following using directive:</p>
<pre>using Xamarin.Forms.GoogleMaps;</pre>
<p>Then create a pin with position and label:</p>
<pre><code>Pin one = new Pin ()
{
    Label = "Pin ONE",
    Position = new position (48.1390196, 11.5744422)
};
MyMap.Pins.Add (one);</code></pre>
<p>&#8220;MyMap&#8221; is the name we have set in the &#8220;MainPage.xaml&#8221;.</p>
<p>The following code can be used to ensure that the map always opens at a specific starting point:</p>
<pre><code>MyMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (48.1390196, 11.5744422), Distance.FromKilometers (10)));</code></pre>
<p>And this is how the app looks now:</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-495 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins.jpg" alt="Screenshot Google Maps in App" width="310" height="620" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard_pins-1024x2048.jpg 1024w" sizes="(max-width: 310px) 100vw, 310px" /></p>
<h2>Add new icons</h2>
<p><span style="font-size: 1.125rem;">I downloaded two alternative icons i</span>n order to replace the red Google standard pins. I have the &#8220;castle.png&#8221; and &#8220;beer.png&#8221; icon from the website <a href="http://icons8.com">icons8.com</a>.</p>
<p>For iOS, we simply drag the two icons to the &#8220;Resources&#8221; folder in the iOS project. It should look like this:</p>
<p><img decoding="async" class="aligncenter wp-image-510 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS.jpg" alt="Add pictures to Xamarin Forms iOS project NErd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_iOS-1536x814.jpg 1536w" sizes="(max-width: 1599px) 100vw, 1599px" /></p>
<p>For Android we drag the icons to the &#8220;drawable&#8221; folder under &#8220;Resources&#8221; in the Android project. For me it is unfortunately always the case that the &#8220;drawable&#8221; folder has to be created manually. Although, it is displayed normally in the Visual Studio folder structure, it actually doesn&#8217;t really exist if you search the folder on your computer. So create a new folder, where the really &#8220;drawable&#8221; folder should be and name it &#8220;drawable&#8221;. Restart Visual Studio and then add the two icons. It looks like this:</p>
<p><img decoding="async" class="aligncenter wp-image-511 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android.jpg" alt="Visual Studio Xamarin how to integrate icons in the drawable folder Nerd Corner" width="1599" height="848" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-768x408.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_Icons_Android-1536x815.jpg 1536w" sizes="(max-width: 1599px) 100vw, 1599px" /></p>
<h2>Extra step for Android users: Create a Bitmap class</h2>
<p>iOS has a clear advantage here. You don&#8217;t have to do anything for Apple phones. iOS automatically renders the icons from the &#8220;Resources&#8221; folder. For Android, however, you have one extra step, but you are almost there.</p>
<p>Create a class in the ANDROID project, name it &#8220;BitmapConfig.cs&#8221; and copy the following code:</p>
<pre><code>
using DemoGoogleMapApp.Droid;
using Xamarin.Forms.GoogleMaps;
using Xamarin.Forms.GoogleMaps.Android.Factories;
using AndroidBitmapDescriptor = Android.Gms.Maps.Model.BitmapDescriptor;
using AndroidBitmapDescriptorFactory = Android.Gms.Maps.Model.BitmapDescriptorFactory;

public sealed class BitmapConfig : IBitmapDescriptorFactory
{
    public AndroidBitmapDescriptor ToNative(BitmapDescriptor descriptor)
    {
        int iconId = 0;
        switch (descriptor.Id)
        {
            case "castle":
                iconId = Resource.Drawable.castle;
                break;
            case "beer":
                iconId = Resource.Drawable.beer;
                break;
        }
        return AndroidBitmapDescriptorFactory.FromResource(iconId);
    }
}
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-513 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig.jpg" alt="Visual Studio Xamarin Bitmap Config for custom icon google maps pin Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_BitmapConfig-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /><br />
You can create an extra case for each icon. We can then assign a case name to each pin on the map.</p>
<p>In the &#8220;MainActivity.cs&#8221; the Google Maps initialization also has to be changed a little bit. Add the following using directive and the new initialization code.</p>
<p>Using directive:</p>
<pre>using Xamarin.Forms.GoogleMaps.Android</pre>
<p>Initialization code:</p>
<pre><code>
var platformConfig = new PlatformConfig
{
    BitmapDescriptorFactory = new BitmapConfig()
};
Xamarin.FormsGoogleMaps.Init(this, savedInstanceState, platformConfig);
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-514 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity.jpg" alt="Bitmap Config for custom google pins in main activation function android Nerd Corner" width="1599" height="848" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-768x408.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot-Bitmap-Config-in-Main-Activity-1536x815.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>I got the idea for the &#8220;BitmapConfig.cs&#8221; from this <a href="https://medium.com/@dev.aritradas/using-custom-markers-and-latitude-longitude-bounds-in-google-maps-on-xamarin-forms-690babde96ff">post</a>.</p>
<h2>Last step: Add the custom icon pins in Google Maps app</h2>
<p>From now on you can easily set the icon image for each pin on the Google Map:</p>
<pre><code>
Pin one = new Pin()
{
    Label="Pin ONE",
    Position= new Position(48.1390196, 11.5744422),
    Icon= BitmapDescriptorFactory.FromBundle("beer"),
    Type = PinType.Place
};
</code></pre>
<p>Each icon can be used as a Google Maps Pin with the following assignment:</p>
<pre>Icon = BitmapDescriptorFactory.FromBundle ("NameOfTheCase")</pre>
<h2>Screenshots of the custom icon pins in Google Maps app</h2>
<p><img loading="lazy" decoding="async" class="alignleft wp-image-520 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_two_end-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="alignleft wp-image-519 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_pin_one_end-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="alignleft wp-image-518 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pins-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /> <img loading="lazy" decoding="async" class="wp-image-517 zoooom alignleft" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label.jpg" alt="Screenshot Xamarin Forms App with custom Google Maps Pin marker image Nerd Corner" width="200" height="400" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label.jpg 1080w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_custom_pin_with_label-1024x2048.jpg 1024w" sizes="auto, (max-width: 200px) 100vw, 200px" /></p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/530/?tmstv=1755833520" rel="nofollow" id="download-link-530" data-redirect="false" >
	Source Code Xamarin Forms Google Maps App with custom icon</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/533/?tmstv=1755833520" rel="nofollow" id="download-link-533" data-redirect="false" >
	Icons</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/536/?tmstv=1755833520" rel="nofollow" id="download-link-536" data-redirect="false" >
	BitmapConfig.cs AndroidManifest.xml MainActivity.cs</a>
</li>
</ul>
<p>Please don&#8217;t forget to insert your Google Maps API Key in the source code.</p>
<p>&nbsp;</p>
<p>The post <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">How to add custom icon pins to Google Maps Xamarin App</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>How to integrate Google Maps in an App with Xamarin</title>
		<link>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/</link>
					<comments>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Mon, 13 Apr 2020 10:53:42 +0000</pubDate>
				<category><![CDATA[App development]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[App with Google Maps]]></category>
		<category><![CDATA[custom Google Maps marker]]></category>
		<category><![CDATA[custom Google Maps pin]]></category>
		<category><![CDATA[Xamarin]]></category>
		<category><![CDATA[Xamarin Forms]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=491</guid>

					<description><![CDATA[<p>This post explains how to integrate Google Maps in an app. The app is a Xamarin Forms application. Xamarin is a cross platform for Android &#8230; </p>
<p>The post <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">How to integrate Google Maps in an App with Xamarin</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This post explains how to integrate Google Maps in an app. The app is a Xamarin Forms application. Xamarin is a cross platform for Android and iOS. The programming language is C#. In addition to this post, <a href="https://nerd-corner.com/how-to-add-custom-icon-pins-to-google-maps-xamarin-app/">there will be a post</a>, which describes how to replace the standard Google Map pin with a custom icon.</p>
<h2>List of components</h2>
<ul>
<li>Visual Studio (free)</li>
</ul>
<h2>Downloading the NuGet Package</h2>
<p>Open Visual Studio and choose Mobile App (Xamarin.Forms). In order to use Google Maps, we have to integrate the corresponding NuGet package. Instead of the official version &#8220;Xamarin.Forms.Maps&#8221; by Microsoft, we use &#8220;Xamarin.Forms.GoogleMaps&#8221; by amay077. Please remember to install the NuGet package for each project. The &#8220;Xamarin.Forms.GoogleMaps&#8221; NuGet package by amay077 contains all functions of the official package and some additional ones. Among other things, you can easily replace the markers on the map with your own pictures.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-504 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket.jpg" alt="Xamarin Visual Studio Google Maps NuGet Package Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_NuGet_Paket-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>All possible functions of the &#8220;Xamarin.Forms.GoogleMaps&#8221; NuGet package by amay077, to integrate Google Maps in an app, are described on GitHub: <a href="https://github.com/amay077/Xamarin.Forms.GoogleMaps">https://github.com/amay077/Xamarin.Forms.GoogleMaps</a></p>
<h2>XAML code for the Google Map integration</h2>
<p>Since the NuGet package is already installed, Google Maps can now be added to the XAML page. Open &#8220;MainPage.xaml&#8221; and add:</p>
<pre>xmlns: gmaps = "clr-namespace: Xamarin.Forms.GoogleMaps; assembly = Xamarin.Forms.GoogleMaps"</pre>
<p>Then we need the following XAML code to display the map:</p>
<pre><code>
    &lt;Grid&gt;
        &lt;gmaps:Map x:Name="MyMap" MapType="Street" HasZoomEnabled="True" MyLocationEnabled="True" &gt;
            &lt;gmaps:Map.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;gmaps:Pin Icon="{Binding PinIcon}" Position="{Binding Position}"
                              Label="{Binding PinLabel}" /&gt;
                &lt;/DataTemplate&gt;
            &lt;/gmaps:Map.ItemTemplate&gt;
        &lt;/gmaps:Map&gt;
    &lt;/Grid&gt;
</code></pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-505 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage.jpg" alt="Visual Studio Xamarin Forms Google Maps integration Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainPage-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<h2>Get the Google API Key to integrate Google Maps in an app</h2>
<p>Although we have the XAML code to integrate Google Maps in an app, an API key is required. Otherwise we won&#8217;t see anything. Obtaining the API key from Google is easy and quick.<br />
Simply request the API key here: <a href="https://developers.google.com/maps/documentation/embed/get-api-key">https://developers.google.com/maps/documentation/embed/get-api-key </a></p>
<p><span style="font-size: 1.125rem;">Please note that the keys for iOS and Android are different.</span></p>
<h2>Initialize Google Maps for Android</h2>
<p>These are the final steps to display Google Maps in Android. Open the &#8220;MainActivity.cs&#8221; and add the following line in the &#8220;OnCreate ()&#8221; function:</p>
<pre>Xamarin.FormsGoogleMaps.Init (this, savedInstanceState);</pre>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-506 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity.jpg" alt="Visual Studio Xamarin Integrate Google Maps Line for main activity Nerd Corner" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_MainActivity-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<p>Next, go to <span style="font-size: 1.125rem;">&#8220;Properties&#8221; and </span><span style="font-size: 1.125rem;">select &#8220;AndroidManifest.xml&#8221;. We have to insert here the Google API key and grant the rights for GPS.</span></p>
<p>The is the place where you have to put the line with the meta-data for the Google Maps API Key:</p>
<pre>&lt;application android: label "Name of your app"&gt;Add here the meta-data&lt;/application&gt;</pre>
<p>This is the line with the meta-data for the Google Maps API Key:</p>
<pre>&lt;meta-data android: name = "com.google.android.maps.v2.API_KEY" android: value = "AddYourAndroidAPIKeyHere" /&gt;</pre>
<p>Then the rights for the GPS have to be granted:</p>
<pre>&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&lt;uses-feature android:name="android.hardware.location.gps" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
&lt;uses-permission android:name="android.permission.INTERNET" /&gt;</pre>
<p>Afterwards the <span style="font-size: 1.125rem;">&#8220;AndroidManifest.xml&#8221; looks like the screenshot here:</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-493 zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest.jpg" alt="Screenshot AndroidManifest for Google Maps API Key" width="1599" height="847" srcset="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest.jpg 1600w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-300x159.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-1024x543.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-768x407.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_AndroidManifest-1536x814.jpg 1536w" sizes="auto, (max-width: 1599px) 100vw, 1599px" /></p>
<h2>Initialize Google Maps for iOS</h2>
<p>The initialization is easier for iOS. You just have to open the &#8220;AppDelegate.cs&#8221; and add the following line:</p>
<pre>Xamarin.FormsGoogleMaps.Init ("AddYouriOSAPIKeyHere");</pre>
<h2>Start the app</h2>
<p>The app is now ready to go. Press compile in Visual Studio, then it looks like this:<br />
<img loading="lazy" decoding="async" class="zoooom aligncenter wp-image-496" src="https://nerd-corner.com/wp-content/uploads/2020/04/Screenshot_standard-512x1024.jpg" alt="Screenshot Google Maps in App Nerd Corner" width="310" height="620" /><br />
It is normal that the app chooses Rome as starting point. The next post shows how you can implement the starting point of the Google Maps app.</p>
<p>Sometimes it happens that the app does not automatically ask for the required rights and therefore it closes immediately after launching. This can be avoided by simply allowing GPS access in the settings or implementing a command to ask for the required rights.</p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/549/?tmstv=1755833520" rel="nofollow" id="download-link-549" data-redirect="false" >
	Source Code Demo Google Maps App</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/542/?tmstv=1755833520" rel="nofollow" id="download-link-542" data-redirect="false" >
	ActivityMain.cs AndroidManifest.xml MainPage.xaml MainPage.xaml.cs</a>
</li>
</ul>
<p>Please don&#8217;t forget to insert your Google Maps API Key in the source code.</p>
<p>The post <a href="https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/">How to integrate Google Maps in an App with Xamarin</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/how-to-integrate-google-maps-in-an-app-with-xamarin/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
		<item>
		<title>Android Bluetooth classic App for Arduino fan control</title>
		<link>https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/</link>
					<comments>https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/#comments</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Thu, 12 Mar 2020 13:45:02 +0000</pubDate>
				<category><![CDATA[App development]]></category>
		<category><![CDATA[Arduino projects]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[fan]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/?p=316</guid>

					<description><![CDATA[<p>We have already created a post in which we explain how to regulate fans by voltage. It doesn&#8217;t matter whether the fan is supplied with &#8230; </p>
<p>The post <a href="https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/">Android Bluetooth classic App for Arduino fan control</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We have already created a post in which we explain <a href="https://nerd-corner.com/arduino-fan-controller/">how to regulate fans by voltage</a>. It doesn&#8217;t matter whether the fan is supplied with 12V or 5V. The number of connections is also unimportant. You only need the + and &#8211; of the fan. Now we also want to connect a Bluetooth module to the Arduino and write an app that can be used to change the speed of the fan. So let&#8217;s get started with the Android Bluetooth classic App for Arduino.</p>
<h2>List of components</h2>
<ul>
<li>Arudino Mega</li>
<li>Breadboard</li>
<li>12V power supply</li>
<li>12V fan</li>
<li>jumper cable</li>
<li>220 Ohm resistor</li>
<li>NPN Transistor number: BC546B D6</li>
<li>Bluetooth module HC-05 or HC-06</li>
</ul>
<p>&nbsp;</p>
<p><iframe loading="lazy" hcb-fetch-image-from="https://www.youtube.com/watch?v=sJ2Og_How2Y" title="Android Bluetooth classic App for Arduino fan control // Arduino Code and Wiring // Full user guide" width="1200" height="675" src="https://www.youtube.com/embed/sJ2Og_How2Y?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<p><img loading="lazy" decoding="async" class="wp-image-323 size-large zoooom aligncenter" src="https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-1024x768.jpg" alt="Android Bluetooth app for arduino control nerd corner" width="720" height="540" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-1024x768.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-300x225.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-768x576.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-1536x1152.jpg 1536w, https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-2048x1536.jpg 2048w, https://nerd-corner.com/wp-content/uploads/2020/03/IMG_20200311_134834-1920x1440.jpg 1920w" sizes="auto, (max-width: 720px) 100vw, 720px" /></p>
<h2>Wiring</h2>
<p><img loading="lazy" decoding="async" class="wp-image-324 size-large zoooom aligncenter" src="https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-1024x588.png" alt="Android Bluetooth app for arduino control nerd corner" width="720" height="413" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-1024x588.png 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-300x172.png 300w, https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-768x441.png 768w, https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-1536x881.png 1536w, https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-2048x1175.png 2048w, https://nerd-corner.com/wp-content/uploads/2020/03/fan_mit_bluetooth_mit_transistor-1920x1102.png 1920w" sizes="auto, (max-width: 720px) 100vw, 720px" /></p>
<p>For the wiring, we proceed analogously to our &#8220;fan control&#8221; post. The 12V power supply must be connected to the breadboard. We connect this &#8211; of the breadboard with GND of the Arduino (the short blue cable connection in the picture). Then we connect the + of the breadboard to Vin of the Arduino Mega (red cable between Arduino and breadboard).</p>
<p>If we would plug the 12V power supply into the socket now. Then our Arduino would already be powered. There is no additional power supply like USB required. The Vin pin of the Arduino automatically regulates the 12V of the power supply to 5V for the Arduino.</p>
<p>Now we plug the NPN transistor into the breadboard. We connect the base (B) to the 220 Ohm resistor and then to pin 13 (yellow connection in the picture). We connect the collector (C) of the transistor directly to the negative connection of the fan (black fan cable). The positive fan connector is connected to the + of the breadboard. We connect the emitter (E) of the transistor to the – of the breadboard.</p>
<p>In addition to these already known steps, we take the Bluetooth module and connect the ground of the module to the ground of the Arduino (black cable). VCC of the module must be connected to 3.3V of the Arduino (red connection). If there is no 3.3V connection, the 5V connection can also be used. TX of the Bluetooth module has to be connected to RX of the Arduino (orange cable). RX of the module has to be connected to TX of the Arduino (purple cable). This means TX to RX and RX to TX. Always the equivalent!</p>
<p>Important: While the Arduino code is being flashed on the Arduino, you have to unplug RX and TX. Otherwise the flash process won&#8217;t work!</p>
<h2>Programming the Android Bluetooth classic app for Arduino</h2>
<p>We program a pure Android app with an HC-05 or alternatively HC-06 Bluetooth module. These two are Bluetooth Classic Modules. You can not connect to Bluetooth 4.0 also called Bluetooth Low Energy (BLE). The code for BLE is very different. Below is the programming guide for a Bluetooth Android app build with Xamarin Android. All important files are also uploaded!</p>
<p>As development environment we use Visual Studio (it is free) for the Xamarin.Android app. In AndroidStudio, the process is analogous, but the code will be in Java and not in C#.</p>
<p>Click on &#8220;Create new project&#8221; and select &#8220;Android app (Xamarin)&#8221;. At First we add the Bluetooth permissions to the &#8220;AndroidManifest.xml&#8221; file:</p>
<pre>&lt;uses-permission android: name = "android.permission.BLUETOOTH" /&gt;
&lt;uses-permission android: name = "android.permission.BLUETOOTH_ADMIN" /&gt;</pre>
<p>Then we design the layout of the app in the &#8220;activity_main.xml&#8221; file. We need 2 buttons for &#8220;Connect&#8221; and &#8220;Disconnect&#8221; and a slider for speed control. For the slider we set the maximum value to 127 (android: max = &#8220;127&#8221;).</p>
<p>In &#8220;MainActivity.cs&#8221; we add &#8220;using Android.Bluetooth&#8221;, create a &#8220;BluetoothConnection&#8221; class and set our &#8220;activity_main.xml&#8221; file as the start page. A Bluetooth socket is created for the connection to the Arduino. We recommend to look at the source code which is attached to this post.</p>
<p>Essentially, we always send a byte to the Arduino. That means we can send numbers between 0 and 255. For the fan control, we take the range from 0 to 127. The Arduino doubles this value and thus regulates the fan, which also runs in a range between 0 and 255. The rest of the range between 128 and 255 can be used for further functions. That&#8217;s it, just compile the app and go to the next step!</p>
<p>Incidentally, the code for the app is based on this project here: <a href="https://www.instructables.com/id/3-LED-Backlight-Xamarin-and-Arduino-With-HC05/" target="_blank" rel="noopener noreferrer">https://www.instructables.com/id/3-LED-Backlight-Xamarin-and-Arduino-With-HC05/</a></p>
<h2>Arduino Code</h2>
<p><img loading="lazy" decoding="async" class="wp-image-325 size-large zoooom aligncenter" src="https://nerd-corner.com/wp-content/uploads/2020/03/arduino_fan_controller_with_bluetooth_screenshot-1024x866.jpg" alt="arduino fan controller with bluetooth nerd corner" width="720" height="609" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/arduino_fan_controller_with_bluetooth_screenshot-1024x866.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/arduino_fan_controller_with_bluetooth_screenshot-300x254.jpg 300w, https://nerd-corner.com/wp-content/uploads/2020/03/arduino_fan_controller_with_bluetooth_screenshot-768x649.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/arduino_fan_controller_with_bluetooth_screenshot.jpg 1081w" sizes="auto, (max-width: 720px) 100vw, 720px" /></p>
<pre><code>#define motorPin 13
int received; //for the received Byte
int fanSpeed = 127; //initial speed - must be a number between 0 and 255
void setup() {
  Serial.begin(9600); //for communication with the app
  delay(3000); // small delay
  pinMode(motorPin, OUTPUT); //define motor pin as output
  analogWrite(motorPin,fanSpeed); //set the initial speed of the fan
}
void loop() {  
  while(Serial.available()) 
  {
     received = Serial.read(); //received Byte    
     Serial.println(received); //if the arduino is connected to the PC, than you can check the received Byte
     switch (received)  //you can easily add new cases to customize your arduino
     {
        case 200:
            Serial.println("RESTARTED");
            break;
        default:
            if(received &gt;0 &amp;&amp; received &lt;=127)
            {
              fanSpeed = (received*2); //app sends value between 0 and 127 - so we need to double it for the fan range between 0 and 255
              delay(10);
            }
            break;
     }  
  }
  analogWrite(motorPin,fanSpeed); //set the speed of the fan
}</code></pre>
<p>Please do not forget to disconnect the RX and TX wires before flashing the Arduino and afterwards connect it again correctly (RX to TX and TX to RX)!</p>
<p>Since we have connected the base of the transistor to pin 13, we define it as &#8220;motorPin&#8221;. The fan speed can be controlled via the &#8220;fanSpeed&#8221; variable. At the beginning, we set &#8220;fanSpeed&#8221; to half the speed, i.e. 127. (Depending on the fan model, a certain minimum speed is necessary for the fan to start.)</p>
<p>We define a variable &#8220;received&#8221; in which we store the byte sent from the app. In the setup function we start the communication with &#8220;Serial.begin&#8221; and set the baud rate to 9600. Then we program a while loop in the loop function. The while loop becomes active whenever a byte is received. If the value of the byte is between 0 and 127, we double it and define it as our new fan speed &#8220;fanSpeed&#8221;. As soon as the while loop has ended, the new speed for the fan is set with &#8220;analogWrite (motorPin, fanSpeed);&#8221;</p>
<h2>Screenshots of the Android Bluetooth classic App for Arduino</h2>
<p>Please note, you have to go to the settings and connect to the Bluetooth module at first. Otherwise you won&#8217;t be able to connect to the Arduino with the app!</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-329 size-medium zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth-150x300.jpg" alt="Screenshots Android App Bluetooth arduino control nerd corner" width="150" height="300" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth-1024x2048.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154409_com.companyname.fancontrollerbluetooth.jpg 1080w" sizes="auto, (max-width: 150px) 100vw, 150px" /> <img loading="lazy" decoding="async" class="alignnone wp-image-330 size-medium zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1-150x300.jpg" alt="Screenshots Android App Bluetooth arduino control nerd corner" width="150" height="300" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1-1024x2048.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154416_com.companyname.fancontrollerbluetooth-1.jpg 1080w" sizes="auto, (max-width: 150px) 100vw, 150px" /> <img loading="lazy" decoding="async" class="alignnone wp-image-331 size-medium zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth-150x300.jpg" alt="Screenshots Android App Bluetooth arduino control nerd corner" width="150" height="300" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth-1024x2048.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154426_com.companyname.fancontrollerbluetooth.jpg 1080w" sizes="auto, (max-width: 150px) 100vw, 150px" /> <img loading="lazy" decoding="async" class="alignnone wp-image-332 size-medium zoooom" src="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth-150x300.jpg" alt="Screenshots Android App Bluetooth arduino control nerd corner" width="150" height="300" srcset="https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth-150x300.jpg 150w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth-512x1024.jpg 512w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth-768x1536.jpg 768w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth-1024x2048.jpg 1024w, https://nerd-corner.com/wp-content/uploads/2020/03/Screenshot_20200311_154438_com.companyname.fancontrollerbluetooth.jpg 1080w" sizes="auto, (max-width: 150px) 100vw, 150px" /></p>
<h2>Download files</h2>
<ul>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/340/?tmstv=1755833520" rel="nofollow" id="download-link-340" data-redirect="false" >
	Source Code Android App "FanControllerBluetooth"</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/350/?tmstv=1755833520" rel="nofollow" id="download-link-350" data-redirect="false" >
	Arduino Code for the "FanControllerBluetooth" app</a>
</li>
<li><a  data-e-Disable-Page-Transition="true" class="download-link" title="" href="https://nerd-corner.com/download/345/?tmstv=1755833520" rel="nofollow" id="download-link-345" data-redirect="false" >
	Only MainActivity.cs AndroidMainfest.xml and activity_main.xml of the "FanControllerBluetooth" app</a>
</li>
</ul>
<p>The post <a href="https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/">Android Bluetooth classic App for Arduino fan control</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/android-bluetooth-classic-app-for-arduino-fan-control/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
			</item>
	</channel>
</rss>
