<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Syafiq Ziyadul Arifin on Medium]]></title>
        <description><![CDATA[Stories by Syafiq Ziyadul Arifin on Medium]]></description>
        <link>https://medium.com/@syafiqza?source=rss-f003533f7946------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cCpIxq-IaF8Qzwwg5L-aAg.png</url>
            <title>Stories by Syafiq Ziyadul Arifin on Medium</title>
            <link>https://medium.com/@syafiqza?source=rss-f003533f7946------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:49:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@syafiqza/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Unable to Extend Volume in Windows Disk Management]]></title>
            <link>https://medium.com/@syafiqza/unable-to-extend-volume-in-windows-disk-management-c5d8b50aae46?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5d8b50aae46</guid>
            <category><![CDATA[extend-volume]]></category>
            <category><![CDATA[disk-management]]></category>
            <category><![CDATA[windows-11]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[disk]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 09:44:55 GMT</pubDate>
            <atom:updated>2024-11-16T09:46:07.611Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*HpjuusP6XdBW-YIqWgnt_g.png" /><figcaption>Disk Management</figcaption></figure><p>Have you ever been unable to extend a volume in Disk Management? When a partition can’t be deleted, it can be quite annoying. This common Windows issue can be frustrating, especially when you need more storage space. Here’s the solution I’ll guide you through.</p><p>First things first, open up PowerShell and type <strong>list disk</strong>. This will open a new shell from <strong>C:\WINDOWS\system32\diskpart.exe</strong>, which is a powerful command-line tool for managing disks. Then, view your disks by typing <strong>list disk</strong> again to see all available drives on your system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*kf_ZQHk7xGqHeSHC2odi1w.png" /></figure><p>The next step is to identify the problematic disk. Select the disk you want to modify by typing <strong>select disk {X}</strong>. In my case, I’ll <strong>select disk 1</strong> (D: drive) because that’s where I encountered the problem. This command tells DiskPart which disk you’ll be working with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*DR0trib5oRm8LQA61HWXWw.png" /></figure><p>Now that you’ve selected your disk, display all the partitions by typing <strong>list partition</strong>. This command shows you a complete overview of all partitions on the selected disk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*cOuIzagMbH47ttrVJTlIgA.png" /></figure><p>Choose the problematic partition you want to remove by typing <strong>select partition {Y}</strong>. In my situation, partition 3 couldn’t be deleted and left an unallocated volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*TduJultfVyBLNC1StdN_aA.png" /></figure><p>Finally, just type <strong>delete partition override</strong>, and you’re done! This command forcibly removes the partition, bypassing any standard restrictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*KOwkebL4Sp7U8biHg-pC1w.png" /></figure><p>Now in Disk Management, you’ll see that the partition has been deleted, and you can extend the volume as needed. The previously problematic space should now be available for use, allowing you to maximize your storage capacity effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*-QYtwhRnZs9XnWSYBokQZA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5d8b50aae46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing Windows Username]]></title>
            <link>https://medium.com/@syafiqza/changing-windows-username-f6d6258f5bbf?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6d6258f5bbf</guid>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 04:12:35 GMT</pubDate>
            <atom:updated>2024-11-16T09:47:40.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nArnkpKrtNIp6hBmKb-uXA.png" /><figcaption>Windows Powershell showing Windows username</figcaption></figure><p>Changing your Windows username can be tricky and potentially risky if not done correctly. This guide will walk you through the process safely.</p><h3>Creating a Temporary Account</h3><p>First, create a new user account. This step is necessary because you can’t change your current username while logged into it. Open Terminal as administrator and create a new user by running:</p><pre>net user /add {USERNAME} {PASSWORD}</pre><p>After that, verify that the account was created successfully. You can run this command to display all user accounts on your computer:</p><pre>wmic useraccount get name,SID</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*rVWICR1s2TcfVI75yKHe9g.png" /></figure><h3>Changing the Username</h3><p>Sign out and log in to the newly created temporary account. Then, use Windows search to find the <strong>Registry Editor</strong>. Open it by clicking <strong>Run as administrator</strong>.</p><blockquote>Here, make sure that you follow the steps correctly, because incorrect changes can severely damage your old account (I made mistakes before and had to reset Windows, so this is actually my second attempt).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*AzF2pK33mWxRqXFLwa0p6g.png" /></figure><p>You will need to enter your administrator password. This is normal because you’re trying to run it as administrator. In the <strong>Registry Editor</strong>, navigate to this path:</p><p><strong>Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList</strong></p><p>You can copy and paste this path into the address bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*NcLtN7_b1x8s98V-MSsvgw.png" /></figure><p>After that, find and open the registry folder for the account you want to rename.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*bPaZDg7aPgIeyx56yu5MXg.png" /></figure><p>Change the username from the <strong>ProfileImagePath</strong> data to your desired username. Here, I changed it to <strong>Syafiq</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*1Ubwb2T8qfq3lNQ75JStuw.png" /></figure><h3>Updating User Folder</h3><p>Next, open File Explorer and go to <strong>C:\Users</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*kYjyDQL1iH7H0EjOckHHCg.png" /></figure><p>Make sure there are two users there — for me, it’s <strong>safiq</strong> (the current logged-in account) and <strong>SZAri</strong> (the account that I want to change its username). Notice that you can edit the name of the folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*afD2rFQQl3zHyxsz5gZGUw.png" /></figure><p>If you encounter an error like “The action can’t be completed because the folder or file is open in another program” or something similar, you can do a quick restart of your computer. This might happen because when you sign out, there are still files or folders opened using that account.</p><h3>Creating a Safety Link</h3><p>Lastly, you need to create a symbolic link (a shortcut) for safety. Maybe you have other programs that saved your username, and that’ll cause problems too in the long run. To avoid that, just open Terminal and type:</p><pre>mklink /d &quot;C:\Users\{OLDUSERNAME}&quot; &quot;C:\Users\{NEWUSERNAME}&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*eItw8tD6_hpx3Pb_M9kumg.png" /></figure><p>A new shortcut file will be created in the C:\Users folder. You’re done! Log back into that account and delete your temporary account by opening Settings and choosing <strong>Accounts &gt; Other users</strong> (or just copy paste <strong>ms-settings:otherusers</strong> in your browser search, it’ll open up the app quickly).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*ulLTj4RxD_psfpWAfle7tA.png" /></figure><p>Click the <strong>Remove</strong> button and there should be a popup like the image below. Again, if you encounter an error saying you need to restart or something similar, you can just follow the directions and do a quick restart of your computer. Just click on <strong>Delete account and data</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*aEQsO1JM12AoswVRImsjLQ.png" /></figure><p>You are done!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6d6258f5bbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup Flameshot in Linux Mint 22]]></title>
            <link>https://medium.com/@syafiqza/setup-flameshot-in-linux-mint-22-b12a1f48c0f2?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/b12a1f48c0f2</guid>
            <category><![CDATA[screenshots]]></category>
            <category><![CDATA[keyboard-shortcuts]]></category>
            <category><![CDATA[linux-mint]]></category>
            <category><![CDATA[screenshot-tool]]></category>
            <category><![CDATA[flameshot]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Sat, 16 Nov 2024 03:36:41 GMT</pubDate>
            <atom:updated>2024-11-16T09:51:06.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*91IMNILAsf2kiceOR90aeg.png" /><figcaption>System info</figcaption></figure><p>Taking screenshots is a common task for many users, whether for documentation, sharing information, or troubleshooting. While Linux Mint comes with a default screenshot tool, you might want something more feature-rich. This is where Flameshot comes in.</p><p>Flameshot is a powerful screenshot tool that offers advanced features like annotations, shapes, and precise area selection. It is completely free and open-source software (check out the source <a href="https://github.com/flameshot-org/flameshot">here</a>), making it an excellent choice for both personal and professional use.</p><h3>Installation</h3><p>First, install Flameshot using the package manager (apt). You can explore other installation options at <a href="https://flameshot.org/#download">https://flameshot.org/#download</a>. Open your Terminal and run:</p><pre>apt install flameshot</pre><p>After installation, verify Flameshot’s location by running:</p><pre>which flameshot</pre><p>If installed via apt, the location should be <strong>/usr/bin/flameshot</strong>. This step ensures that Flameshot was installed correctly and is accessible from your system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*1UGXzeq8-d0zRtzQe0bcYQ.png" /></figure><h3>Setting Up the Keyboard Shortcut</h3><p>To make Flameshot truly convenient, we’ll set it up to launch with your <strong>PrtSc</strong> key. Navigate to <strong>System Settings &gt; Keyboard &gt; Shortcuts &gt; Custom Shortcuts</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*B4txOkbq6YOGYOuN0i3hIg.png" /></figure><p>Click on <strong>Add custom shortcut</strong> and fill in the following details:</p><ul><li>Name: <strong>flameshot</strong></li><li>Command: <strong>/usr/bin/flameshot gui</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*cfJbajSGkK45gNXM2_gbWg.png" /></figure><p>Click <strong>Add </strong>to confirm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*2lFDn5IyGqhq-OckvAphRg.png" /></figure><p>Double-click on <strong>Keyboard bindings </strong>and press your <strong>PrtSc</strong> button on your keyboard. If <strong>PrtSc</strong> is already bound to another program (like the default gnome-screenshot), simply click <strong>Yes</strong> to reassign it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*yPDfxwkevlZiTdHNKBy4ZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*e1Ro6ELWEIsucg_bsppX1g.png" /></figure><p>Now your <strong>PrtSc</strong> button will trigger Flameshot! Once triggered, you can select an area to capture and use the intuitive toolbar to add annotations, highlights, or shapes before saving your screenshot.</p><p>When I pressed <strong>PrtSc</strong>, I noticed a 2–3 second delay before Flameshot’s screenshot interface appeared. While this might not affect everyone, I decided to investigate the cause.</p><p>To debug the issue, I ran the command /usr/bin/flameshot gui in Terminal and aborted the screenshot process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*rq1bsmovrRpEDhVWTLDCVQ.png" /></figure><p>This produced the following errors:</p><pre>MESA: error: ZINK: failed to choose pdev<br>glx: failed to create drisw screen</pre><p>After investigation, I discovered this was caused by an incorrect NVIDIA driver version. If you’re experiencing similar issues, check out my follow-up article for the solution: [Coming soon]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b12a1f48c0f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building ROS Noetic on Ubuntu 22.04]]></title>
            <link>https://medium.com/@syafiqza/building-ros-noetic-on-ubuntu-22-04-e3a5f02f3e40?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3a5f02f3e40</guid>
            <category><![CDATA[robot-operating-system]]></category>
            <category><![CDATA[ubuntu-22-04-lts]]></category>
            <category><![CDATA[source]]></category>
            <category><![CDATA[ubuntu-22-04]]></category>
            <category><![CDATA[ros-noetic]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 19:09:19 GMT</pubDate>
            <atom:updated>2023-11-15T19:09:19.912Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Disclaimer:</strong> This is my personal documentation of me doing ROS installation from source. The guide is not yet complete, and I’m uncertain about whether I will continue it or not — perhaps during my spare time at the end of the year, but I don’t really know. Thanks to <a href="https://medium.com/u/d255137f8ec6">Lukas Reisinger</a> for showing me that it’s possible.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*WjoKCBb1kJMAb1PR.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fLDMA4SHJ-UVCk4g.jpg" /><figcaption>ROS Noetic Ninjemys x Ubuntu 22.04 LTS</figcaption></figure><p>Hi everyone! I’m Safiq, and today I’m sharing my journey of installing the Robot Operating System (ROS) on my Ubuntu 22.04 LTS computer from the source code. Please note that I decided to undertake this process because I needed to set up my project (which is a ROS Noetic project) in the Ubuntu 22 environment. I have already successfully completed it using a Linux Container (I’ll document that process later), but I wanted to explore an alternative approach. Now, let me take you through the steps I followed:</p><h3>Getting Ready</h3><p>First things first, I made sure I had all the necessary tools. I used the following command to install Python 3, ROS dependencies, and essential build tools:</p><pre>sudo apt-get install python3-rosdep python3-rosinstall-generator python3-vcstools python3-vcstool build-essential</pre><h3>Creating a Special Place</h3><p>I created a dedicated folder for my ROS project called “ros_noetic_base.” Inside this folder, I made another folder named “catkin_ws” (short for workspace) where all the ROS magic would happen:</p><pre>mkdir ros_noetic_base<br>cd ros_noetic_base &amp;&amp; mkdir catkin_ws<br>cd catkin_ws</pre><h3>Bringing in the ROS Gang</h3><p>Now, the exciting part — grabbing the ROS software! I used these commands to download various parts of ROS from the internet:</p><pre>git clone https://github.com/ros/actionlib.git -b 1.14.0<br>git clone https://github.com/ros/bond_core.git -b 1.8.6<br>git clone https://github.com/ros/catkin.git -b 0.8.10<br>git clone https://github.com/ros/class_loader.git -b 0.5.0<br>git clone https://github.com/ros/cmake_modules.git -b 0.5.0<br>git clone https://github.com/ros/common_msgs.git -b 1.13.1<br>git clone https://github.com/ros/dynamic_reconfigure.git -b 1.7.3<br>git clone https://github.com/ros/gencpp.git -b 0.7.0<br>git clone https://github.com/jsk-ros-pkg/geneus.git -b 3.0.0<br>git clone https://github.com/ros/genlisp.git -b 0.4.18<br>git clone https://github.com/ros/genmsg.git -b 0.6.0<br>git clone https://github.com/RethinkRobotics-opensource/gennodejs.git -b 2.0.1<br>git clone https://github.com/ros/genpy.git -b 0.6.16<br>git clone https://github.com/ros/message_generation.git -b 0.4.1<br>git clone https://github.com/ros/message_runtime.git -b 0.4.13<br>git clone https://github.com/ros/nodelet_core.git -b 1.10.2<br>git clone https://github.com/ros/pluginlib.git -b 1.13.0<br>git clone https://github.com/ros/ros.git -b 1.15.8<br>git clone https://github.com/ros/ros_comm.git -b 1.16.0<br>git clone https://github.com/ros/ros_comm_msgs.git -b 1.11.3<br>git clone https://github.com/ros/ros_environment.git -b 1.3.2<br>git clone https://github.com/ros/rosbag_migration_rule.git -b 1.0.1<br>git clone https://github.com/ros/rosconsole.git -b 1.14.3<br>git clone https://github.com/ros/rosconsole_bridge.git -b 0.5.4<br>git clone https://github.com/ros/roscpp_core.git -b 0.7.2<br>git clone https://github.com/ros/roslisp.git -b 1.9.25<br>git clone https://github.com/ros/rospack.git -b 2.6.2<br>git clone https://github.com/ros/std_msgs.git -b 0.5.13</pre><h3>Exploring New Versions</h3><p>Upon checking the repositories one by one, I discovered that some packages had newer versions available. Here are the updated versions:</p><ul><li>ros/bond_core (latest v4.0.0)</li><li>ros/class_loader (latest v2.6.0)</li><li>ros/pluginlib (latest v5.3.0)</li><li>ros/ros_environment (latest v4.2.0)</li><li>ros/roscpp_core (latest v0.7.3)</li></ul><p>In an attempt to use the latest versions, I ventured beyond the guide I was following and attempted to install them all at once. (Please reread the disclaimer above; this documentation is not complete, and I am still encountering some errors.)</p><p>Additionally, I cloned a couple of packages outside the workspace:</p><pre>cd ..<br>git clone https://github.com/ros-infrastructure/catkin_pkg.git -b 1.0.0<br>git clone https://github.com/ros-infrastructure/rospkg.git -b 0.5.2</pre><p>I tried installing their latest versions as well (v1.5.0 for ros-infrastructure/rospkg).</p><p>The dir will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*QkUL5mrDLkfKOLfuj9s9vw.png" /><figcaption>The project tree</figcaption></figure><h3>Patching and Tweaking</h3><p>To address some issues, I copied patches from specific URLs to local files:</p><ul><li><a href="https://gist.githubusercontent.com/Crcodlus/111f25ac48fed5004a86aae7a9d758c7/raw/e21c3fb9ddd04e67f1873855eeef2bcb50ac883a/ros_comm.patch">ros_comm.patch</a> to <strong>ros_noetic_base/catkin_ws/src/ros_comm/ros_comm.patch</strong></li><li><a href="https://gist.githubusercontent.com/Crcodlus/111f25ac48fed5004a86aae7a9d758c7/raw/e21c3fb9ddd04e67f1873855eeef2bcb50ac883a/rosconsole.patch">rosconsole.patch</a> to <strong>ros_noetic_base/catkin_ws/src/rosconsole/rosconsole.patch</strong></li></ul><p>Then, applied the patches:</p><pre>cd catkin_ws/src/ros_comm<br>git apply — ignore-whitespace ros_comm.patch<br><br>cd ../rosconsole<br>git apply --ignore-whitespace rosconsole.patch</pre><h3>Dockerizing the Process</h3><p>I created a Dockerfile to encapsulate the necessary commands for initialization:</p><pre>FROM ubuntu:22.04<br><br>RUN apt-get update &amp;&amp; \<br>        apt-get install -y \<br>        cmake \<br>        build-essential \<br>        python3 \<br>        pip</pre><p>To run it:</p><pre>sudo docker build -t ros_noetic_base .<br>sudo docker run -it --rm -v .:/ros_noetic_base ros_noetic_base bash<br>cd /ros_noetic_base/catkin_pkg &amp;&amp; python3 setup.py install<br>cd /ros_noetic_base/rospkg &amp;&amp; python3 setup.py install<br>cd /ros_noetic_base/catkin_ws<br>./src/catkin/bin/catkin_make_isolated \<br>-DCMAKE_BUILD_TYPE=Release \<br>-DPYTHON_EXECUTABLE=/usr/bin/python3</pre><h3>Troubleshooting</h3><p>If you encounter errors during the process, it’s likely due to missing packages. Add the missing packages to the Dockerfile, and repeat the build and run steps iteratively until all required packages are installed.</p><blockquote>to be continued.</blockquote><p>References:</p><ul><li><a href="https://wiki.ros.org/noetic/Installation/Source">https://wiki.ros.org/noetic/Installation/Source</a></li><li><a href="https://medium.com/@lukas_reisinger/building-ros-noetic-on-ubuntu-22-04-b3ca676c63e7">https://medium.com/@lukas_reisinger/building-ros-noetic-on-ubuntu-22-04-b3ca676c63e7</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3a5f02f3e40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Cannot Connect to The Docker Daemon”]]></title>
            <link>https://medium.com/@syafiqza/cannot-connect-to-the-docker-daemon-1424b156ea4a?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/1424b156ea4a</guid>
            <category><![CDATA[connect]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-daemon]]></category>
            <category><![CDATA[docker-push]]></category>
            <category><![CDATA[docker-image]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 18:24:04 GMT</pubDate>
            <atom:updated>2023-11-15T18:24:04.380Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, it’s Safiq again! I had a strange experience with Docker (or maybe it was Ubuntu causing the issue; I’m not sure, as regular Ubuntu users may understand).</p><p>Here’s what happened: <strong>My computer froze</strong> <strong>while I was sending my work to Azure.</strong> Even the mouse didn’t work!</p><p>After my computer started working again, I found out that the problem was with the command prompt — the program I was using. It was not responding, so I had to close it (bet you’ve never dealt with that). But the weird part was that Docker, the tool I use for work, got stuck in it. No matter what Docker command I tried, it said, <strong>“Cannot connect to the Docker daemon at unix://home/safiqq/.docker/desktop/docker.sock”,</strong> where <strong>safiqq </strong>is my host name.</p><p>I looked for solutions on places like Stack Overflow, but nothing helped. Docker was still stuck. So, I tried something that came to my mind. I opened the Docker Desktop app, deleted all my containers and images, and guess what? It suddenly started working again! I don’t know why this weird solution worked, but I was happy to get back to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jEl1-86Y8fFXQGahQ2_N0Q.png" /><figcaption>The before and after</figcaption></figure><p>This whole experience reminded me that technology can be unpredictable. Sometimes things go wrong, and we don’t know why. At times, you might need to try unusual solutions to fix problems. So, here’s to technology and its mysteries. I’m glad to share this story with you, and I’ll see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1424b156ea4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blank Screen in Visual Studio Code]]></title>
            <link>https://medium.com/@syafiqza/blank-screen-in-visual-studio-code-d84707001c94?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/d84707001c94</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[black-screen]]></category>
            <category><![CDATA[ubuntu-20-04]]></category>
            <category><![CDATA[blank-screen]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Thu, 14 Sep 2023 16:11:21 GMT</pubDate>
            <atom:updated>2023-09-14T16:12:00.672Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, it’s me again, Safiq! Lately, I’ve had a problem with Visual Studio Code (VS Code) on Ubuntu 20.04. It’s frustrating, but I found some solutions that might help you too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YKLDOAkeNGFlasWrQZJ9zA.png" /></figure><h3>The Annoying Problem</h3><p>Imagine you want to write code, but when you open VS Code, you see a blank screen (sometimes accompanied by white shapes) instead. It’s frustrating, right? I figured out why it happens, and here’s the simple explanation:</p><ul><li><strong>GPU Trouble</strong>: VS Code uses your computer’s graphics power (GPU) to display things. But sometimes, your GPU and VS Code don’t get along. Some GPUs just don’t work well with how VS Code shows stuff, causing the blank screen and white shapes.</li><li><strong>Broken Cache:</strong> VS Code stores some pictures in a special place (cache) to make things faster. But if this place gets messed up, it can cause problems.</li></ul><h3>Solution 1: Easier but Temporary</h3><p>I tried the easy way first — launching VS Code with a special command. It tells VS Code to stop using the GPU and use your computer’s regular power instead. It’s quick, but you need to do it every time you open VS Code.</p><ol><li>Open your computer’s command thing (we call it a terminal).</li><li>Type this command to open VS Code:</li></ol><pre>code --disable-gpu</pre><p>This command makes sure VS Code doesn’t use the GPU, which often fixes the blank screen. But, using your computer’s power instead might make things a bit slower.</p><h3>Solution 2: A Bit Tougher but Permanent</h3><p>The second way is a bit trickier but gets rid of the problem for good. It’s like cleaning up a mess to make your room tidy again.</p><ol><li>Make sure VS Code is closed — not running.</li><li>Open the terminal again.</li><li>Go to a special folder where VS Code keeps its things, find a folder called “GPUCache” and delete it.</li></ol><pre>cd $HOME/.config/Code<br>rm -r GPUCache</pre><p>Finally, restart VS Code with code. Voila!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MwoHNJvyAsikPvarS2EMQ.png" /></figure><p>This action wipes out the broken cache, and VS Code makes a new one. It’s like giving it a fresh start, and the blank screen and white shapes should disappear.</p><p>In the end, I learned that you can make VS Code behave even when it’s acting up. Using the --disable-gpu trick or cleaning out the cache can help you get back to coding without any problems. Just choose the way that works best for you, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d84707001c94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring PostgreSQL Authentication in Linux: From Peer to Password]]></title>
            <link>https://medium.com/@syafiqza/configuring-postgresql-authentication-in-linux-from-peer-to-password-1bde0445c4da?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bde0445c4da</guid>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[methods]]></category>
            <category><![CDATA[md5]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 18:13:17 GMT</pubDate>
            <atom:updated>2023-07-26T00:40:40.271Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, it’s me again, Syafiq Ziyadul Arifin a.k.a. Safiq. Recently, I’ve been installing PostgreSQL on my Linux system (I used to have PostgreSQL on Windows). Anddd the first thing I did after installation was, of course, trying to connect using psql -U postgres as usual. However, I encountered an error that left me a bit confused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*LCToFrOXJyTxV4-WlGgCIg.png" /><figcaption>psql: error: connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed: FATAL: Peer authentication failed for user “postgres”</figcaption></figure><p>After some debugging, I realized that the default authentication method for PostgreSQL in Linux is set to “peer.”</p><p>Now, what exactly does that mean? First, let me tell you that PostgreSQL has several authentication methods like “md5<strong>”</strong>, “peer<strong>”</strong>, and others.</p><p>When the auth-method is set to “peer”, PostgreSQL will only allow the “postgres” user to log in to PostgreSQL and not any other user. This has been a bit inconvenient for me, as I had to use sudo -i -u postgres and then psql every time, especially when I needed to import some .sql files.</p><p>So, how do we change this authentication method? Actually, it’s pretty easy. I just need to know the version of my PostgreSQL. There are 2 ways I recommend to find it out: you can either log in to your PostgreSQL or check your PostgreSQL’s path (/etc/postgresql/{VERSION}).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*B6XKUEu0i8G6rNGnZOBDEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*vx7PZs_dcfNNGNelgcN2vw.png" /><figcaption>PostgreSQL v15</figcaption></figure><p>After determining your PostgreSQL version (mine is 15), you can proceed to edit the configuration file called pg_hba by entering the command sudo nano /etc/postgresql/{VERSION}/main/pg_hba.conf. Remember to use sudo to avoid encountering a permission denied error.</p><p>Upon scrolling down, you will come across the following lines:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*Y60pXpVudvxK3irUwF4TQQ.png" /></figure><p>Now, you need to change the “peer” entry, which is written under the “Database administrative login by Unix domain socket,” to “md5.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*5BNSqKniKiQQZwaNePLtzQ.png" /></figure><p>After making this change, save the file by pressing Ctrl+X, followed by Y, and then press Enter.</p><p>If you attempt to log in using psql -U postgres, you might still encounter the peer authentication error message, as shown in the first image. To apply the configuration changes, you must restart PostgreSQL by running the command sudo systemctl restart postgresql.</p><p>And voila! You can now log in using your password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*z_FwWP7UhXM5w3KUEENPaQ.png" /></figure><p>Reference(s):</p><ul><li><a href="https://www.postgresql.org/docs/current/auth-pg-hba-conf.html">https://www.postgresql.org/docs/current/auth-pg-hba-conf.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bde0445c4da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embedded System #11 — Ultrasonic vs IR Sensor]]></title>
            <link>https://medium.com/@syafiqza/embedded-system-11-ultrasonic-vs-ir-sensor-b4c6b519fe7?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4c6b519fe7</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[measurement]]></category>
            <category><![CDATA[distance]]></category>
            <category><![CDATA[hc-sr04]]></category>
            <category><![CDATA[hw201]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Sun, 07 May 2023 13:33:41 GMT</pubDate>
            <atom:updated>2023-05-12T02:30:46.200Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, it’s me again, Syafiq Ziyadul Arifin, also known as Safiq. In this eleventh project (you can get the list <a href="https://medium.com/@syafiqza/list/ii2260-embedded-system-d14058244e53">here</a>), I want to talk to you about sensors that measure distance and how they work. Specifically, I’ll explain the difference between ultrasonic and IR sensors. So, let’s dive in!</p><h3>Components Used:</h3><ul><li>ESP32 Devkit V1</li><li>Data cable (USB type A to Micro B)</li><li>Jumper cables</li><li>Breadboard</li><li>HC-SR04</li><li>HW201</li></ul><h3>Distance Measurement</h3><p>A range sensor and an IR (infrared) sensor are both types of sensors used to detect distance, but they work based on different principles.</p><p>Range sensors, also known as distance sensors, are used to measure the distance between the sensor and an object. They work based on the principle of time of flight, which involves measuring the time it takes for a signal to travel from the sensor to the object and back again. The most common types of range sensors include ultrasonic sensors and laser rangefinders.</p><p>Ultrasonic sensors, such as the HC-SR04, emit high-frequency sound waves and measure the time it takes for the waves to bounce back from an object. The distance to the object can then be calculated based on the time of flight of the sound waves (which is 340 m/s). Ultrasonic sensors are commonly used in applications such as obstacle detection, parking sensors, and distance measurement.</p><p>Laser rangefinders, on the other hand, emit laser beams and measure the time it takes for the laser to reflect off an object and return to the sensor. The distance to the object can be calculated based on the time of flight of the laser beam. Laser rangefinders are used in a wide range of applications, including surveying, construction, and military operations.</p><p>IR sensors, also known as infrared sensors, are used to detect the presence or proximity of an object. They work based on the principle of reflection, which involves emitting a beam of infrared light and measuring the amount of light that reflects back to the sensor. The most common types of IR sensors include passive infrared (PIR) sensors and infrared proximity sensors.</p><p>Passive infrared (PIR) sensors are used to detect changes in the amount of infrared radiation emitted by an object. They are commonly used in motion detectors for security systems and automatic lighting systems.</p><p>Infrared proximity sensors emit infrared light and measure the amount of light that reflects back to the sensor. The amount of light detected can be used to determine the distance to the object. Infrared proximity sensors are commonly used in robotics, automation, and mobile devices for touchless gesture control.</p><h3>NewPing Library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*2yAJFXzsPY9UCHjCq1PfXQ.png" /></figure><p>To make the HC-SR04 sensor work, we must first install the NewPing library. NewPing library is a popular Arduino library that simplifies the process of communicating with ultrasonic sensors. With its simple interface, the library reduces the complexity of the code required to read and interpret sensor data, making it easier to develop and troubleshoot code.</p><p>The library is designed to be highly efficient and accurate, using a timer-based approach to measure the distance to an object. It uses an optimized algorithm that minimizes the number of instructions required to perform a distance measurement, making it ideal for use on resource-constrained microcontrollers such as the ESP32. Additionally, the library is <strong>non-blocking</strong>, allowing the microcontroller to continue running other code while waiting for a distance measurement. This is particularly useful in applications that require real-time processing or multitasking.</p><p>The library provides several functions to control the sensor, such as sonar.ping() to trigger a distance measurement, sonar.ping_cm() to return the distance in centimeters, and sonar.ping_in() to return the distance in inches. These functions can be easily integrated into your code to perform distance measurements and control other parts of your project based on the measured distance.</p><h3>Circuit</h3><p>Because the circuit is simple, I won’t be using a simulator and will instead build it directly on my breadboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*fAHWgQML0KrizeQeP4D3zw.png" /></figure><p>The steps are as follows:</p><ol><li>Connect the GND pin to the negative rail on the breadboard.</li><li>Next, connect the VIN pin to the positive rail on the breadboard.</li><li>Connect the negative rail to both Gnd of HC-SR04 and HW201, and connect the positive rail to both Vcc of HC-SR04 and HW201.</li><li>Connect the HC-SR04’s Echo pin to digital pin 26 and the Trigger pin to digital pin 27.</li><li>Finally, connect the HW201’s Out pin to digital pin 14.</li></ol><h3>Code</h3><p>To use the HC-SR04 and HW201, I have created the following code:</p><pre>#include &lt;NewPing.h&gt;<br><br>#define ECHO_PIN_HC_SR04 26<br>#define TRIGGER_PIN_HC_SR04 27<br>#define MAX_DISTANCE_HC_SR04 200<br><br>NewPing sonar(TRIGGER_PIN_HC_SR04, ECHO_PIN_HC_SR04, MAX_DISTANCE_HC_SR04);<br><br>#define HW201_PIN 14<br><br>void setup() {<br>  Serial.begin(115200);<br>  pinMode(HW201_PIN, INPUT);<br>}<br><br>void loop() {<br>  // Read distance from HC-SR04 sensor<br>  delay(50);<br>  unsigned int distance = sonar.ping_cm();<br>  Serial.print(distance);<br>  <br>  Serial.print(&quot;,&quot;);<br>  <br>  // Read value from HW201 sensor<br>  int hw201_value = digitalRead(HW201_PIN);<br>  Serial.println(hw201_value);<br>}</pre><p>Let’s break down the code.*</p><p>First, it defines some pins and variables. It then creates a NewPing object with the defined pins and maximum distance. In the setup() function, it initializes the serial communication and sets the mode of the HW201 pin to INPUT. In the loop() function, it reads the distance from the HC-SR04 sensor using the ping_cm() function, and prints it to the serial monitor. It then reads the value from the HW201 sensor using the digitalRead() function and prints it to the serial monitor. The delay() function is used to wait for the HC-SR04 sensor to complete its measurement before reading its value again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*gKO3EboZa4wymyMeqsghkA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*JCvYUgK-0jGjo-WiugClCQ.gif" /></figure><p>Congratulations! You have successfully finished your eleventh project using the ESP32 and the Arduino IDE. Through this project, you have gained knowledge about the differences between ultrasonic and IR sensors, and learned how to measure distances using these sensors. While this marks the end of the <a href="https://medium.com/@syafiqza/list/ii2260-embedded-system-d14058244e53">II2260 Embedded System</a> playlist, I may still post about my other projects in the future.</p><p>I hope you have enjoyed learning and experimenting with these projects, and that you have gained new insights and skills along the way. If you have any questions or need further assistance, please feel free to reach out to me. Remember, tinkering and experimenting is a fun and rewarding way to learn new things and explore your creativity. Keep exploring and happy tinkering!</p><p>(*) Trivia:</p><ul><li>Although my ESP32 Devkit V1 has pins that are all digital, I just realized that some of them are only useful for input (digital pins 34, 35, 36, and 39).</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4c6b519fe7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embedded System #10 — Data Visualization and Data Logging]]></title>
            <link>https://medium.com/@syafiqza/embedded-system-10-data-visualization-and-data-logging-56bab91a19ca?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/56bab91a19ca</guid>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[bmp280]]></category>
            <category><![CDATA[weather]]></category>
            <category><![CDATA[arduino]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 10:42:43 GMT</pubDate>
            <atom:updated>2023-06-21T17:26:11.548Z</atom:updated>
            <content:encoded><![CDATA[<h3>Embedded System #10 — Data Visualization and Data Logging</h3><p>Hi, it’s me again, Syafiq Ziyadul Arifin, also known as Safiq. In this tenth project (you can get the list <a href="https://medium.com/@syafiqza/list/ii2260-embedded-system-d14058244e53">here</a>), I’m excited to show you how to sync your database with Google Sheets and create a line chart to visualize the data. So, let’s dive in!</p><h3>Components Used:</h3><ul><li>ESP32 Devkit V1</li><li>Smartphone or PC</li><li>Data cable (USB type A to Micro B)</li><li>BMP280</li><li>Jumper cables (male to female)</li><li>Breadboard</li></ul><h3>Arduino IDE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWx50jjr8zp_uAtgTRzmnQ.png" /></figure><p>If you’ve been following my stories since <a href="https://medium.com/@syafiqza/embedded-system-1-led-blink-with-esp32-22fb55e62f38">project #1</a>, you know that I’ve been using Arduino IDE v2.0.3. However, I’ve realized that Arduino IDE v2 doesn’t have the SPIFFS upload tools that we’ll be needing. Luckily, I have a solution for this. I’ve downloaded Arduino IDE v1 (thanks to <a href="https://medium.com/u/f55c06317084">Hafidz Shidqi</a>), and as of April 19th, 2023, the latest version is v1.8.19.</p><h3>SPIFFS</h3><p>SPIFFS is a lightweight filesystem created for microcontrollers with a flash chip, which is connected by SPI bus, like the ESP32 flash memory.</p><p>SPIFFS lets you access the flash memory like you would do in a normal filesystem in your computer, but simpler and more limited. You can read, write, close, and delete files. At the time of writing this post, SPIFFS doesn’t support directories, so everything is saved on a flat structure.</p><p>Using SPIFFS with the ESP32 board is especially useful to:</p><ul><li>Create configuration files with settings</li><li>Save data permanently</li><li>Create files to save small amounts of data instead of using a microSD card</li><li>Save HTML and CSS files to build a web server</li><li>Save images, figures, and icons</li><li>etc.</li></ul><p>SPIFFS lets you write HTML and CSS in separate files and save them on the ESP32 filesystem. However, manually writing code in Arduino IDE to create, save, and write files to the ESP32 can be inconvenient. Luckily, there’s a plugin for Arduino IDE that makes it easy to upload files from your computer to the ESP32 filesystem. Let’s install it for easy and efficient file management.</p><h3>SPIFFS Upload Tool</h3><p>Download the latest release from <a href="https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/">https://github.com/me-no-dev/arduino-esp32fs-plugin/releases/</a> (ESP32FS-1.x.zip).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YiAlpVx2rQC73U4klrVMag.png" /></figure><p>Once the download is complete, open your Arduino IDE and click on <strong>File &gt; Preferences</strong> in the menu bar. From there, locate and copy your sketchbook’s location. Next, open your File Explorer and paste the sketchbook’s location into the address bar. This will take you directly to the sketchbook folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*Wqop3RDiBucSS6ad9IA-Eg.png" /></figure><p>Once you’re there, unzip the folder that you downloaded earlier. Then, unzip the folder that we downloaded before, follow the tree I give below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*ypnIoJJx3UOef5Eqi32fCA.png" /></figure><h3>AsyncWebServer Library</h3><p>Download the repository <a href="https://github.com/me-no-dev/ESPAsyncWebServer">https://github.com/me-no-dev/ESPAsyncWebServer</a> as a ZIP file. Next, open your Arduino IDE and navigate to <strong>Sketch &gt; Include Library &gt; Add .ZIP Library…</strong> and select the library that you downloaded earlier. Don’t forget to also include the repository <a href="https://github.com/me-no-dev/AsyncTCP">https://github.com/me-no-dev/AsyncTCP</a>, as it is a dependency of AsyncWebServer.</p><h3>Circuit</h3><p>I’m going to be using the same circuit that I used for <a href="https://medium.com/@syafiqza/embedded-system-7-bluetooth-connections-in-esp32-b190ff39cec3">project #7</a> (but without the LED), so if you don’t mind, please take a look at it.</p><h3>Code</h3><p>You can access and download the code I’ve created, which comprises the ESP32 code and the HTML files that will function as the server.</p><pre>// datavislog.ino<br><br>#include &lt;WiFi.h&gt;<br>#include &lt;ESPAsyncWebServer.h&gt;<br>#include &lt;SPIFFS.h&gt;<br>#include &lt;Wire.h&gt;<br>#include &lt;Adafruit_Sensor.h&gt;<br>#include &lt;Adafruit_BMP280.h&gt;<br>#include &lt;string&gt;<br><br>Adafruit_BMP280 bmp;<br><br>// replace with your network credentials<br>const char* ssid = &quot;Safiq&quot;;<br>const char* password = &quot;Medium@syafiqza&quot;;<br><br>// create AsyncWebServer object on port 80<br>AsyncWebServer server(80);<br><br>void setup(){<br>  // serial port for debugging purposes<br>  Serial.begin(115200);<br>  <br>  bool status; <br>  // default settings<br>  // (you can also pass in a Wire library object like &amp;Wire2)<br>  status = bmp.begin(0x76);  <br>  if (!status) {<br>    Serial.println(&quot;Could not find a valid BMP280 sensor, check wiring!&quot;);<br>    while (1);<br>  }<br><br>  // initialize SPIFFS<br>  if(!SPIFFS.begin()){<br>    Serial.println(&quot;An Error has occurred while mounting SPIFFS&quot;);<br>    return;<br>  }<br><br>  // connect to Wi-Fi<br>  WiFi.begin(ssid, password);<br>  while (WiFi.status() != WL_CONNECTED) {<br>    delay(1000);<br>    Serial.println(&quot;Connecting to WiFi..&quot;);<br>  }<br><br>  // print ESP32 Local IP Address<br>  Serial.println(WiFi.localIP());<br><br>  // route for root / web page<br>  server.on(&quot;/&quot;, HTTP_GET, [](AsyncWebServerRequest *request){<br>    request-&gt;send(SPIFFS, &quot;/index.html&quot;);<br>  });<br>  server.on(&quot;/temperature&quot;, HTTP_GET, [](AsyncWebServerRequest *request){<br>    request-&gt;send_P(200, &quot;text/plain&quot;, std::to_string(bmp.readTemperature()).c_str());<br>  });<br>  server.on(&quot;/pressure&quot;, HTTP_GET, [](AsyncWebServerRequest *request){<br>    request-&gt;send_P(200, &quot;text/plain&quot;, std::to_string(bmp.readPressure()).c_str());<br>  });<br>  server.on(&quot;/altitude&quot;, HTTP_GET, [](AsyncWebServerRequest *request){<br>    request-&gt;send_P(200, &quot;text/plain&quot;, std::to_string(bmp.readAltitude()).c_str());<br>  });<br><br>  // start server<br>  server.begin();<br>}<br> <br>void loop() {}</pre><pre>&lt;!-- data/index.html --&gt;<br><br>&lt;!DOCTYPE HTML&gt;<br>&lt;html&gt;<br><br>&lt;head&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>  &lt;script src=&quot;https://code.highcharts.com/highcharts.js&quot;&gt;&lt;/script&gt;<br>  &lt;style&gt;<br>    body {<br>      min-width: 310px;<br>      max-width: 800px;<br>      height: 400px;<br>      margin: 0 auto;<br>    }<br><br>    h2 {<br>      font-family: Arial;<br>      font-size: 2.5rem;<br>      text-align: center;<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>  &lt;h2&gt;ESP Weather Station&lt;/h2&gt;<br>  &lt;div id=&quot;chart-temperature&quot; class=&quot;container&quot;&gt;&lt;/div&gt;<br>  &lt;div id=&quot;chart-pressure&quot; class=&quot;container&quot;&gt;&lt;/div&gt;<br>  &lt;div id=&quot;chart-altitude&quot; class=&quot;container&quot;&gt;&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;script&gt;<br>  let x, y1, y2, y3;<br>  let chartT = new Highcharts.Chart({<br>    chart: { renderTo: &#39;chart-temperature&#39; },<br>    title: { text: &#39;BMP280 Temperature&#39; },<br>    series: [{<br>      showInLegend: false,<br>      data: []<br>    }],<br>    plotOptions: {<br>      line: {<br>        animation: false,<br>        dataLabels: { enabled: true }<br>      },<br>      series: { color: &#39;#059e8a&#39; }<br>    },<br>    xAxis: {<br>      type: &#39;datetime&#39;,<br>      dateTimeLabelFormats: { second: &#39;%H:%M:%S&#39; }<br>    },<br>    yAxis: {<br>      title: { text: &#39;Temperature (C)&#39; }<br>    },<br>    credits: { enabled: false }<br>  });<br><br>  let chartP = new Highcharts.Chart({<br>    chart: { renderTo: &#39;chart-pressure&#39; },<br>    title: { text: &#39;BMP280 Pressure&#39; },<br>    series: [{<br>      showInLegend: false,<br>      data: []<br>    }],<br>    plotOptions: {<br>      line: {<br>        animation: false,<br>        dataLabels: { enabled: true }<br>      },<br>      series: { color: &#39;#18009c&#39; }<br>    },<br>    xAxis: {<br>      type: &#39;datetime&#39;,<br>      dateTimeLabelFormats: { second: &#39;%H:%M:%S&#39; }<br>    },<br>    yAxis: {<br>      title: { text: &#39;Pressure (Pa)&#39; }<br>    },<br>    credits: { enabled: false }<br>  });<br><br>  let chartA = new Highcharts.Chart({<br>    chart: { renderTo: &#39;chart-altitude&#39; },<br>    title: { text: &#39;BMP280 Altitude&#39; },<br>    series: [{<br>      showInLegend: false,<br>      data: []<br>    }],<br>    plotOptions: {<br>      line: {<br>        animation: false,<br>        dataLabels: { enabled: true }<br>      }<br>    },<br>    xAxis: {<br>      type: &#39;datetime&#39;,<br>      dateTimeLabelFormats: { second: &#39;%H:%M:%S&#39; }<br>    },<br>    yAxis: {<br>      title: { text: &#39;Altitude (m)&#39; }<br>    },<br>    credits: { enabled: false }<br>  });<br><br>  fetch(`https://api.allorigins.win/get?url=${encodeURIComponent(&#39;https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280&#39;)}`)<br>    .then(response =&gt; {<br>      if (response.ok) return response.json()<br>      throw new Error(&#39;Network response was not ok.&#39;)<br>    })<br>    .then(data =&gt; {<br>      data.contents = JSON.parse(data.contents).slice(-5);<br>      for (let i = 0; i &lt; data.contents.length; i++) {<br>        x = new Date(data.contents[i].timestamp).getTime() + 2.52 * (10 ** 7),<br>          y1 = data.contents[i].temperature,<br>          y2 = data.contents[i].pressure,<br>          y3 = data.contents[i].altitude;<br>        if (new Date().getTime() - x &lt;= 3600000) {<br>          if (chartT.series[0].data.length &gt; 40) chartT.series[0].addPoint([x, y1], true, true, true);<br>          else chartT.series[0].addPoint([x, y1], true, false, true);<br>          if (chartP.series[0].data.length &gt; 40) chartP.series[0].addPoint([x, y2], true, true, true);<br>          else chartP.series[0].addPoint([x, y2], true, false, true);<br>          if (chartA.series[0].data.length &gt; 40) chartA.series[0].addPoint([x, y3], true, true, true);<br>          else chartA.series[0].addPoint([x, y3], true, false, true);<br>        }<br>      }<br>    });<br><br>  setInterval(function () {<br>    let xhttp = new XMLHttpRequest();<br>    xhttp.onreadystatechange = function () {<br>      if (this.readyState == 4 &amp;&amp; this.status == 200) {<br>        x = (new Date()).getTime() + 2.52 * (10 ** 7),<br>          y1 = parseFloat(this.responseText);<br>        if (chartT.series[0].data.length &gt; 40) chartT.series[0].addPoint([x, y1], true, true, true);<br>        else chartT.series[0].addPoint([x, y1], true, false, true);<br>      }<br>    };<br>    xhttp.open(&quot;GET&quot;, &quot;/temperature&quot;, true);<br>    xhttp.send();<br>  }, 30000);<br><br>  setInterval(function () {<br>    let xhttp = new XMLHttpRequest();<br>    xhttp.onreadystatechange = function () {<br>      if (this.readyState == 4 &amp;&amp; this.status == 200) {<br>        x = (new Date()).getTime() + 2.52 * (10 ** 7),<br>          y2 = parseFloat(this.responseText);<br>        if (chartP.series[0].data.length &gt; 40) chartP.series[0].addPoint([x, y2], true, true, true);<br>        else chartP.series[0].addPoint([x, y2], true, false, true);<br>      }<br>    };<br>    xhttp.open(&quot;GET&quot;, &quot;/pressure&quot;, true);<br>    xhttp.send();<br>  }, 30000);<br><br>  setInterval(function () {<br>    let xhttp = new XMLHttpRequest();<br>    xhttp.onreadystatechange = function () {<br>      if (this.readyState == 4 &amp;&amp; this.status == 200) {<br>        x = (new Date()).getTime() + 2.52 * (10 ** 7),<br>          y3 = parseFloat(this.responseText);<br>        if (chartA.series[0].data.length &gt; 40) chartA.series[0].addPoint([x, y3], true, true, true);<br>        else chartA.series[0].addPoint([x, y3], true, false, true);<br>      }<br>    };<br>    xhttp.open(&quot;GET&quot;, &quot;/altitude&quot;, true);<br>    xhttp.send();<br>  }, 30000);<br><br>  setInterval(function () {<br>    fetch(&quot;https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280&quot;, {<br>      method: &quot;POST&quot;,<br>      mode: &quot;no-cors&quot;,<br>      body: JSON.stringify({<br>        temperature: y1,<br>        pressure: y2,<br>        altitude: y3<br>      })<br>    });<br>  }, 30000);<br>&lt;/script&gt;<br><br>&lt;/html&gt;</pre><p>Let’s break down the code.</p><p>The sketch includes several libraries for different functionalities, such as WiFi communication, serving web pages, accessing the SPIFFS file system, and interfacing with the BMP280 sensor.</p><p>The Adafruit_BMP280 library is used to interface with the BMP280 sensor. The bmp object is created as an instance of the Adafruit_BMP280 class, and the begin() function is called to initialize the sensor with the default address (0x76). If the sensor is not found, an error message is printed to the serial monitor.</p><p>The SPIFFS (SPI Flash File System) is used to store the web pages that will be served by the web server. The SPIFFS.begin() function is called to mount the SPIFFS file system, and if it fails, an error message is printed to the serial monitor.</p><p>The sketch connects to a Wi-Fi network using the WiFi.begin() function with the SSID (network name) and password provided. The sketch waits in a loop until the connection is successful, and the local IP address of the ESP32 is printed to the serial monitor.</p><p>The server object is an instance of the AsyncWebServer class that will handle incoming HTTP requests. Several routes are defined using the server.on() function, which specifies the URL path, HTTP method, and a lambda function that will be called when a request matches the route. The lambda functions send the corresponding data read from the BMP280 sensor as responses with the appropriate HTTP status code and content type.</p><p>The server.begin() function is called to start the web server and listen for incoming requests.</p><p>The loop() function is empty in this sketch, meaning it does nothing and the program just waits for incoming requests to be handled by the web server.</p><p>Inside the body section, there is a heading (h2) element with the text “ESP Weather Station”, and three div elements with unique IDs (chart-temperature, chart-pressure, and chart-altitude) that will be used as containers for the Highcharts charts.</p><p>In the script section, JavaScript code is used to create three instances of Highcharts charts, one for each container. These charts are configured with various options, such as title, series data, plot options, x-axis and y-axis configurations, and credits. These options define the appearance and behavior of the charts, such as the type of chart, data to be plotted, colors, labels, and more.</p><p>The code then uses the fetch function to make an API request to retrieve data from an external API endpoint. The response is parsed as JSON and stored in the data variable. The contents of the data variable are then processed in a loop to extract the timestamp, temperature, pressure, and altitude values. If the timestamp is within the last hour (based on the current time), the temperature, pressure, and altitude values are added to the respective Highcharts series using the addPoint() method. The “true” and “false” arguments in the addPoint() method determine whether to redraw the chart and whether to animate the chart or not.</p><p>Two setInterval() functions are used to periodically make AJAX requests to the server to fetch temperature and pressure data. These requests are made every 30 seconds. The retrieved data is then added to the temperature and pressure series in the Highcharts charts using the addPoint() method, similar to the initial data retrieval.</p><p>Finally, there is an event listener that listens for the “resize” event on the window object, and when triggered, it calls the “redraw” method on all the Highcharts charts to redraw them with the updated container sizes, ensuring that the charts are responsive to window resizing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*jHb_ZSpkaZYV7t7tMY121A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*SM5P9H5agN9rn3tsWHotuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*QKlPuzcWHHahoCU3ZGLn3w.gif" /></figure><h3>Connect to Sheets</h3><p>Open Google Sheets, go to <strong>Extensions &gt; Apps Script</strong>. Add a new script file and copy and paste the code I have written below.</p><pre>/**<br> * Retrieves all the rows in the active spreadsheet that contain data and logs the<br> * values for each row.<br> * For more information on using the Spreadsheet API, see<br> * https://developers.google.com/apps-script/service_spreadsheet<br> */<br>function readRows() {<br>  var sheet = SpreadsheetApp.getActiveSheet();<br>  var rows = sheet.getDataRange();<br>  var numRows = rows.getNumRows();<br>  var values = rows.getValues();<br><br>  for (var i = 0; i &lt;= numRows - 1; i++) {<br>    var row = values[i];<br>    Logger.log(row);<br>  }<br>};<br><br>/**<br> * Adds a custom menu to the active spreadsheet, containing a single menu item<br> * for invoking the readRows() function specified above.<br> * The onOpen() function, when defined, is automatically invoked whenever the<br> * spreadsheet is opened.<br> * For more information on using the Spreadsheet API, see<br> * https://developers.google.com/apps-script/service_spreadsheet<br> */<br>function onOpen() {<br>  var sheet = SpreadsheetApp.getActiveSpreadsheet();<br>  var entries = [{<br>    name : &quot;Read Data&quot;,<br>    functionName : &quot;readRows&quot;<br>  }];<br>  sheet.addMenu(&quot;Script Center Menu&quot;, entries);<br>};<br><br>/*====================================================================================================================================*<br>  ImportJSON by Trevor Lohrbeer (@FastFedora)<br>  ====================================================================================================================================<br>  Version:      1.1<br>  Project Page: http://blog.fastfedora.com/projects/import-json<br>  Copyright:    (c) 2012 by Trevor Lohrbeer<br>  License:      GNU General Public License, version 3 (GPL-3.0) <br>                http://www.opensource.org/licenses/gpl-3.0.html<br>  ------------------------------------------------------------------------------------------------------------------------------------<br>  A library for importing JSON feeds into Google spreadsheets. Functions include:<br>     ImportJSON            For use by end users to import a JSON feed from a URL <br>     ImportJSONAdvanced    For use by script developers to easily extend the functionality of this library<br>  Future enhancements may include:<br>   - Support for a real XPath like syntax similar to ImportXML for the query parameter<br>   - Support for OAuth authenticated APIs<br>  Or feel free to write these and add on to the library yourself!<br>  ------------------------------------------------------------------------------------------------------------------------------------<br>  Changelog:<br>  <br>  1.1    Added support for the noHeaders option<br>  1.0    Initial release<br> *====================================================================================================================================*/<br>/**<br> * Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create <br> * a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in <br> * the JSON feed. The remaining rows contain the data. <br> * <br> * By default, data gets transformed so it looks more like a normal data import. Specifically:<br> *<br> *   - Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values <br> *      of the rows representing their parent elements.<br> *   - Values longer than 256 characters get truncated.<br> *   - Headers have slashes converted to spaces, common prefixes removed and the resulting text converted to title case. <br> *<br> * To change this behavior, pass in one of these values in the options parameter:<br> *<br> *    noInherit:     Don&#39;t inherit values from parent elements<br> *    noTruncate:    Don&#39;t truncate values<br> *    rawHeaders:    Don&#39;t prettify headers<br> *    noHeaders:     Don&#39;t include headers, only the data<br> *    debugLocation: Prepend each value with the row &amp; column it belongs in<br> *<br> * For example:<br> *<br> *   =ImportJSON(&quot;http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&amp;alt=json&quot;, &quot;/feed/entry/title,/feed/entry/content&quot;,<br> *               &quot;noInherit,noTruncate,rawHeaders&quot;)<br> * <br> * @param {url} the URL to a public JSON feed<br> * @param {query} a comma-separated lists of paths to import. Any path starting with one of these paths gets imported.<br> * @param {options} a comma-separated list of options that alter processing of the data<br> *<br> * @return a two-dimensional array containing the data, with the first row containing headers<br> * @customfunction<br> **/<br>function ImportJSON(url, query, options) {<br>  return ImportJSONAdvanced(url, query, options, includeXPath_, defaultTransform_);<br>}<br><br>/**<br> * An advanced version of ImportJSON designed to be easily extended by a script. This version cannot be called from within a <br> * spreadsheet.<br> *<br> * Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create <br> * a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in <br> * the JSON feed. The remaining rows contain the data. <br> *<br> * Use the include and transformation functions to determine what to include in the import and how to transform the data after it is<br> * imported. <br> *<br> * For example:<br> *<br> *   =ImportJSON(&quot;http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&amp;alt=json&quot;, <br> *               &quot;/feed/entry&quot;,<br> *                function (query, path) { return path.indexOf(query) == 0; },<br> *                function (data, row, column) { data[row][column] = data[row][column].toString().substr(0, 100); } )<br> *<br> * In this example, the import function checks to see if the path to the data being imported starts with the query. The transform <br> * function takes the data and truncates it. For more robust versions of these functions, see the internal code of this library.<br> *<br> * @param {url}           the URL to a public JSON feed<br> * @param {query}         the query passed to the include function<br> * @param {options}       a comma-separated list of options that may alter processing of the data<br> * @param {includeFunc}   a function with the signature func(query, path, options) that returns true if the data element at the given path<br> *                        should be included or false otherwise. <br> * @param {transformFunc} a function with the signature func(data, row, column, options) where data is a 2-dimensional array of the data <br> *                        and row &amp; column are the current row and column being processed. Any return value is ignored. Note that row 0 <br> *                        contains the headers for the data, so test for row==0 to process headers only.<br> *<br> * @return a two-dimensional array containing the data, with the first row containing headers<br> **/<br>function ImportJSONAdvanced(url, query, options, includeFunc, transformFunc) {<br>  var jsondata = UrlFetchApp.fetch(url);<br>  var object   = JSON.parse(jsondata.getContentText());<br>  <br>  return parseJSONObject_(object, query, options, includeFunc, transformFunc);<br>}<br><br>/** <br> * Encodes the given value to use within a URL.<br> *<br> * @param {value} the value to be encoded<br> * <br> * @return the value encoded using URL percent-encoding<br> */<br>function URLEncode(value) {<br>  return encodeURIComponent(value.toString());  <br>}<br><br>/** <br> * Parses a JSON object and returns a two-dimensional array containing the data of that object.<br> */<br>function parseJSONObject_(object, query, options, includeFunc, transformFunc) {<br>  var headers = new Array();<br>  var data    = new Array();<br>  <br>  if (query &amp;&amp; !Array.isArray(query) &amp;&amp; query.toString().indexOf(&quot;,&quot;) != -1) {<br>    query = query.toString().split(&quot;,&quot;);<br>  }<br>  <br>  if (options) {<br>    options = options.toString().split(&quot;,&quot;);<br>  }<br>    <br>  parseData_(headers, data, &quot;&quot;, 1, object, query, options, includeFunc);<br>  parseHeaders_(headers, data);<br>  transformData_(data, options, transformFunc);<br>  <br>  return hasOption_(options, &quot;noHeaders&quot;) ? (data.length &gt; 1 ? data.slice(1) : new Array()) : data;<br>}<br><br>/** <br> * Parses the data contained within the given value and inserts it into the data two-dimensional array starting at the rowIndex. <br> * If the data is to be inserted into a new column, a new header is added to the headers array. The value can be an object, <br> * array or scalar value.<br> *<br> * If the value is an object, it&#39;s properties are iterated through and passed back into this function with the name of each <br> * property extending the path. For instance, if the object contains the property &quot;entry&quot; and the path passed in was &quot;/feed&quot;,<br> * this function is called with the value of the entry property and the path &quot;/feed/entry&quot;.<br> *<br> * If the value is an array containing other arrays or objects, each element in the array is passed into this function with <br> * the rowIndex incremeneted for each element.<br> *<br> * If the value is an array containing only scalar values, those values are joined together and inserted into the data array as <br> * a single value.<br> *<br> * If the value is a scalar, the value is inserted directly into the data array.<br> */<br>function parseData_(headers, data, path, rowIndex, value, query, options, includeFunc) {<br>  var dataInserted = false;<br>  <br>  if (isObject_(value)) {<br>    for (key in value) {<br>      if (parseData_(headers, data, path + &quot;/&quot; + key, rowIndex, value[key], query, options, includeFunc)) {<br>        dataInserted = true; <br>      }<br>    }<br>  } else if (Array.isArray(value) &amp;&amp; isObjectArray_(value)) {<br>    for (var i = 0; i &lt; value.length; i++) {<br>      if (parseData_(headers, data, path, rowIndex, value[i], query, options, includeFunc)) {<br>        dataInserted = true;<br>        rowIndex++;<br>      }<br>    }<br>  } else if (!includeFunc || includeFunc(query, path, options)) {<br>    // Handle arrays containing only scalar values<br>    if (Array.isArray(value)) {<br>      value = value.join(); <br>    }<br>    <br>    // Insert new row if one doesn&#39;t already exist<br>    if (!data[rowIndex]) {<br>      data[rowIndex] = new Array();<br>    }<br>    <br>    // Add a new header if one doesn&#39;t exist<br>    if (!headers[path] &amp;&amp; headers[path] != 0) {<br>      headers[path] = Object.keys(headers).length;<br>    }<br>    <br>    // Insert the data<br>    data[rowIndex][headers[path]] = value;<br>    dataInserted = true;<br>  }<br>  <br>  return dataInserted;<br>}<br><br>/** <br> * Parses the headers array and inserts it into the first row of the data array.<br> */<br>function parseHeaders_(headers, data) {<br>  data[0] = new Array();<br><br>  for (key in headers) {<br>    data[0][headers[key]] = key;<br>  }<br>}<br><br>/** <br> * Applies the transform function for each element in the data array, going through each column of each row.<br> */<br>function transformData_(data, options, transformFunc) {<br>  for (var i = 0; i &lt; data.length; i++) {<br>    for (var j = 0; j &lt; data[i].length; j++) {<br>      transformFunc(data, i, j, options);<br>    }<br>  }<br>}<br><br>/** <br> * Returns true if the given test value is an object; false otherwise.<br> */<br>function isObject_(test) {<br>  return Object.prototype.toString.call(test) === &#39;[object Object]&#39;;<br>}<br><br>/** <br> * Returns true if the given test value is an array containing at least one object; false otherwise.<br> */<br>function isObjectArray_(test) {<br>  for (var i = 0; i &lt; test.length; i++) {<br>    if (isObject_(test[i])) {<br>      return true; <br>    }<br>  }  <br><br>  return false;<br>}<br><br>/** <br> * Returns true if the given query applies to the given path. <br> */<br>function includeXPath_(query, path, options) {<br>  if (!query) {<br>    return true; <br>  } else if (Array.isArray(query)) {<br>    for (var i = 0; i &lt; query.length; i++) {<br>      if (applyXPathRule_(query[i], path, options)) {<br>        return true; <br>      }<br>    }  <br>  } else {<br>    return applyXPathRule_(query, path, options);<br>  }<br>  <br>  return false; <br>};<br><br>/** <br> * Returns true if the rule applies to the given path. <br> */<br>function applyXPathRule_(rule, path, options) {<br>  return path.indexOf(rule) == 0; <br>}<br><br>/** <br> * By default, this function transforms the value at the given row &amp; column so it looks more like a normal data import. Specifically:<br> *<br> *   - Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values <br> *     of the rows representing their parent elements.<br> *   - Values longer than 256 characters get truncated.<br> *   - Values in row 0 (headers) have slashes converted to spaces, common prefixes removed and the resulting text converted to title <br>*      case. <br> *<br> * To change this behavior, pass in one of these values in the options parameter:<br> *<br> *    noInherit:     Don&#39;t inherit values from parent elements<br> *    noTruncate:    Don&#39;t truncate values<br> *    rawHeaders:    Don&#39;t prettify headers<br> *    debugLocation: Prepend each value with the row &amp; column it belongs in<br> */<br>function defaultTransform_(data, row, column, options) {<br>  if (!data[row][column]) {<br>    if (row &lt; 2 || hasOption_(options, &quot;noInherit&quot;)) {<br>      data[row][column] = &quot;&quot;;<br>    } else {<br>      data[row][column] = data[row-1][column];<br>    }<br>  } <br><br>  if (!hasOption_(options, &quot;rawHeaders&quot;) &amp;&amp; row == 0) {<br>    if (column == 0 &amp;&amp; data[row].length &gt; 1) {<br>      removeCommonPrefixes_(data, row);  <br>    }<br>    <br>    data[row][column] = toTitleCase_(data[row][column].toString().replace(/[\/\_]/g, &quot; &quot;));<br>  }<br>  <br>  if (!hasOption_(options, &quot;noTruncate&quot;) &amp;&amp; data[row][column]) {<br>    data[row][column] = data[row][column].toString().substr(0, 256);<br>  }<br><br>  if (hasOption_(options, &quot;debugLocation&quot;)) {<br>    data[row][column] = &quot;[&quot; + row + &quot;,&quot; + column + &quot;]&quot; + data[row][column];<br>  }<br>}<br><br>/** <br> * If all the values in the given row share the same prefix, remove that prefix.<br> */<br>function removeCommonPrefixes_(data, row) {<br>  var matchIndex = data[row][0].length;<br><br>  for (var i = 1; i &lt; data[row].length; i++) {<br>    matchIndex = findEqualityEndpoint_(data[row][i-1], data[row][i], matchIndex);<br><br>    if (matchIndex == 0) {<br>      return;<br>    }<br>  }<br>  <br>  for (var i = 0; i &lt; data[row].length; i++) {<br>    data[row][i] = data[row][i].substring(matchIndex, data[row][i].length);<br>  }<br>}<br><br>/** <br> * Locates the index where the two strings values stop being equal, stopping automatically at the stopAt index.<br> */<br>function findEqualityEndpoint_(string1, string2, stopAt) {<br>  if (!string1 || !string2) {<br>    return -1; <br>  }<br>  <br>  var maxEndpoint = Math.min(stopAt, string1.length, string2.length);<br>  <br>  for (var i = 0; i &lt; maxEndpoint; i++) {<br>    if (string1.charAt(i) != string2.charAt(i)) {<br>      return i;<br>    }<br>  }<br>  <br>  return maxEndpoint;<br>}<br><br>/** <br> * Converts the text to title case.<br> */<br>function toTitleCase_(text) {<br>  if (text == null) {<br>    return null;<br>  }<br>  <br>  return text.replace(/\w\S*/g, function(word) { return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); });<br>}<br><br>/** <br> * Returns true if the given set of options contains the given option.<br> */<br>function hasOption_(options, option) {<br>  return options &amp;&amp; options.indexOf(option) &gt;= 0;<br>}</pre><p>Then, open the sheet and copy and paste the formula below into the first cell (A1).</p><blockquote><em>=ImportJSON(“https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280&quot;)</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*EQel-sQvbMonOPVGEPgGEQ.png" /></figure><p>Congratulations! You have successfully finished your tenth project using the ESP32 and the Arduino IDE. Now you can sync your database with Google Sheets and create line charts to visualize your data. If you have any questions, feel free to reach out to me. Happy tinkering!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56bab91a19ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embedded System #9 — Insert ESP32 Data Into MySQL]]></title>
            <link>https://medium.com/@syafiqza/embedded-system-9-insert-esp32-data-into-mysql-b12ed1543195?source=rss-f003533f7946------2</link>
            <guid isPermaLink="false">https://medium.com/p/b12ed1543195</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[post]]></category>
            <category><![CDATA[esp32]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Syafiq Ziyadul Arifin]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 04:54:21 GMT</pubDate>
            <atom:updated>2023-04-04T04:55:49.670Z</atom:updated>
            <content:encoded><![CDATA[<h3>Embedded System #9 — Insert ESP32 Data Into MySQL</h3><p>Hi, it’s me again, Syafiq Ziyadul Arifin, also known as Safiq. In this nineth project (you can get the list <a href="https://medium.com/@syafiqza/list/ii2260-embedded-system-d14058244e53">here</a>), I am excited to show you how to insert your BMP280 sensor readings from your ESP32 into a MySQL database. So, let’s dive in!</p><h3>Components Used:</h3><ul><li>ESP32 Devkit V1</li><li>Smartphone or PC</li><li>Data cable (USB type A to Micro B)</li><li>BMP280</li><li>Jumper cables (male to female)</li><li>Breadboard</li></ul><h3>Prerequisite</h3><p>Before you go any further, there is a prerequisite for this project, which is a database. You can create your own database locally or publicly if you want, but here I will tell you how to use the database that I have previously published (read the story <a href="https://medium.com/@syafiqza/working-with-aws-rest-api-d6e41d66195a">here</a>).*</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_76LlNzMQUGVZqYlK-5Ig.png" /></figure><h3>Circuit</h3><p>I’m going to be using the same circuit that I used for <a href="https://medium.com/@syafiqza/embedded-system-7-bluetooth-connections-in-esp32-b190ff39cec3">project #7</a> (but without the LED), so if you don’t mind, please take a look at it.</p><h3>Code</h3><p>Here is the program I made.</p><pre>#include &lt;WiFi.h&gt;<br>#include &lt;WiFiClientSecure.h&gt;<br>#include &lt;HTTPClient.h&gt;<br>#include &lt;Adafruit_Sensor.h&gt;<br>#include &lt;Adafruit_BMP280.h&gt;<br><br>// constants won&#39;t change. They&#39;re used here to set pin numbers, etc.<br>// replace with your network credentials<br>const char* ssid = &quot;Safiq&quot;;<br>const char* password = &quot;Medium@syafiqza&quot;;<br>// replace with your domain name and URL path or IP address with path<br>const char* serverName = &quot;https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280&quot;;<br><br>// define the BMP sensor and web server<br>Adafruit_BMP280 bmp;<br><br>void setup() {<br>  Serial.begin(115200);<br>  bmp.begin(0x76);  // [0x76, 0x77]<br>  // connect to Wi-Fi network with SSID and password<br>  Serial.print(&quot;Connecting to &quot;);<br>  Serial.println(ssid);<br>  WiFi.begin(ssid, password);<br>  while (WiFi.status() != WL_CONNECTED) {<br>    delay(500);<br>    Serial.print(&quot;.&quot;);<br>  }<br>  // print private IP address and start web server<br>  Serial.println(&quot;&quot;);<br>  Serial.println(&quot;WiFi connected.&quot;);<br>  Serial.println(&quot;IP address: &quot;);<br>  Serial.println(WiFi.localIP());<br>}<br><br>void loop() {<br>  // check WiFi connection status<br>  if (WiFi.status() == WL_CONNECTED) {<br>    WiFiClientSecure* client = new WiFiClientSecure;<br>    client-&gt;setInsecure();  // don&#39;t use SSL certificate<br>    HTTPClient https;<br><br>    https.begin(*client, serverName);<br><br>    // specify content-type header<br>    https.addHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);<br>    int httpResponseCode = https.POST(&quot;{\&quot;temperature\&quot;:&quot; + String(bmp.readTemperature()) + &quot;,\&quot;pressure\&quot;:&quot; + String(bmp.readPressure()) + &quot;,\&quot;altitude\&quot;:&quot; + String(bmp.readAltitude()) + &quot;}&quot;);<br><br>    if (httpResponseCode &gt; 0) {<br>      Serial.print(&quot;HTTP response code: &quot;);<br>      Serial.println(httpResponseCode);<br>    } else {<br>      Serial.print(&quot;Error code: &quot;);<br>      Serial.println(httpResponseCode);<br>    }<br>    // free resources<br>    https.end();<br>  } else {<br>    Serial.println(&quot;WiFi disconnected&quot;);<br>  }<br>  // send an HTTP POST request every minute<br>  delay(60000);<br>}</pre><p>Let’s break down the code.</p><p>The program first initializes the BMP280 sensor and Wi-Fi connection in the setup() function. The serial communication is also set up to monitor the program’s output. The loop() function checks if the Wi-Fi connection is active and creates a secure connection to the web server using HTTPS.</p><p>After setting the Content-Type header, the program creates a JSON string to hold the temperature, pressure, and altitude readings from the BMP280 sensor. An HTTP POST request is sent to the server with this data, and the server responds with an HTTP response code that is printed to the serial monitor.</p><p>If the Wi-Fi connection is lost, the program prints “WiFi disconnected” to the serial monitor. The program waits for 1 minute using the delay() function before executing the loop() function again. This ensures that the program runs every minute and uploads weather data to the web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nJ1TXb6q08ngqDLYSNd7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*Tvgp5g6dItHzSCKVGoHQig.png" /><figcaption>New data has been added and can be viewed at <a href="https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280">https://chznne1yi9.execute-api.ap-southeast-2.amazonaws.com/prod/bmp280</a></figcaption></figure><p>Congratulations! You have successfully finished your nineth project using the ESP32 and the Arduino IDE. Now, you can transfer data between your ESP32 microcontroller board and a database. If you have any questions, feel free to reach out to me. Happy tinkering!</p><p>(*) Trivia:</p><ul><li>I have created the API contract for the REST API, which can be accessed through this <a href="https://docs.google.com/spreadsheets/d/1Jb61wJCyHwLRaOMhy7GSg1Fglr7xAS5_gBTJywTOMkU/edit?usp=sharing">link</a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b12ed1543195" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>