<?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 Protonest IoT on Medium]]></title>
        <description><![CDATA[Stories by Protonest IoT on Medium]]></description>
        <link>https://medium.com/@protonestiot?source=rss-f3bc7e6b1fdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1lmgt4gj3tvjlVFFBIsR2Q.png</url>
            <title>Stories by Protonest IoT on Medium</title>
            <link>https://medium.com/@protonestiot?source=rss-f3bc7e6b1fdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 14:26:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@protonestiot/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[Select the Right Quectel Module for Your Application]]></title>
            <link>https://protonestiot.medium.com/select-the-right-quectel-module-for-your-application-0fae90a7a195?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fae90a7a195</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[quectel]]></category>
            <category><![CDATA[nb-iot]]></category>
            <category><![CDATA[gsm]]></category>
            <category><![CDATA[4g]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 04:15:46 GMT</pubDate>
            <atom:updated>2025-09-22T04:17:17.716Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XcJlcD9gjDqg4rNowYv_cw.jpeg" /></figure><p>At Protonest, we design and develop IoT devices every day, and we know how tricky selecting the right cellular module can feel. That’s why we put together this article: to help you cut through the noise and confidently pick the module that fits your use case, without over or under-engineering.</p><h3><strong>What is Quectel &amp; Why the Module Matters</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2-od39ur3ThbTR-jWDm5og.png" /></figure><p>Quectel makes cellular/GNSS modules (2G, 4G, LTE-M, NB-IoT, etc.) that let devices send data, get location, or stream. The right module depends on:</p><ul><li>Data volume — How much data will your device send?</li><li>Frequency — Will it transmit continuously, periodically, or only on rare events?</li><li>Location needs — Do you require GPS/GNSS, or just data connectivity?</li><li>Design trade-offs — How critical are cost, size, power consumption, and latency for your use case?</li></ul><h3>Key Technologies Compared</h3><p>Different applications don’t need the same type of network. A smart meter that sends a few numbers once a day can work well on <strong>NB-IoT</strong>, while a video camera that streams continuously needs <strong>high-speed LTE</strong>. Technologies like <strong>2G, NB-IoT, LTE Cat M1, Cat 1, and Cat 4</strong> each offer different balances between <strong>speed, power use, coverage, and cost</strong>. The table below shows how they compare so you can quickly match your application needs with the right option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*Yx7HxWq4I2ArViK0GstVTg.png" /></figure><h3>Important Parameters to Think About</h3><p>When choosing a module, it’s not just about the network type, it’s about how well it fits your device’s real-world needs. You’ll want to balance things like data rate, power consumption, size, cost, and coverage so your product works reliably without wasting energy or budget. The points below highlight the most critical factors to keep in mind before making your selection.</p><ol><li><strong>Data rate / bandwidth</strong>—is streaming or large file transfer required, or just small messages?</li><li><strong>Power modes</strong>—can it sleep, have eDRX, PSM, or deep sleep? Idle power is critical if battery-powered.</li><li><strong>Coverage &amp; Bands</strong>—ensure module supports the RF bands &amp; regions you deploy in.</li><li><strong>Size &amp; footprint</strong>—module dimension, mounting style (LGA, LCC, M.2, etc.).</li><li><strong>Cost (module + data plan + deployment)</strong>—module price, cost of the network usage, and maintenance.</li><li><strong>Latency and reliability</strong>—for streaming or near real-time, you need lower latency, strong signal.</li><li><strong>Additional features</strong> — GPS/GNSS support, fallback to other networks, voice support, security, and firmware over the air (FOTA).</li></ol><h3>Power and Coverage in Action</h3><h4><strong>Power Consumption Modes</strong></h4><p>Quectel modules don’t use the same energy all the time. Their consumption depends on the state they are in.</p><ul><li>During <strong>startup and network connection</strong>, current spikes.</li><li>In <strong>active mode</strong>, power draw is at its highest because the module is sending or receiving data.</li><li>In <strong>sleep or idle</strong>, power drops, but the module is still ready.</li><li>In <strong>PSM (Power Saving Mode)</strong>, current falls to very low levels, making it ideal for battery-powered IoT devices.</li><li>When the module <strong>wakes up from PSM</strong>, it briefly uses more power again.</li></ul><p>This shows why using sleep and PSM modes is critical for extending device battery life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4CfpjHQ-W8If78bV0EUWfA.png" /></figure><h4><strong>Coverage and Energy Use</strong></h4><p>Signal strength (RSSI) also plays a huge role in energy consumption. Poor coverage means the module needs to retry sending data, which costs more energy.</p><ul><li>In <strong>bad coverage</strong>, energy use can be up to 4× higher.</li><li>In <strong>medium coverage</strong>, energy demand drops significantly.</li><li>In <strong>good coverage</strong>, modules use the least energy for the same task.</li><li>This means even if you choose the right module, deploying it in a weak-signal area can shorten battery life dramatically.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Z8s38tUvMbshfC3IdCL0Zg.png" /></figure><h3><strong>Quectel Module Examples &amp; Trade-offs</strong></h3><p>Let’s look at some real Quectel modules and see where each one works best. Every module has strengths but also some trade-offs.</p><h4>BC95-G / BC950K-GL (NB-IoT)</h4><p>This module is built for very small and infrequent data transfers. It uses very little power, especially in Power Saving Mode, making it perfect for battery devices like sensors. The trade-off is that it only supports low speeds and has higher latency, so it is not good for streaming or frequent updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*1-K06B7AVxO9a2W-iSae3A.png" /></figure><p><a href="https://drive.google.com/file/d/1Mc_wed4GQjAIpjDnfp5RA2ope2UeZQoO/view?usp=sharing">BC950K-GL Datasheet</a></p><p><a href="https://drive.google.com/file/d/1lvHtjYy8_7M1PDYcIo0zH6ZuF3UWZujY/view?usp=sharing">BC95-G Datasheet</a></p><h4><strong>BG95 Series (Cat M1 / NB2 / EGPRS with GPS)</strong></h4><p>The BG95 strikes a balance between performance and power. It supports GPS/GNSS, works in many regions, and offers higher data rates than pure NB-IoT. This makes it ideal for trackers and wearables. The downside is that it costs more than NB-IoT modules and still can’t handle heavy video or very fast data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*fkcjCVbPX8sm7bKFAvE62Q.png" /></figure><p><a href="https://drive.google.com/file/d/1mIuisR5bLaU8YN-Lk-vP4TRIPE5Q-C5x/view?usp=sharing">BG95 Series Datasheet</a></p><h4><strong>BG96 (Cat M1 / NB1 / EGPRS)</strong></h4><p>An earlier but still popular option, the BG96 offers moderate data speeds and reliable network fallback. It is well-tested and stable, but slower compared to newer modules like the BG95.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*gybADvxNk6zurBm6U3HL_w.png" /></figure><p><a href="https://drive.google.com/file/d/1abZJdDiaDdMyJRveFTCsJkphfsOjGxNC/view?usp=sharing">BG96 Datasheet</a></p><h4><strong>EC200U / EC21 (Cat 1)</strong></h4><p>These Cat 1 modules support voice calls (VoLTE) and higher data rates, making them useful for devices that need both voice and data. They are good for smart trackers or devices with richer functions. The drawback is higher power use and cost compared to Cat M1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfuCoapWTSPafBMPXaNDBQ.png" /></figure><p><a href="https://drive.google.com/file/d/1daVUx3rRnOpRKYWQOodXlXli3csbf_vN/view?usp=sharing">EC200U Datasheet</a></p><h4><strong>EC25 / EG25-G (Cat 4)</strong></h4><p>When you need fast data or video streaming, Cat 4 modules like the EC25 are the right choice. They can reach very high data speeds, suitable for cameras or routers. But this comes at the cost of high power draw and a higher price, so they are not practical for battery-powered devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Rw7c4kfethQviZsfqD9RA.png" /></figure><p><a href="https://drive.google.com/file/d/1m0Ujg1xvKEK6vCysE7AaUOcscYy08wxp/view?usp=sharing">EC25 Series Datasheet</a></p><p><a href="https://drive.google.com/file/d/1yxtCkAoGpjnqx269moaCoUSyPBa91qXy/view?usp=sharing">EG25-G Datasheet</a></p><h4><strong>EG916 (Cat 1)</strong></h4><p>The EG916 is a cost-effective LTE Cat 1 module designed for IoT applications that need stable performance but not very high speed. It supports data rates good enough for voice, messaging, and medium-sized data transfers. It also has wide coverage and long-term availability, making it a solid choice for smart meters, POS terminals, and trackers. The trade-off is that it offers lower speeds than Cat 4 and uses more power than NB-IoT or Cat M1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*MP4dPyPZpaG5TFcnUDW-5A.png" /></figure><p><a href="https://drive.google.com/file/d/1MHGjCq3UjOyIjKb6KHK_B4FuCibTyv8v/view?usp=sharing">EG916 Datasheet</a></p><h4><strong>EG800 (LTE Cat 1 bis)</strong></h4><p>The EG800 is based on Cat 1 bis, which uses a single antenna to cut cost and size. It is very compact and power-efficient, making it ideal for small IoT devices like trackers, wearables, and smart sensors. It provides enough bandwidth for messaging, location data, and even light multimedia. The limitation is that it cannot reach the speeds of regular Cat 1 or Cat 4 modules, so it is not suitable for heavy streaming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*UB_pAlUbKLbTxagE1-fhRw.png" /></figure><p><a href="https://drive.google.com/file/d/1dZSsTw6CIHI9-8gPfdah9qvIwSWC3dVV/view?usp=sharing">EG800 Datasheet</a></p><h3>Scenario Walk-throughs</h3><p>Choosing the right module becomes much easier when you look at your application first. Different devices need different balances of speed, cost, and power. The table below matches <strong>common IoT applications</strong> with the most suitable Quectel modules, along with their data rates and cost levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*KBHoICQ2p8aA80kaObsO3Q.png" /></figure><h3><strong>Design Tips and Optimization</strong></h3><p>Even after choosing the right Quectel module, the way you design your device will decide how well it performs in real life. The same module can last years on a battery in one product but only weeks in another. Here are some simple tips to get the best results:</p><p><strong>Use Power Saving Features</strong></p><p>Quectel modules support modes like PSM (Power Saving Mode) and eDRX (extended sleep). These allow the device to sleep most of the time and only wake up to send data, cutting power use by up to 90%.</p><p><strong>Send Data in Batches</strong></p><p>Instead of sending tiny packets often, combine data and send it less frequently. For example, a tracker can upload a position every 30 minutes instead of every 2 minutes. Fewer network handshakes = less power.</p><p><strong>Choose the Right Antenna</strong></p><p>A weak antenna makes the module consume more energy as it retries transmissions. Always use an antenna designed for the correct frequency bands of your module.</p><p><strong>Consider Network Fallback</strong></p><p>If your device will be used in rural or indoor areas, pick modules with multi-mode support (Cat M1 + NB-IoT + 2G). This ensures the device stays connected even if one network is weak.</p><p><strong>Enable FOTA (Firmware Over the Air)</strong></p><p>Many Quectel modules support remote firmware updates. This helps fix bugs, improve performance, and avoid costly recalls.</p><h3><strong>Conclusion</strong></h3><p>Selecting the right Quectel module is all about matching the technology to your application.</p><ul><li><strong>NB-IoT</strong> works best for small, low-power sensors that send little data.</li><li><strong>Cat M1 / Cat 1</strong> are great choices for trackers, POS systems, and devices that need both data and voice.</li><li><strong>Cat 1 bis</strong> offers a compact, cost-effective option for simple IoT without GPS.</li><li><strong>Cat 4</strong> is the right choice for video streaming and high-speed data, but it comes with a higher cost and power use.</li><li><strong>2G and multi-mode modules</strong> still play a role in legacy and coverage-critical applications.</li></ul><p>By also considering design factors like power saving, antenna quality, fallback, and real-world testing, developers can make sure their devices are <strong>reliable, efficient, and cost-effective</strong>.</p><h3><strong>References</strong></h3><ol><li>Quectel Wireless Solutions — Product Datasheets: <a href="https://drive.google.com/drive/folders/1lecWdgcPfM2aL7KoR6yNhX5Srul8L5GO?usp=sharing">https://drive.google.com/drive/folders/1lecWdgcPfM2aL7KoR6yNhX5Srul8L5GO?usp=sharing</a></li><li>QuecPython Power Consumption Guide — <a href="https://python.quectel.com/doc/quecpython/Application_guide/en/system/power-consumption.html">https://python.quectel.com/doc/quecpython/Application_guide/en/system/power-consumption.html</a></li><li>ResearchGate — “Quectel BC95-G average energy consumption in different coverage levels” — <a href="https://www.researchgate.net/figure/Quectel-BC95-G-average-energy-consumption-in-different-coverage-levels_fig2_350468787">https://www.researchgate.net/figure/Quectel-BC95-G-average-energy-consumption-in-different-coverage-levels_fig2_350468787</a></li></ol><p>💡 <strong>Need help choosing or implementing systems with Quectel?</strong><br> Whether it’s <strong>NB-IoT, Cat M1, Cat 1, Cat 1 bis, Cat 4, or 2G</strong>, our team can support you in designing and implementing the system for your IoT application.<br> 👉 <a href="https://www.protonest.co/contact-us">https://www.protonest.co/contact-us</a></p><p>Written by: Pasindu Deemantha</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fae90a7a195" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPS with Quectel EG916Q-GL and ESP32]]></title>
            <link>https://protonestiot.medium.com/gps-with-quectel-eg916q-gl-and-esp32-f3a2110c4b3d?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3a2110c4b3d</guid>
            <category><![CDATA[quectel]]></category>
            <category><![CDATA[gps-tracking]]></category>
            <category><![CDATA[gps]]></category>
            <category><![CDATA[esp32-tutorial]]></category>
            <category><![CDATA[pcb-design]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 04:56:14 GMT</pubDate>
            <atom:updated>2025-08-30T04:58:54.987Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KnpTbTTOrObfaNfT-vdHqg.jpeg" /></figure><p>In this article, we’re going to zoom in on the GPS part of Quectel EG916Q-GL, continuing the previous story.</p><p>We’ll walk you through how we,</p><ul><li>Connected an ESP32 to the EG916Q-GL</li><li>Sent AT commands to fetch GNSS coordinates</li><li>Verified real-time location data for applications like vehicle tracking, environmental monitoring, and asset management</li></ul><p>So if you’ve been looking for a simple way to get GPS data into your IoT project, this guide will help you get started quickly</p><h4>Introduction</h4><p>The Quectel EG916Q is a versatile module that provides GNSS (GPS, GLONASS, BeiDou) as well as GSM. By connecting this module to a MCU, we can,</p><ul><li>Request GPS coordinates and satellite information with AT commands.</li><li>Integrate location data into IoT systems.</li></ul><p>This project demonstrates a simple, reliable way to test GPS functionality before integrating it into larger applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*cbMWsRr5ueWQNffzRAc8Gg.png" /></figure><h4>Used Hardware Component List</h4><ul><li>Quectel EG916Q-GL LTE Cat 1 bis module</li><li>ESP32-WROOM-32</li><li>3.7 V Li-ion / LiPo battery</li><li>Step-up converter (To power up the Modem with 3.8V)</li><li>Logic Shifter(3.3: 1.8V)</li><li>TPD3F303DPVR (ESD protection IC near the SIM card holder)</li><li>U.FL to SMA adapter (if using SMA antenna)</li><li>ESD protection diodes (for SIM and RF lines)</li><li>ASM1117 regulator(For powering ESP32 with 3.3V from 5V)</li><li>GPS External antenna connected to the EG916Q-GL for better satellite signal reception.</li></ul><h4>Hardware Setup</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*QC5p6rvW98vn7USmylpaPQ.png" /><figcaption>Design Architecture Idea</figcaption></figure><p>Schematic Design : <a href="https://drive.google.com/file/d/1-ubtnCbc6-Go5NS01lN3gN3DTDLhVEsN/view?usp=sharing"><strong><em>Link</em></strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPJIxJx-jifxb2NI4QMMzA.png" /></figure><p>Follow these steps to prepare your PCB,</p><ol><li>Insert the <strong>3V coin cell</strong> to power the GPS circuitry.</li><li>Connect the <strong>3.7V battery</strong> to the PCB to power the ESP32 and the module.</li></ol><h4>Software Setup</h4><p>GPS_Test_Arduino code: <a href="https://drive.google.com/file/d/1dyjUixcueDlMO1oLYcmr3K9ZvjJFBZTP/view?usp=sharing"><strong><em>Link</em></strong></a></p><pre>#define PWR_LATCH_PIN    23<br>#define PWRKEY_PIN        4<br>#define DTR_PIN          15<br>#define RX2_PIN          16<br>#define TX2_PIN          17<br>#define MODULE_RESET_PIN  5<br><br>HardwareSerial modem(2);<br><br>void setup() {<br>  Serial.begin(115200);<br>  while (!Serial);  // wait for Serial USB<br><br>  //Open the “AT” UART to the module<br>  modem.begin(115200, SERIAL_8N1, RX2_PIN, TX2_PIN);<br><br>  // 1) Turn on rails<br>  pinMode(PWR_LATCH_PIN, OUTPUT);<br>  digitalWrite(PWR_LATCH_PIN, HIGH);<br>  delay(10);<br><br>  // 2) Release module RESET_N (internal pull‑high)<br>  pinMode(MODULE_RESET_PIN, OUTPUT);<br>  digitalWrite(MODULE_RESET_PIN, LOW);<br><br>  // 3) PWRKEY pulse to turn module on<br>  pinMode(PWRKEY_PIN, OUTPUT);<br>  digitalWrite(PWRKEY_PIN, LOW);<br>  delay(30);<br>  digitalWrite(PWRKEY_PIN, HIGH);<br>  delay(550);<br>  digitalWrite(PWRKEY_PIN, LOW);<br><br>  // 4) Give it time to boot<br>  Serial.println(&quot;Waiting for module to boot…&quot;);<br>  delay(12000);<br><br>  // 5) Hold DTR high so module doesn’t fall asleep<br>  pinMode(DTR_PIN, OUTPUT);<br>  digitalWrite(DTR_PIN, HIGH);<br><br>}<br><br>void loop() {<br>  // a) module → Serial<br>  if (modem.available()) {<br>    Serial.write(modem.read());<br>  }<br><br>  // b) Serial → module<br>  if (Serial.available()) {<br>    modem.write(Serial.read());<br>  }<br><br>  delay(10);  // avoid 100% CPU<br>}</pre><ol><li>Open <strong>Arduino IDE</strong> and select your ESP32 board and correct COM port.</li><li>Upload the <strong>GPS_Test_Arduino</strong> code to the ESP32.</li><li>Open the <strong>Serial Monitor</strong> at <strong>115200 baud</strong> to interact with the EG916Q module.</li></ol><p>The code sets up UART communication between the ESP32 and the module and allows you to send AT commands to control GPS functionality.</p><h4>Using AT Commands for GPS</h4><p>Once the module is powered and the code is running, you can use the following AT commands to control the GNSS features:</p><h4>1. Turn On the GPS</h4><pre>AT+QGPS=1</pre><ul><li>This command activates the GPS engine inside the EG916Q module.</li><li>Wait <strong>8 seconds</strong> for the module to connect to satellites. This may vary. If you are initially indoors, it will take around 4–5 minutes.</li><li>The module begins tracking satellites and generating NMEA sentences.</li></ul><h4>2. Request GPS Location</h4><pre>AT+QGPSLOC=0</pre><ul><li>This command requests the current GPS location.</li><li>The module returns a string with information such as:<br><strong>Latitude and Longitude<br>Altitude<br>UTC Time<br>Fix status and number of satellites</strong></li></ul><p>You can parse this data in your code or send it to a server for real-time tracking.</p><h4>3. Stop GPS to Save Power</h4><pre>AT+QGPSEND</pre><ul><li>Deactivates the GPS engine.</li><li>Reduces power consumption, especially useful for battery-powered IoT devices.</li></ul><h4>Example Output</h4><p>After sending AT+QGPSLOC=0, you might receive a response like:</p><pre>+QGPSLOC: 37.421998,-122.084000,1.2,2025/08/17,10:45:30,1,12</pre><p>Where:</p><ul><li>37.421998 → Latitude</li><li>-122.084000 → Longitude</li><li>1.2 → Altitude in meters</li><li>2025/08/17 → Date</li><li>10:45:30 → UTC Time</li><li>1 → Fix status (1 = valid)</li><li>12 → Number of satellites in view</li></ul><h4>Applications</h4><p>This setup is ideal for a variety of IoT and embedded applications:</p><ul><li><strong>Vehicle and Fleet Tracking:</strong> Monitor location in real-time.</li><li><strong>Asset Management:</strong> Keep track of devices, containers, or equipment.</li><li><strong>Smart Agriculture:</strong> Track machinery or monitor field conditions with location data.</li></ul><h4>Hardware Constraints</h4><ul><li>ESP32’s 3.3V regulator <strong>cannot supply enough current</strong> for the modem. So we need an external power source.</li><li>EG916Q-GL uses <strong>1.8V logic</strong> (UART): Must use <strong>level shifters</strong> to avoid damage</li><li>GPS and LTE antennas must be <strong>carefully matched</strong> (impedance 50Ω).</li></ul><h4>Firmware Constraints</h4><ul><li>Retries if there are any GNSS failures, AT Failures</li><li>GPS may take <strong>30–60s cold start</strong> in poor conditions.</li></ul><h4>Environmental Challenges</h4><ul><li><strong>Indoor GPS fix</strong> is difficult (Suits open sky).</li><li><strong>Antenna orientation</strong> affects accuracy and signal strength.</li></ul><h4>Further use of GPS data</h4><p>Once the basic GNSS setup is functional, you can enhance the project,</p><ul><li><strong>Log GPS data</strong> to SD cards or cloud servers(HTTPs/MQTT).</li><li><strong>Geofencing and alerts</strong> when devices enter or leave defined areas.</li></ul><h4>Conclusion</h4><p>Getting GNSS readings with the Quectel EG916Q module and an MCU is straightforward, yet powerful if handled well. Using AT commands, you can control the GPS engine, read location data, and integrate it into your IoT projects.</p><p>This project provides a strong foundation for building location-aware devices, from simple GPS trackers to complex IoT systems. By experimenting with satellite data, power management, and real-time logging, you can unlock the full potential of GNSS-enabled IoT applications.</p><h4>References</h4><p><strong>Quectel Developer Community</strong> — <a href="https://forums.quectel.com/">https://forums.quectel.com</a></p><p><strong>Refer to the related documents</strong>: <a href="https://drive.google.com/drive/folders/1MDbQLB7siDjw97u1nsaw8Oc8Iy8Q6U7P?usp=sharing">https://drive.google.com/drive/folders/1MDbQLB7siDjw97u1nsaw8Oc8Iy8Q6U7P?usp=sharing</a></p><p>If you need any assistance with implementing Quectel EG916Q-GLLG-N03-SGNSA, contact us at <a href="https://www.protonest.co/contact-us">https://www.protonest.co/contact-us</a></p><p>PCB Design by: Milinda Ruberu and Yashodha Salgadu</p><p>Firmware by: Bharkka Sharma</p><p>Written by: Tenura Pinsara</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3a2110c4b3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running an API with JWT on Quectel EG916Q-GL]]></title>
            <link>https://protonestiot.medium.com/running-an-api-with-jwt-on-quectel-eg916q-gl-33179277c62a?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/33179277c62a</guid>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[quectel]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[low-power-design]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Mon, 18 Aug 2025 14:26:25 GMT</pubDate>
            <atom:updated>2025-08-21T03:51:40.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejVrNBsrRmcv3UbIXvJbiA.jpeg" /></figure><p>Protonest was seeking a modem that could support both GSM and GPS with low power consumption. And we came across Quectel EG916Q-GLLG-N03-SGNSA, which does the task easily, thanks to the recommendation from our PCB consultant, Yashodha Salgadu.</p><p>Quectel is a global leader in IoT modules, providing compact yet powerful electronic solutions. Their modules enable seamless connectivity to the internet, mobile networks, GPS, and more, serving as the communication backbone of modern smart devices.</p><p>Here are some types they provide,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*9qEWKyUdTYolwmJIc2Mpcw.png" /></figure><p>More about Quectel: <a href="https://www.quectel.com/">https://www.quectel.com/</a></p><p><strong>We made a low-power and reliable solution for running an API with JWT with Quectel EG916Q-GL.</strong></p><p>Shayee Tan from Shenzhen Hapchang Technology Co., Ltd helped us get the Quectel EG916Q-GLLG-N03-SGNSA at a decent price. And the assembling was done in-house.</p><p>Note: The backend API endpoints given here are only examples. You need to use your own backend APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*JOUMVeXJmRlqe9av4gVQhQ.png" /></figure><h4>Why EG916Q-GL?</h4><ol><li>Can efficiently run lightweight API &amp; JWT workflows</li><li>Longer battery life and more efficient energy use</li><li>Proven Reliability across Harsh Conditions</li></ol><p>EG916Q-GL-based solution is ideal for,</p><ul><li>Secure asset tracking with cloud connectivity</li><li>Remote sensor telemetry (agriculture, water metering)</li><li>Smart city devices that need reliable communication with low maintenance</li><li>Industrial automation, where security and low power are critical</li></ul><h4><strong>Used Hardware Component List</strong></h4><ul><li>Quectel EG916Q-GL LTE Cat 1 bis module</li><li>ESP32-WROOM-32</li><li>3.7 V Li-ion / LiPo battery</li><li>TP4056 battery charging module</li><li>Step-up converter (To power up the Modem with 3.8V)</li><li>Logic Shifter(3.3: 1.8V)</li><li>SIM card (with active LTE data plan)</li><li>TPD3F303DPVR (ESD protection IC near the SIM card holder)</li><li>U.FL to SMA adapter (if using SMA antenna)</li><li>ESD protection diodes (for SIM and RF lines)</li><li>ASM1117 regulator(For powering ESP32 with 3.3V from 5V)</li></ul><p><strong>Here is how you need to connect the QUECTEL</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BMuV73StoM0tQKcXZ9QNQ.png" /><figcaption>High Level Design</figcaption></figure><p>Basic idea of Schematic Design between ESP32 and LTE_MODULE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYXYSGRFzTGYqeRD5_42GA.png" /><figcaption>ESP32 and POWER Circuit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*u1DfRlrnkEzuGgDM51oY1w.png" /><figcaption>LTE Module</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*mO_j3pMuRhpdtdvjePZ-TQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9oCbMK8hytMwdGS9ZvfwA.png" /><figcaption>SIM Connector Circuit</figcaption></figure><p>AT Cmd for QUECTEL module with JWT token config</p><p><strong>1. Module Initialization</strong></p><pre>AT+CFUN=1,1</pre><ul><li><strong>Purpose</strong>: Full module reset (use only if needed to clear previous state)</li><li><strong>Response</strong>: OK indicates successful reset</li></ul><pre>AT+CPIN?</pre><ul><li><strong>Purpose</strong>: Check if SIM card is ready</li><li><strong>Expected Response</strong>: +CPIN: READY (if SIM is unlocked)</li></ul><pre>AT+CGDCONT=1,&quot;IP&quot;,&quot;dialog4G&quot;</pre><ul><li><strong>Purpose</strong>: Define PDP Context 1 with:</li><li>IP type (“IP”)</li><li>APN name (“dialog4G” — replace with your carrier’s APN)</li><li><strong>Response</strong>: OK</li></ul><pre>AT+CGATT=1</pre><ul><li><strong>Purpose</strong>: Attach to Packet-Switched (PS) domain for data</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QIACT=1</pre><ul><li><strong>Purpose</strong>: Activate PDP Context 1 to get an IP address</li><li><strong>Response</strong>: OK (verify IP with AT+QIACT?)</li></ul><p><strong>2. HTTP/SSL Configuration</strong></p><pre>AT+QHTTPCFG=&quot;contextid&quot;,1</pre><ul><li><strong>Purpose</strong>: Bind HTTP service to PDP Context 1</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QHTTPCFG=&quot;sslctxid&quot;,1</pre><ul><li><strong>Purpose</strong>: Use SSL Context 1 for HTTPS</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QSSLCFG=&quot;sslversion&quot;,1,3</pre><ul><li><strong>Purpose</strong>: Enforce TLS 1.2 (value 3) for security</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QSSLCFG=&quot;seclevel&quot;,1,0</pre><ul><li><strong>Purpose</strong>: Set server authentication only (no client cert)</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QSSLCFG=&quot;sni&quot;,1,1</pre><ul><li><strong>Purpose</strong>: Enable Server Name Indication (SNI) for HTTPS</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QHTTPCFG=&quot;contenttype&quot;,4</pre><ul><li><strong>Purpose</strong>: Set default Content-Type: application/json</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QHTTPCFG=&quot;requestheader&quot;,0</pre><ul><li><strong>Purpose</strong>: Disable custom headers</li><li><strong>Response</strong>: OK</li></ul><p><strong>3. Login (POST Request)</strong></p><pre>AT+QHTTPURL=98,60</pre><ul><li><strong>Purpose</strong>: Prepare to send URL (98 chars for my host address, 60s timeout)</li><li><strong>Response</strong>: CONNECT (ready for URL input)</li></ul><pre>[&lt;https://api&gt;] // It should be according to the URL of your host</pre><ul><li><strong>Action</strong>: Paste the exact URL (98 characters for me)</li><li><strong>Response</strong>: OK after URL is accepted</li></ul><pre>AT+QHTTPPOST=52,60,60</pre><ul><li><strong>Purpose</strong>: Send POST request:</li><li>52: JSON body length (bytes)</li><li>60,60: Timeouts (seconds)</li><li><strong>Response</strong>: CONNECT (ready for JSON input)</li></ul><pre>{&quot;phoneNumber&quot;:&quot;0771231230&quot;,&quot;password&quot;:&quot;Aa!11111&quot;}. <br>// It&#39;s just an example of the json body</pre><ul><li><strong>Action</strong>: Send the exact JSON body (52 bytes)</li><li><strong>Response</strong>: OK + +QHTTPPOST: 0,200 (success)</li></ul><p><strong>4. Read Login Response</strong></p><pre>AT+QHTTPREAD=60</pre><ul><li><strong>Purpose</strong>: Read server response (60s timeout)</li><li><strong>Response</strong>:json{“status”:”success”, “data”:{ “jwtToken”:”eyJhbGci…”, “refreshToken”:”eyJhbGci…” }}</li><li><strong>Note</strong>: Copy the jwtToken for authenticated requests.</li></ul><p><strong>5. Configure GET Request Headers</strong></p><p>Note: Before running the Get request, fetch the JWT</p><pre>AT+QHTTPCFG=&quot;custom_header&quot;,&quot;Authorization:&lt;JWT_TOKEN&gt;&quot;</pre><ul><li><strong>Purpose</strong>: Set JWT in the Authorization header</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QHTTPCFG=&quot;custom_header&quot;,&quot;Host: &lt;Host_link&gt;&quot;</pre><ul><li><strong>Purpose</strong>: Manually set Host header (required for HTTP/1.1)</li><li><strong>Response</strong>: OK</li></ul><p><strong>6. Fetch User Data (GET Request)</strong></p><pre>AT+QHTTPURL=112,60</pre><ul><li><strong>Purpose</strong>: Prepare GET URL (112 chars, 60s timeout)</li><li><strong>Response</strong>: CONNECT</li></ul><p>CONNECT</p><pre>[&lt;https://api&gt;]........ <br>//The URL related to the Get request</pre><p>OK</p><ul><li><strong>Action</strong>: Paste the exact URL</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QHTTPGET=60</pre><ul><li><strong>Purpose</strong>: Send GET request (60s timeout)</li><li><strong>Response</strong>: OK + +QHTTPGET: 0,200 (success)</li></ul><p><strong>7. Read GET Response</strong></p><pre>AT+QHTTPREAD=60</pre><ul><li><strong>Response</strong>:json{“status”:”success”,”data”:{…….data you ste…….}}</li></ul><p><strong>8. Cleanup</strong></p><pre>AT+QHTTPSTOP</pre><ul><li><strong>Purpose</strong>: Terminate HTTP session</li><li><strong>Response</strong>: OK</li></ul><pre>AT+QIDEACT=1</pre><ul><li><strong>Purpose</strong>: Deactivate PDP Context 1 (optional)</li><li><strong>Response</strong>: OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*A8VXDskD5PLXpER9LnYodg.png" /><figcaption>AT command flow</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bc1bm3OmCTzmZ6fibb0x-Q.png" /><figcaption>Typical times for some commands</figcaption></figure><p>We are providing you with a <strong>mock version</strong> of LTE + JWT code, so you can compile and run it on your PCB.</p><p>It will,</p><ul><li>Connect LTE.</li><li>Make HTTP requests.</li><li>Simulate the server returning a JWT token.</li><li>Simulate sending data with the token</li></ul><pre>#include &lt;stdio.h&gt;<br>#include &lt;stdbool.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;time.h&gt;<br>#include &quot;cJSON.h&quot;   // Download from: https://github.com/DaveGamble/cJSON<br><br>#define DEVICE_NAME     &quot;MyDevice&quot; // Add your own<br>#define PASSWORD        &quot;secret&quot; // Add your own<br>#define BASE_URL        &quot;https://my-backend.com&quot; // Add your own<br>#define JWT_TOKEN_MAX   512<br><br>static char jwt_token[JWT_TOKEN_MAX] = &quot;&quot;;<br><br>/* ============================<br>   TIME MEASUREMENT HELPER<br>============================ */<br>static double elapsed_ms(clock_t start, clock_t end) {<br>    return ((double)(end - start) / CLOCKS_PER_SEC) * 1000.0;<br>}<br><br>/* ============================<br>   MOCK LTE + HTTP HANDLERS<br>============================ */<br>bool lte_setup(void) {<br>    printf(&quot;[MOCK LTE] Simulating LTE connection success.\n&quot;);<br>    return true;<br>}<br><br>bool make_http_request(const char *url, const char *method,<br>                       char *response, size_t response_size,<br>                       const char *body, const char *jwt_token) {<br>    printf(&quot;\n[MOCK HTTP] %s %s\n&quot;, method, url);<br>    printf(&quot;[MOCK HTTP] Body: %s\n&quot;, body ? body : &quot;(none)&quot;);<br>    if (jwt_token &amp;&amp; strlen(jwt_token) &gt; 0) {<br>        printf(&quot;[MOCK HTTP] JWT: %s\n&quot;, jwt_token);<br>    }<br><br>    if (strstr(url, &quot;/auth/login&quot;)) {<br>        snprintf(response, response_size, &quot;{\&quot;token\&quot;:\&quot;FAKE_JWT_12345\&quot;}&quot;);<br>    } else {<br>        snprintf(response, response_size, &quot;{\&quot;status\&quot;:\&quot;success\&quot;}&quot;);<br>    }<br>    return true;<br>}<br><br>/* ============================<br>   LTE + JWT HANDLING<br>============================ */<br>bool init_lte_connection(void) {<br>    clock_t start = clock();<br>    bool result = lte_setup();<br>    clock_t end = clock();<br><br>    printf(&quot;[TIME] LTE setup took %.2f ms\n&quot;, elapsed_ms(start, end));<br><br>    if (!result) {<br>        printf(&quot;[ERROR] Failed to connect to LTE network\n&quot;);<br>        return false;<br>    }<br>    printf(&quot;[INFO] LTE connection established\n&quot;);<br>    return true;<br>}<br><br>bool authenticate_device(void) {<br>    char url[256], json_body[256], response[1024];<br><br>    snprintf(url, sizeof(url), &quot;%s/auth/login&quot;, BASE_URL);<br>    snprintf(json_body, sizeof(json_body),<br>             &quot;{\&quot;userName\&quot;:\&quot;%s\&quot;,\&quot;password\&quot;:\&quot;%s\&quot;}&quot;,<br>             DEVICE_NAME, PASSWORD);<br><br>    clock_t start = clock();<br>    bool req_ok = make_http_request(url, &quot;POST&quot;, response, sizeof(response),<br>                                    json_body, NULL);<br>    clock_t end = clock();<br>    printf(&quot;[TIME] Authentication request took %.2f ms\n&quot;, elapsed_ms(start, end));<br><br>    if (!req_ok) {<br>        printf(&quot;[ERROR] Login request failed\n&quot;);<br>        return false;<br>    }<br><br>    cJSON *root = cJSON_Parse(response);<br>    if (!root) {<br>        printf(&quot;[ERROR] Invalid JSON in login response\n&quot;);<br>        return false;<br>    }<br><br>    cJSON *token_obj = cJSON_GetObjectItem(root, &quot;token&quot;);<br>    if (token_obj &amp;&amp; cJSON_IsString(token_obj)) {<br>        strncpy(jwt_token, token_obj-&gt;valuestring, sizeof(jwt_token) - 1);<br>        jwt_token[sizeof(jwt_token) - 1] = &#39;\0&#39;;<br>        printf(&quot;[INFO] JWT token stored: %s\n&quot;, jwt_token);<br>    } else {<br>        printf(&quot;[ERROR] Token not found in response\n&quot;);<br>        cJSON_Delete(root);<br>        return false;<br>    }<br>    cJSON_Delete(root);<br>    return true;<br>}<br><br>bool send_secure_data(const char *json_payload) {<br>    char url[256], response[1024];<br>    snprintf(url, sizeof(url), &quot;%s/device/data&quot;, BASE_URL);<br><br>    clock_t start = clock();<br>    bool result = make_http_request(url, &quot;POST&quot;, response, sizeof(response),<br>                                    json_payload, jwt_token);<br>    clock_t end = clock();<br>    printf(&quot;[TIME] Data send took %.2f ms\n&quot;, elapsed_ms(start, end));<br><br>    return result;<br>}<br><br>bool ensure_authenticated(void) {<br>    if (strlen(jwt_token) == 0) {<br>        return authenticate_device();<br>    }<br>    return true;<br>}<br><br>/* ============================<br>   MAIN APPLICATION LOGIC<br>============================ */<br>int main(void) {<br>    if (!init_lte_connection()) return 1;<br><br>    if (!authenticate_device()) return 1;<br><br>    const char *data = &quot;{\&quot;temperature\&quot;:\&quot;25\&quot;,\&quot;battery\&quot;:\&quot;80\&quot;}&quot;;<br>    if (!send_secure_data(data)) {<br>        printf(&quot;[WARN] JWT might be expired, retrying...\n&quot;);<br>        if (authenticate_device()) {<br>            send_secure_data(data);<br>        }<br>    }<br><br>    return 0;<br>}</pre><p>Steps to RUN: (Run on VS Code , ArduinoIDE)</p><ol><li><strong>Download </strong><strong>cJSON.c and </strong><strong>cJSON.h</strong></li></ol><p>From: <a href="https://github.com/DaveGamble/cJSON">https://github.com/DaveGamble/cJSON</a><br>Put them in the same folder</p><p><strong>2. Compile</strong></p><pre>gcc mock_lte_jwt.c cJSON.c -o mock_test</pre><p><strong>3. Run</strong></p><pre>./mock_test</pre><p>Expected Output</p><pre>[00:00.000] [MOCK LTE] Initializing LTE module...<br>[00:01.200] [MOCK LTE] Sending AT command: AT<br>[00:01.250] [MOCK LTE] Response: OK<br>[00:02.000] [MOCK LTE] Attaching to network...<br>[00:04.500] [INFO] LTE connection established (2.5s)<br><br>[00:04.500] [MOCK HTTP] POST https://my-backend.com/auth/login<br>[00:04.500] [MOCK HTTP] Body: {&quot;userName&quot;:&quot;MyDevice&quot;,&quot;password&quot;:&quot;secret&quot;}<br>[00:05.600] [INFO] JWT token stored: FAKE_JWT_12345  (1.1s)<br><br>[00:05.600] [MOCK HTTP] POST https://my-backend.com/device/data<br>[00:05.600] [MOCK HTTP] Body: {&quot;temperature&quot;:&quot;25&quot;,&quot;battery&quot;:&quot;80&quot;}<br>[00:06.700] [INFO] Data sent successfully (1.1s)<br><br>[00:06.700] [INFO] Total time elapsed: 6.7 seconds</pre><h4>Conclusion</h4><p>Running an API with JWT authentication on the <strong>Quectel EG916Q-GL</strong> module offers a reliable, secure, and power-efficient way to connect IoT devices to the cloud.<br>By combining the module’s LTE capabilities with a lightweight JWT workflow, developers can,</p><p><strong>Ensure strong security</strong> — JWT tokens protect API endpoints without adding excessive overhead.</p><p><strong>Optimize power usage</strong> — ideal for battery-powered applications with long operational life.</p><p><strong>Maintain flexibility</strong> — AT commands make it adaptable to various MCU platforms such as ESP32, STM32, or other embedded processors.</p><h4>References</h4><p>1. Quectel &amp; Hardware Documentation</p><p><strong>Quectel EG916Q-GL AT Commands Manual</strong> <em>(Official PDF from Quectel)</em> — Explains LTE connection setup, HTTPS, and SSL/TLS usage.</p><p><strong>Quectel EG91x Series Hardware Design</strong> — Covers power management, pinouts, and UART/USB interface details.</p><p><strong>Quectel Developer Community</strong> — <a href="https://forums.quectel.com/">https://forums.quectel.com</a></p><p>2. JWT &amp; API Security</p><p><strong>JWT Official Website</strong> — <a href="https://jwt.io/">https://jwt.io</a><br> (Token structure, debugging, libraries for C, Python, JavaScript, etc.)</p><p><strong>RFC 7519 — JSON Web Token (JWT) Specification</strong> — <a href="https://datatracker.ietf.org/doc/html/rfc7519">https://datatracker.ietf.org/doc/html/rfc7519</a></p><p>3. Practical IoT Use Cases &amp; Tutorials</p><p><strong>Postman API Testing Tool</strong> — <a href="https://www.postman.com/">https://www.postman.com</a></p><p>Refer to the related documents : <a href="https://drive.google.com/drive/folders/1osb7M7efkDHb-JQNi29A-fjJvpdrSmQM?usp=drive_link">https://drive.google.com/drive/folders/1osb7M7efkDHb-JQNi29A-fjJvpdrSmQM?usp=drive_link</a></p><p>If you need any assistance with implementing Quectel EG916Q-GLLG-N03-SGNSA, contact us at <a href="https://www.protonest.co/contact-us">https://www.protonest.co/contact-us</a></p><p>PCB Design by: Milinda Ruberu</p><p>Firmware by: Bharkka Sharma and Abinayan Ratnasingam</p><p>Written by: Tenura Pinsara</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33179277c62a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Mesh Network for ESP32-Based IoT Systems]]></title>
            <link>https://protonestiot.medium.com/choosing-the-right-mesh-network-for-esp32-based-iot-systems-711871fc01f8?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/711871fc01f8</guid>
            <category><![CDATA[wireless-mesh-networking]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[wireless-communication]]></category>
            <category><![CDATA[esp32]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 10:33:00 GMT</pubDate>
            <atom:updated>2025-06-14T02:35:51.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYRbQ3AoxhycUbbqbcjHvg.png" /></figure><h3><strong>Mash Networking on ESP32</strong></h3><p>Mesh networking on ESP32 enables robust, scalable, and wireless communication between devices without relying on a single access point. However, several are available, such as ESP-NOW, Wi-Fi Mesh, BLE Mesh, Zigbee, and Thread.</p><h3>Why do we need mesh networks?</h3><ul><li><strong>Wide coverage</strong> — Sensors relay messages so a whole building or field stays connected.</li><li><strong>Self-healing resilience — </strong>If one node drops out, traffic automatically re-routes through the others.</li><li><strong>Easy expansion </strong>— Add a new device and it joins the network with no extra setup.</li><li><strong>Signal around obstacles</strong> — Messages hop through nearby nodes to bypass walls or metal barriers.</li><li><strong>Cost-Efficient Deployment — </strong>One Internet uplink (no extra routers or long cables) can serve many nodes.</li></ul><h3>How do you choose the right one for your application?</h3><p>This guide breaks down each mesh protocol’s strengths and best use cases using simple explanations, visuals, and comparison tools.</p><p>Firstly, the different protocols will be compared based on the key parameters. Then, the article will look at a simple flow chart to select the most suitable protocol. Finally, some of the most common use cases for mesh networking will be briefly evaluated, discussing the most suitable protocol for them.</p><h3><strong>Mesh Protocol Comparison Table</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqMA6C0xwd4ATJzAm3SUCw.png" /></figure><h3><strong>Key Features to Consider</strong></h3><h4>Ecosystem Integration</h4><ul><li><strong>Wi-Fi Mesh: </strong>Native integration with ESP RainMaker, MQTT, and cloud bridges.</li><li><strong>BLE Mesh: </strong>Mobile apps can provision/control.</li><li><strong>Zigbee:</strong> Works with Home Assistant/ Zigbee Home Automation, ESP RainMaker, Matter bridges, and is compatible with ESP32-H2/C6.</li><li><strong>Thread:</strong> Integrates into Matter ecosystems, works with Home Assistant via Border Routers, and has good IP network integration.</li><li><strong>ESP-NOW: </strong>No direct support in smart home ecosystems, best for custom, local-only ESP projects.</li></ul><h4>Diagnostics &amp; Debugging Tools</h4><ul><li><strong>Wi-Fi Mesh:</strong> Debug tool for remote logs over ESP-NOW/TCP, no need for UART attachment.</li><li><strong>BLE Mesh:</strong> Nordic nRF Mesh app, BLE sniffers (Wireshark, nRF Sniffer), BLE callbacks available in ESP SDK.</li><li><strong>Zigbee:</strong> 802.15.4 sniffers (TI Packet Sniffer, Wireshark), Espressif Zigbee Sniffer.</li><li><strong>Thread:</strong> CLI logs, Wireshark capture of 6LoWPAN, OpenThread diagnostics supported on ESP32-H2/S3.</li><li><strong>ESP-NOW: </strong>No formal tools, debug via serial logs, RSSI monitoring, or custom telemetry.</li></ul><h4>Security</h4><p>All protocols listed support AES-128 encryption, but the key difference is <strong>how provisioning is done,</strong></p><ul><li><strong>BLE Mesh &amp; Thread</strong>: Secure by design with automated provisioning</li><li><strong>Zigbee</strong>: Uses install codes or shared keys</li><li><strong>Wi-Fi Mesh</strong>: WPA2-based; provisioning usually via mobile app</li><li><strong>ESP-NOW</strong>: Requires manual key management (developer-controlled)</li></ul><h4>Library Validation &amp; Source Links (as of ESP-IDF v5.x+)</h4><p><strong>1. ESP-NOW</strong></p><p>Location: Included in ESP-IDF under components/esp_wifi</p><p>Docs: <a href="https://www.espressif.com/en/solutions/low-power-solutions/esp-now">ESP-NOW — ESP-IDF Programming Guide</a></p><p>Tested on: ESP32, ESP32-C3, ESP32-S3</p><p><strong>2. Wi-Fi Mesh (ESP-MDF)</strong></p><p>Repo: <a href="https://github.com/espressif/esp-mdf">ESP-MDF GitHub</a></p><p>Docs: <a href="https://docs.espressif.com/projects/esp-mdf/en/latest/">ESP-MDF Programming Guide</a></p><p>Features: Mesh routing, root node bridging, Mupgrade OTA, Mdebug logging</p><p><strong>3. BLE Mesh</strong></p><p>Repo/Module: Built into ESP-IDF as esp_ble_mesh component</p><p>Docs: <a href="https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/esp-ble-mesh/ble-mesh-index.html">https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/esp-ble-mesh/ble-mesh-index.html</a></p><p>Examples: examples/bluetooth/esp_ble_mesh in ESP-IDF repo</p><p><strong>4. Zigbee</strong></p><p>SDK: esp-zigbee-sdk GitHub</p><p>Docs: Zigbee SDK Guide</p><p>Tested on: ESP32-H2, ESP32-C6 (required for IEEE 802.15.4)</p><p>Zigbee 3.0 Certified: Yes (based on ZBOSS stack)</p><p><strong>5. Thread</strong></p><p>SDK: <a href="https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/openthread.html">https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/openthread.html</a></p><p>Tested on: ESP32-H2, ESP32-C6</p><p>Supports Matter: Yes (as part of Matter SDK stack)</p><p>All these libraries can be built using the CMake-based ESP-IDF build system, and Espressif provides working examples in most cases (especially for BLE Mesh, Wi-Fi Mesh, ESP-NOW).</p><h3><strong>Power vs. Throughput Tradeoff</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/0*BDasuF0_YgGXWVSO" /></figure><p>As this graph demonstrates, WiFi mesh has a significantly high throughput over power consumption compared to the other protocols. In order to visualize the difference among the other protocols that have a relatively low throughput, the below graph can be referred to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*cy5YPnKpFzBV_KGW" /></figure><p>Refer: <a href="https://docs.espressif.com/projects/esp-techpedia/en/latest/esp-friends/solution-introduction/mesh/mesh-comparison.html#:~:text=Mesh%20Solution%20Comparison">https://docs.espressif.com/projects/esp-techpedia/en/latest/esp-friends/solution-introduction/mesh/mesh-comparison.html#:~:text=Mesh%20Solution%20Comparison</a></p><h3>Quick Selection Flowchart (Simplified Step-by-Step)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TDe8iTDBuCvPgWqEgvIS4Q.png" /></figure><h3>Key Application Scenarios and Recommendations (with Device Counts)</h3><ul><li><strong>Smart Home Sensors (Battery-powered)<br>Best Fit:</strong> Zigbee or Thread<br><strong>Why:</strong> Low power, reliable, standard-compliant<br><strong>Typical Network Size: </strong>Zigbee, Thread: Around 300 nodes</li><li><strong>User-Friendly Lighting Control (With Phones)<br>Best Fit:</strong> Bluetooth Mesh (BLE Mesh)<br><strong>Why:</strong> Phones can provision and control devices directly, suitable for lighting<br><strong>Typical Network Size: </strong>BLE Mesh: ~100 nodes practical (up to ~32,000 nodes theoretically)</li><li><strong>Industrial Sensor Networks<br>Best Fit:</strong> Thread or Zigbee<br><strong>Why:</strong> High scalability, proven in large networks, good resilience<br><strong>Typical Network Size: </strong>Zigbee, Thread: ~ 300 nodes</li><li><strong>Wi-Fi Coverage Extension + Data Transfer<br>Best Fit:</strong> Wi-Fi Mesh (ESP-MESH)<br><strong>Why:</strong> High throughput, IP access, ESP-MDF support<br><strong>Typical Network Size: </strong>Wi-Fi Mesh (ESP-MESH): Espressif tested up to 100 nodes</li><li><strong>Custom Real-Time Networks with Few Devices<br>Best Fit:</strong> ESP-NOW<br><strong>Why:</strong> Very low latency, easy setup, ideal for fast control loops<br><strong>Typical Network Size: </strong>ESP-NOW: &lt;20 nodes (up to 10 peers per device recommended by Espressif)</li></ul><h3>Here is the Final Takeaway,</h3><p><strong>If low power is critical</strong>, go Zigbee/Thread. <strong>If a user-friendly setup with a phone is needed</strong>, go BLE Mesh. <strong>If you need to push big data</strong>, use Wi-Fi Mesh. <strong>If you’re building a lightweight custom network</strong>, try ESP-NOW.</p><p>By understanding your application’s power, bandwidth, and user interaction needs, and matching it with these protocols, you can make an informed, confident mesh selection.</p><h3><strong>References</strong></h3><ol><li>Espressif Systems, “ESP-NOW,” <em>ESP-IDF Programming Guide</em>, [Online]. Available: <a href="https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/network/esp_now.html">https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/network/esp_now.html</a></li><li>Espressif Systems, “ESP-MDF Programming Guide,” <em>ESP-MDF Documentation</em>, [Online]. Available: <a href="https://docs.espressif.com/projects/esp-mdf/en/latest/">https://docs.espressif.com/projects/esp-mdf/en/latest/</a></li><li>Bluetooth SIG, “Bluetooth® Mesh Networking FAQs,” <em>Bluetooth Technology Website</em>, [Online]. Available: <a href="https://www.bluetooth.com/learn-about-bluetooth/feature-enhancements/mesh/mesh-faq/">https://www.bluetooth.com/learn-about-bluetooth/feature-enhancements/mesh/mesh-faq/</a></li><li>Bluetooth SIG, “Bluetooth Mesh Networking: The Packet,” <em>Bluetooth Technology Website</em>, [Online]. Available: <a href="https://www.bluetooth.com/bluetooth-resources/bluetooth-mesh-networking-the-packet/">https://www.bluetooth.com/bluetooth-resources/bluetooth-mesh-networking-the-packet/</a></li><li>OpenThread, “What is Thread?,” <em>OpenThread Documentation</em>, [Online]. Available: <a href="https://openthread.io/guides/thread-primer/">https://openthread.io/guides/thread-primer/</a></li><li>OpenThread, “Display and Manage Network Data with OT CLI,” <em>OpenThread Documentation</em>, [Online]. Available: <a href="https://openthread.io/reference/cli/concepts/netdata">https://openthread.io/reference/cli/concepts/netdata</a></li><li>OpenThread, “IP6 Service — OpenThread,” <em>OpenThread Documentation</em>, [Online]. Available: <a href="https://openthread.io/reference/config/group/config-ip6">https://openthread.io/reference/config/group/config-ip6</a> kumarasenau@gmail.com</li><li>Bluetooth SIG, “Bluetooth Mesh Lighting Networks: A Practical Guide for Lighting Manufacturers,” <em>Bluetooth Technology Website</em>, [Online]. Available: <a href="https://www.bluetooth.com/bluetooth-resources/bluetooth-mesh-lighting-networks-a-practical-guide-for-lighting-manufacturers/">https://www.bluetooth.com/bluetooth-resources/bluetooth-mesh-lighting-networks-a-practical-guide-for-lighting-manufacturers/</a></li><li>Espressif Systems, “ESP-WIFI-MESH Basic Information and FAQ,” <em>ESP-MDF Programming Guide</em>, [Online]. Available: <a href="https://docs.espressif.com/projects/esp-mdf/en/latest/api-guides/general-notes.html">https://docs.espressif.com/projects/esp-mdf/en/latest/api-guides/general-notes.html</a></li><li>Espressif Systems, “Mwifi API,” <em>ESP-MDF Programming Guide</em>, [Online]. Available: <a href="https://docs.espressif.com/projects/esp-mdf/en/latest/api-reference/mwifi/index.html">https://docs.espressif.com/projects/esp-mdf/en/latest/api-reference/mwifi/index.html</a></li><li>Espressif Systems, “Mlink,” <em>ESP-MDF Programming Guide</em>, [Online]. Available: <a href="https://docs.espressif.com/projects/esp-mdf/en/latest/api-guides/mlink.html">https://docs.espressif.com/projects/esp-mdf/en/latest/api-guides/mlink.html</a></li><li>Bluetooth SIG, “Large Scale Bluetooth Mesh Testing,” <em>Bluetooth Technology Website</em>, [Online]. Available: <a href="https://www.bluetooth.com/bluetooth-resources/large-scale-bluetooth-mesh-testing/">https://www.bluetooth.com/bluetooth-resources/large-scale-bluetooth-mesh-testing/</a></li><li>OpenThread, “Thread Border Router — Thread 1.2 Multicast,” <em>OpenThread Documentation</em>, [Online]. Available: <a href="https://openthread.io/codelabs/openthread-border-router-ipv6-multicast">https://openthread.io/codelabs/openthread-border-router-ipv6-multicast</a></li><li>OpenThread, “Router/Leader — OpenThread,” <em>OpenThread Documentation</em>, [Online]. Available: <a href="https://openthread.io/reference/group/api-thread-router">https://openthread.io/reference/group/api-thread-router</a></li><li>Bluetooth SIG, “Bluetooth® Mesh Networking,” <em>Bluetooth Technology Website</em>, [Online]. Available: <a href="https://www.bluetooth.com/learn-about-bluetooth/feature-enhancements/mesh/">https://www.bluetooth.com/learn-about-bluetooth/feature-enhancements/mesh/</a></li></ol><p><strong>Good Luck with your Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=711871fc01f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Low Power Push-Button Control with TPS22918 and STM32]]></title>
            <link>https://protonestiot.medium.com/low-power-push-button-circuit-with-tps22918-and-stm32-48e52ab71051?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/48e52ab71051</guid>
            <category><![CDATA[low-power-design]]></category>
            <category><![CDATA[embedded-systems-design]]></category>
            <category><![CDATA[stm32]]></category>
            <category><![CDATA[switching]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Sun, 04 May 2025 07:58:49 GMT</pubDate>
            <atom:updated>2025-06-02T09:47:33.894Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyMm-eyhh8BKAgVU4CpZVg.png" /></figure><p>At <strong>Protonest IoT</strong>, we often look for ways to make our embedded designs simpler, smarter, and more power-efficient. In one of our recent projects, we had a challenge,</p><p><strong>Could we use a single button not just to power on/off a device, but also trigger multiple features?</strong></p><p>Thanks to the support of our consultant <strong>Yashodha Salgadu</strong> and our PCB Designer <strong>Milinda Ruberu</strong>, we came up with a reliable solution, and it’s now becoming a standard in our future designs.</p><p>This article walks you through how we achieved it.</p><h4>What’s Special about this?</h4><p>This system,</p><ul><li>Uses just one momentary push button.</li><li>Consumes microamps in OFF mode.</li><li>Let the microcontroller power itself down.</li><li>Triggers different actions based on how long you hold the button.</li></ul><p>Perfect for battery-powered, field-deployed, or handheld devices.</p><h4>Real Use Cases</h4><p>In protonest, we tested this setup with motor controllers, in which,</p><ul><li>A short press switches between the motors.</li><li>A long press turns the system ON &amp; OFF.</li><li>All power LEDs and circuits are cut when off, saving energy.</li></ul><p>The results were great, and we were able to achieve the requirement.</p><p>We’re currently using this with an STM32, but it’s controllable with ESP32 or other MCUs.</p><h3>Key Components Needed</h3><h4><a href="https://www.digikey.com/en/products/detail/texas-instruments/TPS22918DBVR/5994601">TPS22918 Load Switch</a></h4><p>A super-efficient power gate,</p><ul><li>ON-resistance: ultra-low</li><li>OFF current: &lt;1 µA</li><li>Built-in output discharge</li></ul><h4><a href="https://s.click.aliexpress.com/e/_oDOW5Mt">Microcontroller (STM32)</a></h4><ul><li><strong>Reads</strong> button pin via GPIO3</li><li><strong>Controls</strong> power via GPIO9</li><li><strong>Executes actions</strong> based on press duration:</li></ul><ol><li>50–500ms → Quick feature (e.g., motor shift)</li><li>~1s → Mode change or calibration</li><li>≥3s → Power-off</li></ol><h4><a href="https://s.click.aliexpress.com/e/_onlWfYv">Push Button</a></h4><ul><li>Button pulls EN HIGH to power up</li><li>Ensures system draws almost zero current when off</li></ul><h4><a href="https://www.lcsc.com/product-detail/Low-Dropout-Regulators-LDO_TI_TLV73333PDBVR_TLV73333PDBVR_C134139.html"><strong>LDO: TLV73333PDBVR</strong></a></h4><ul><li>Regulates voltage to support the 3.3V input of STM32.</li></ul><h3>Circuit Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*reQ9OtElqmG2pAQafKXkFQ.png" /></figure><h4>How It Works</h4><p>Here’s the system’s flow from power-off to full control,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*r6QoZqAlNhyGdIdPM62thg.jpeg" /></figure><h3><strong>Firmware Logic</strong></h3><pre>#include &lt;Arduino.h&gt;<br><br>// Pin configuration<br>const int buttonPin = PB3;<br>const int powerPin  = PB9;<br><br>// Debounce and timing<br>const unsigned long debounceDelay = 50;<br>const unsigned long shortPressMin = 50;<br>const unsigned long shortPressMax = 500;<br>const unsigned long midPressMin   = 800;<br>const unsigned long midPressMax   = 1200;<br>const unsigned long longPressMin  = 3000;<br><br>volatile bool buttonState = LOW;<br>volatile bool lastButtonState = LOW;<br>volatile unsigned long pressStartTime = 0;<br>volatile unsigned long lastDebounceTime = 0;<br><br>bool isPowerOn = true;<br><br>void setup() {<br>  pinMode(buttonPin, INPUT);<br>  pinMode(powerPin, OUTPUT);<br>  digitalWrite(powerPin, HIGH);  // Initially powered on<br><br>  Serial.begin(9600);<br>}<br><br>void loop() {<br>  unsigned long currentTime = millis();<br>  bool reading = digitalRead(buttonPin);<br><br>  if (reading != lastButtonState) {<br>    lastDebounceTime = currentTime;<br>  }<br><br>  if ((currentTime - lastDebounceTime) &gt; debounceDelay) {<br>    if (reading != buttonState) {<br>      buttonState = reading;<br><br>      if (buttonState == HIGH) {<br>        pressStartTime = currentTime;<br>      } else {<br>        unsigned long pressDuration = currentTime - pressStartTime;<br>        handleButtonPress(pressDuration);<br>      }<br>    }<br>  }<br><br>  lastButtonState = reading;<br>}<br><br>// Handle actions based on press duration<br>void handleButtonPress(unsigned long duration) {<br>  if (duration &gt;= shortPressMin &amp;&amp; duration &lt;= shortPressMax) {<br>    Serial.println(&quot;Short press detected: motor shift&quot;);<br>    motorShift();<br>  }<br>  else if (duration &gt;= midPressMin &amp;&amp; duration &lt;= midPressMax) {<br>    Serial.println(&quot;Mid press detected: calibrate&quot;);<br>    calibrateSystem();<br>  }<br>  else if (duration &gt;= longPressMin) {<br>    Serial.println(&quot;Long press detected: power off&quot;);<br>    powerOff();<br><br>    // Wait here until button pressed again to power back on<br>    while (digitalRead(buttonPin) == LOW);  // Wait for button release<br>    delay(200);  // Debounce<br>    while (digitalRead(buttonPin) == HIGH); // Wait for next press<br><br>    Serial.println(&quot;Powering back on&quot;);<br>    powerOn();<br>  }<br>}<br><br>void motorShift() {<br>  // Example motor shift code<br>  Serial.println(&quot;Motor shifted.&quot;);<br>}<br><br>void calibrateSystem() {<br>  // Example calibration code<br>  Serial.println(&quot;System calibrated.&quot;);<br>}<br><br>void powerOff() {<br>  digitalWrite(powerPin, LOW);<br>  isPowerOn = false;<br>}<br><br>void powerOn() {<br>  digitalWrite(powerPin, HIGH);<br>  isPowerOn = true;<br>}</pre><h3>Why This Is Better Than Other Options?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ASxsmap8V9qFwE_0pBzEQ.png" /></figure><p>With this method,</p><ul><li>You don’t need latches or power supervisor ICs.</li><li>You reduce the BOM.</li><li>You have full control from firmware.</li><li>You draw only a <strong>few microamps</strong> when off.</li></ul><h3>Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SOmHx0fzdmROSsacaf8zwg.png" /></figure><p>One button. Zero complexity. More functionality.</p><p>Whether you’re building a battery-powered sensor, a portable controller, or a slick low-power interface, this method keeps your device <strong>simple</strong>, <strong>smart</strong>, and <strong>power-efficient.</strong></p><p><strong>Good Luck with your Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48e52ab71051" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Raspberry Pi Pico W Captive Portal WiFi Setup]]></title>
            <link>https://protonestiot.medium.com/raspberry-pi-pico-w-captive-portal-wifi-setup-b64a8c56ec18?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b64a8c56ec18</guid>
            <category><![CDATA[wifi-configuration]]></category>
            <category><![CDATA[captive-portal]]></category>
            <category><![CDATA[micropython]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[iot-projects]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 07:49:53 GMT</pubDate>
            <atom:updated>2025-05-09T12:11:19.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fK7VPfvhznaySh6Yhf6IXg.png" /></figure><p>We had a chance to work on a project with Raspberry Pi Pico W to build a MicroPython-based captive portal using both Access Point (AP) and Station (STA) modes.</p><p>This system allows users to,</p><ul><li>Configure Wi-Fi settings via a web interface.</li><li>Automatically redirected to a captive portal webpage to input router credentials.(These credentials are securely saved and used to establish a connection in STA mode.)</li><li>Auto-reconnection logic, a fallback to AP mode when the maximum number of failures is reached</li><li>Web server with an embedded map interface for managing GPS coordinates of the location.</li></ul><p>The needed components for the project,</p><ul><li><a href="https://s.click.aliexpress.com/e/_on9I0tV">Raspberry Pi Pico W</a></li><li><a href="https://s.click.aliexpress.com/e/_omNsQdd">USB to Micro USB Cable</a></li></ul><h3>What are AP Mode and STA Mode?</h3><h4>AP Mode (Access Point Mode)</h4><ul><li>Pico W creates its WiFi network (PicoW_Config)</li><li>Used for first-time setup or when WiFi fails</li><li>Devices connect directly without a router</li></ul><h4><strong>STA Mode (Station Mode)</strong></h4><ul><li>Pico W connects to an existing WiFi router</li><li>Used for regular operations after setup</li><li>Enables features like web access and data transfer over the local network</li></ul><p>We will guide you through the setup process, let’s start by preparing the Raspberry Pi pico w.</p><ul><li>First, plug your Raspberry Pi Pico W into your computer using a micro USB cable.</li><li>If this is your first time setting up the Pico or reinstalling MicroPython, hold the BOOTSEL button on the Pico.</li><li>Once the Pico appears as a removable drive on your computer, release the BOOTSEL button.</li></ul><p>Now let’s Install MicroPython on the Pico W</p><ul><li>Download the latest MicroPython UF2 file for the Pico W from <a href="https://www.raspberrypi.com/documentation/microcontrollers/micropython.html">here</a>.</li><li>Drag and drop the downloaded UF2 file onto the Pico W drive that appears on your computer.</li><li>The Pico will automatically reboot and be ready for programming.</li></ul><p>Thonny IDE and Configure for MicroPython,</p><ul><li>Open Thonny IDE on your computer. (If you haven’t installed, install it from <a href="https://thonny.org/">here</a>.)</li><li>After that, go to Tools &gt; Options and select the Interpreter tab.</li><li>From the Interpreter dropdown, choose MicroPython (Raspberry Pi Pico).</li><li>Check the option “Try to detect port automatically” to allow Thonny to detect the connected Pico.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*Ed9CMK1k2VPwTLrGLZ4twQ.png" /></figure><p>Download and Upload main.py to the Pico W,</p><ul><li>Click on the<a href="https://drive.google.com/file/d/164yCdO8dzZGZrWY7IC9xZOJE9GWums7B/view?usp=sharing"> Download main.py</a> link to download the Python script to your computer. (This script contains HTML code as well.)</li></ul><p>Upload the main.py Script to the Raspberry Pi Pico W,</p><ul><li>Open Thonny IDE on your computer.</li><li>Go to File &gt; Open, then browse to the location where you downloaded the main.py script.</li><li>Open the main.py script in Thonny.</li><li>In Thonny, go to File &gt; Save As.</li><li>Select Raspberry Pi Pico from the available devices.</li><li>Save the file with the name main.py directly onto the Raspberry Pi Pico W.</li><li>Ensure that you save it directly to the Pico W and not to your computer.</li></ul><p>In main.py, you can define the following configuration variables,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*qpDygV22F80sYwuFhywQCw.png" /></figure><ul><li>CHECK_INTERVAL: The time interval (in seconds) between each Wi-Fi connection status check.</li><li>MAX_FAILS: Maximum number of connection failures allowed before the system falls back to Access Point (AP) mode.</li><li>AP_SSID: The SSID (name) of the Access Point (AP) for the Pico W to create.</li><li>AP_PASSWORD: The password required to connect to the Pico W’s AP network.</li></ul><p>After saving the script, click the Run button in Thonny to execute the script on the Raspberry Pi Pico W.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/0*hln0syDHMMZSYXzw" /></figure><p><strong>What Happens When the Script Runs,</strong></p><p>Disconnecting from Wi-Fi,</p><ul><li>The device first disconnects from any previously connected Wi-Fi networks to ensure a clean start.</li></ul><p>Attempt to Connect,</p><ul><li>If this is the first time you’re running the script and the wifi_config.json file does not exist, the device automatically enters Access Point (AP) mode.</li></ul><p>AP Mode</p><ul><li>In AP mode, the device broadcasts a Wi-Fi network named “PicoW_Config.”</li><li>Connect to ‘PicoW_Config’: You need to connect your device to the “PicoW_Config” Wi-Fi network with below credentials,</li></ul><pre>AP_SSID = &quot;PicoW_Config&quot;     <br>AP_PASSWORD = &quot;12345678&quot;</pre><ul><li>Once connected, the device will automatically redirect you to a captive portal webpage <a href="http://192.168.4.1/">http://192.168.4.1</a>. (This redirection happens through DNS interception, meaning all DNS requests are rerouted to this address)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*jKu0e7yldC04FDC447U3lQ.png" /></figure><ul><li>Once you submit the Wi-Fi credentials through the captive portal, they are sent to the Raspberry Pi Pico W, which then attempts to establish a connection with the specified router.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*KcCqpG9H-1_IztY7F3ugOg.png" /></figure><p>If the connection is successful,</p><ul><li>The system will send a response showing the connected SSID and the IP address of the STA mode webpage.</li><li>The captive portal will close, and the system will switch to STA mode.</li><li>To access the STA mode webpage, connect your device to the same WiFi connection that the Pico is connected to, and then click the IP address link.</li></ul><p>If the connection to the router fails, the system will attempt to reconnect.</p><ul><li>If reconnection is successful, it will show the SSID and STA mode webpage IP address.</li><li>If reconnection also fails, the interface will show the following,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/0*R_pL5_vWCjbaNzwH" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/0*t_ZK6D7ZyAFrqI9q" /></figure><p>And the portal will prompt you to re-enter the credentials. The system will start AP mode again, reload the web page, and display the credential entering page again.</p><h4>STA mode</h4><p>In STA mode, the main functionality is driven by two core functions,</p><ul><li>Web Server and Coordinate Handling</li><li>Connection Monitoring and Reconnection Logic</li></ul><h4><strong>Web Server and Coordinate Handling</strong></h4><p>This is how the STA mode web interface looks,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aMO2bl62bnEkqhXz" /></figure><ul><li>In STA mode, you can either search for a location or manually point to your location on the map.</li><li>The coordinates of the selected location will be displayed. When you click to save the coordinates, the data is sent to the Raspberry Pi Pico W.</li><li>Once the Pico receives the coordinates, they are stored and processed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZNfUNdJvx_T3ESce" /></figure><h4><strong>Connection Monitoring and Reconnection Logic</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*whaAnPoyqj3e9Z_B" /></figure><ul><li>The system periodically performs HTTP requests at intervals defined by CHECK_INTERVAL to verify internet connectivity, attempting to connect to example.com and google.com to ensure the device has internet access.</li></ul><p><strong>If the Connectivity Test Fails,</strong></p><ul><li>If the connectivity test fails, then the system will try to reconnect to the Wi-Fi network.</li></ul><p><strong>If Reconnection is Successful,</strong></p><ul><li>If the device successfully reconnects to the Wi-Fi and passes the connectivity tests, it will remain in STA Mode.</li></ul><p><strong>If Reconnection Attempts Exceed MAX_FAILS,</strong></p><ul><li>If reconnection fails beyond MAX_FAILS, the device will switch to AP Mode for reconfiguration, prompting you to re-enter Wi-Fi credentials.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*FRlS8J6y_o-f9k2oQ_5Aew.png" /></figure><p>When you stop the application, you will see the creation of two files on the Raspberry Pi Pico W,</p><ul><li>coordinates.json — This file stores the coordinates of the selected location.</li><li>wifi_credentials.json — This file contains the saved Wi-Fi credentials (SSID and password).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*Vv6ebivi3uEqYIGA" /></figure><p>When You Run the Script Again,</p><ul><li>It attempts to Connect Using Stored Credentials: The device will first check if there are any saved Wi-Fi credentials and attempt to use them to connect to the router.</li></ul><p>If Connection is Successful,</p><ul><li>The system will proceed to switch to STA Mode and send a response showing the connected SSID and the STA mode IP address.</li><li>The captive portal will close, and you can access the STA mode webpage by clicking the IP address.</li><li>When the webpage is served, a GET /coordinates request is automatically triggered to fetch and display the GPS coordinates that the user has already saved in the coordinates.json file. These coordinates are shown initially on the webpage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0euG0L9ed5-RY2Ne" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nv7SFEdSYHNMQhf4" /></figure><ul><li>The connectivity test process continues to check internet access.</li></ul><p>If the Connection Fails,</p><ul><li>The device will start AP mode, prompting you to enter the credentials again.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*drRG57xfZCaZ-ZyO" /></figure><h4>Limitations</h4><p>Limitations in AP Mode:</p><ul><li>Desktop Devices: While most Desktop Devices work fine with captive portal redirection, some OS may fail to immediately trigger the redirection when connected to the “PicoW_Config” network. This is related to how the OS handles DNS requests.</li><li>Mobile Phones (Android/iOS): Mobile phones generally show a notification or auto-redirect to the captive portal after connecting to the “PicoW_Config” network. However, there may be delays, particularly with older operating systems or specific device configurations.</li><li>Other DNS Requests (e.g. WhatsApp): Apps like WhatsApp can delay redirection by making background DNS requests. These app requests interfere with the DNS redirection, potentially causing delays in reaching the captive portal.</li></ul><p>Limitations in STA Mode:</p><ul><li>IP Address Assignment: In STA mode, the IP for the web server is dynamically assigned by the router. Therefore, you cannot manually assign a desired IP address.</li><li>Loss of Connection: If the Pico W disconnects from the router, it loses its IP address, causing the web server to stop functioning. The webpage won’t display a disconnected status.</li><li>Coordinate Saving Issues: If the Wi-Fi connection is checked at intervals shorter than 30 seconds, there may be occasional failures in saving coordinates due to interference. Increasing the Wi-Fi check interval to 50 seconds ensures that coordinates are saved reliably.</li></ul><p>By Following the above procedure, you will be able to implement a captive portal on Raspberry Pi Pico W.</p><p>Developed &amp; Written by: T F Nusha</p><p><strong>Good Luck with your IoT Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b64a8c56ec18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Router Connectivity Monitoring with Teltonica Router, Node.js, and Courier]]></title>
            <link>https://protonestiot.medium.com/router-connectivity-monitoring-with-teltonica-router-node-js-and-courier-c1a23bc9596a?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1a23bc9596a</guid>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 07:24:17 GMT</pubDate>
            <atom:updated>2025-02-27T07:24:17.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-4GI5Td2sbsg61TqrpdQA.png" /></figure><p>Router connectivity monitoring has become one of the main aspects of modern networking, which ensures that downtime is minimized and issues are caught before they escalate. With the right setup, you can track multiple routers, and receive instant notifications via email if one goes offline.</p><p>We faced a business challenge to have an email notification for the user when there is no network connection in the router. No router can provide within the router itself, since an email cannot be sent without any internet connection. In this article, we explore a practical approach using Node.js hosted on Firebase, a Teltonica router’s Wget feature, and the Courier email service.</p><p>We also show you how to dynamically modify key settings, like the time interval, email address, and number of routers using Postman calls, so you can adapt on the fly without redeploying your application.</p><h3><strong>Introduction</strong></h3><p>In this article, we will discuss router connectivity monitoring and how it helps you track any potential network failure.</p><p>We’ll walk through configuring a Teltonica router to run a get request to a Node.js server at set intervals, then show you how to receive email alerts through Courier if a router stops sending.</p><p>Beyond that, we will cover how to use Postman to change your setup in real-time adjusting the time interval, altering the email recipient, and even adding or removing routers from the monitoring pool.</p><p>This flexibility helps you maintain a multiple router environment without heavy configuration overhead.</p><p>So, by the end of this piece, you’ll have a clear path to monitoring your routers effectively and adapting your solution to your needs.</p><p>Here is the router we used,</p><p>Official: <a href="https://teltonika-networks.com/products/routers/rutx50">https://teltonika-networks.com/products/routers/rutx50</a></p><p>US :<a href="https://amzn.to/41bemDF"> Amazon</a></p><p>Non US: <a href="https://amzn.to/4jPBVZV">Amazon</a></p><h3><strong>Why Router Connectivity Monitoring Is Important</strong></h3><p>Monitoring your routers’ connectivity offers several key benefits. Let’s discuss the main benefits.</p><h4><strong>Reduced Downtime</strong></h4><ul><li>Get instant notifications and address connectivity issues quickly, so your network remains operational.</li></ul><h4><strong>Easy Troubleshooting</strong></h4><ul><li>Pinpoint which router went down and when speeding up the recovery process.</li></ul><h4><strong>Scalability</strong></h4><ul><li>Whether you have one router or ten, you can easily add or remove devices from the monitoring tool.</li></ul><h4><strong>Proactive Alerts</strong></h4><ul><li>Staying informed means you can tackle issues proactively rather than being blindsided by unexpected downtime.</li></ul><h4><strong>Flexibility</strong></h4><ul><li>Easily change core configurations like add new nodes, monitoring intervals and alert recipients, so your setup remains relevant as your needs evolve.</li></ul><h3><strong>Step-by-Step Implementation</strong></h3><h4><strong>Setting Up the Environment</strong></h4><ul><li><strong>Node.js</strong>: Install Node.js (v14+).</li><li><strong>Courier Account</strong>: Create an account at <a href="https://www.courier.com/">Courier</a> to obtain your authorization token.</li><li><strong>Teltonica Router</strong>: Ensure your router is accessible and has the Wget/Auto Reboot feature.</li><li><strong>Postman (or Similar API Tool)</strong>: You’ll need Postman to make quick changes to your Node.js app.</li></ul><h4><strong>The Node.js Application Code</strong></h4><pre>//Router Connectivity Monitoring Server   <br>//Using Node.js, Express, and Courier    <br>const express = require(&quot;express&quot;);<br>const { CourierClient } = require(&quot;@trycourier/courier&quot;);<br><br>const app = express();<br>const port = 3000;<br><br>// Parse JSON in request bodies<br>app.use(express.json());<br><br>// Default configurations<br>let NUM_ROUTERS = 5;<br>let TIME_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes in milliseconds<br><br>// Courier initialization (replace with your token)<br>const courier = new CourierClient({<br>  authorizationToken: &quot;YOUR_COURIER_AUTH_TOKEN_HERE&quot;, // Replace with the courier token<br>});<br><br>// Track last ping time and timers for each router<br>let routerPingStatus = {};<br>let routerTimers = {};<br><br>// Default email recipient<br>let emailRecipient = &quot;info@example.com&quot;;<br><br>//Helper function to send an email alert<br>async function sendEmail(routerId) {<br>  try {<br>    const { requestId } = await courier.send({<br>      message: {<br>        to: {<br>          email: emailRecipient,<br>        },<br>        content: {<br>          title: `No ping for router ${routerId}`,<br>          body: `No ping received for router ${routerId} in the last ${<br>            TIME_INTERVAL_MS / 60000<br>          } minute(s)!`,<br>        },<br>        routing: {<br>          method: &quot;single&quot;,<br>          channels: [&quot;email&quot;],<br>        },<br>      },<br>    });<br><br>    console.log(&quot;Email sent via Courier, requestId:&quot;, requestId);<br>  } catch (error) {<br>    console.error(&quot;Error sending email via Courier:&quot;, error);<br>  }<br>}<br><br>//2. Initialize router data structures<br>function initializeRouters(num) {<br>  routerPingStatus = {};<br>  routerTimers = {};<br><br>  for (let i = 1; i &lt;= num; i++) {<br>    routerPingStatus[i] = null; // Last ping timestamp<br>    routerTimers[i] = null;     // setTimeout reference<br>  }<br>}<br><br>//Start the timer for a router<br>function startTimerForRouter(routerId) {<br>  if (routerTimers[routerId]) {<br>    clearTimeout(routerTimers[routerId]);<br>  }<br><br>  routerTimers[routerId] = setTimeout(() =&gt; {<br>    const lastPing = routerPingStatus[routerId];<br>    if (!lastPing || Date.now() - lastPing &gt;= TIME_INTERVAL_MS) {<br>      console.log(<br>        `No ping received for router ${routerId} in the last ${<br>          TIME_INTERVAL_MS / 60000<br>        } minute(s). Sending email.`<br>      );<br>      sendEmail(routerId);<br>    }<br>    routerTimers[routerId] = null;<br>  }, TIME_INTERVAL_MS);<br>}<br><br>//Create router endpoints dynamically<br>function createRouterEndpoints() {<br>  for (let i = 1; i &lt;= NUM_ROUTERS; i++) {<br>    // Health endpoint<br>    app.get(`/router${i}/health`, (req, res) =&gt; {<br>      const routerId = i;<br>      const lastPing = routerPingStatus[routerId];<br>      let secondsSinceLastPing = null;<br><br>      if (lastPing) {<br>        secondsSinceLastPing = Math.floor((Date.now() - lastPing) / 1000);<br>      }<br><br>      res.status(200).json({<br>        routerId,<br>        status: &quot;healthy&quot;,<br>        lastPing: lastPing ? new Date(lastPing).toISOString() : null,<br>        secondsSinceLastPing,<br>      });<br>    });<br><br>    // Ping endpoint<br>    app.get(`/router${i}/ping`, (req, res) =&gt; {<br>      const routerId = i;<br>      routerPingStatus[routerId] = Date.now();<br><br>      // Restart the timer<br>      startTimerForRouter(routerId);<br><br>      res.status(200).json({<br>        message: `Ping received for router ${routerId}`,<br>        timestamp: new Date().toISOString(),<br>      });<br>    });<br>  }<br>}<br><br>// Initialize routers and endpoints at startup<br>initializeRouters(NUM_ROUTERS);<br>createRouterEndpoints();<br><br>//Configuration endpoints<br> <br>// Change the number of routers<br>app.post(&quot;/config/num-routers&quot;, (req, res) =&gt; {<br>  const { numRouters } = req.body;<br>  if (!numRouters || typeof numRouters !== &quot;number&quot;) {<br>    return res.status(400).json({<br>      error: &quot;Please provide a valid &#39;numRouters&#39; number&quot;,<br>    });<br>  }<br><br>  NUM_ROUTERS = numRouters;<br>  initializeRouters(NUM_ROUTERS);<br>  createRouterEndpoints();<br><br>  res.status(200).json({<br>    message: `Number of routers changed to ${NUM_ROUTERS}`,<br>    currentRouters: NUM_ROUTERS,<br>  });<br>});<br><br>// Change the email recipient<br>app.post(&quot;/config/email&quot;, (req, res) =&gt; {<br>  const { recipient } = req.body;<br>  if (!recipient || typeof recipient !== &quot;string&quot;) {<br>    return res.status(400).json({<br>      error: &quot;Please provide a valid &#39;recipient&#39; string&quot;,<br>    });<br>  }<br><br>  emailRecipient = recipient;<br>  res.status(200).json({<br>    message: &quot;Email recipient updated&quot;,<br>    currentConfig: {<br>      emailRecipient,<br>    },<br>  });<br>});<br><br>// Change the time interval<br>app.post(&quot;/config/time-interval&quot;, (req, res) =&gt; {<br>  const { intervalMs } = req.body;<br>  if (typeof intervalMs !== &quot;number&quot; || intervalMs &lt;= 0) {<br>    return res<br>      .status(400)<br>      .json({ error: &quot;Please provide a valid &#39;intervalMs&#39; (milliseconds) &gt; 0&quot; });<br>  }<br><br>  TIME_INTERVAL_MS = intervalMs;<br>  // Reset timers for each router<br>  for (let i = 1; i &lt;= NUM_ROUTERS; i++) {<br>    if (routerTimers[i]) {<br>      clearTimeout(routerTimers[i]);<br>      routerTimers[i] = null;<br>    }<br>    if (routerPingStatus[i] !== null) {<br>      startTimerForRouter(i);<br>    }<br>  }<br><br>  res.status(200).json({<br>    message: `Time interval changed to ${TIME_INTERVAL_MS} ms`,<br>  });<br>});<br><br>// Start the Express server<br>app.listen(port, () =&gt; {<br>  console.log(`Server is running on port ${port}`);<br>  console.log(`Created ${NUM_ROUTERS} router health and ping endpoints.`);<br>});</pre><ul><li><strong>Courier Setup</strong>: Replace “YOUR_COURIER_AUTH_TOKEN_HERE” with your actual Courier authorization token. Will be discussed later on setting up Courier.</li><li><strong>Dynamic Endpoints</strong>: <strong>/routerX/health</strong> and <strong>/routerX/ping </strong>let each router check in.</li><li><strong>Config Endpoints</strong>:</li></ul><pre>POST /config/num-routers //Updates the number of monitored routers.<br>POST /config/email //Changes the recipient email address.<br>POST /config/time-interval //Modifies the ping interval in milliseconds.</pre><h4>Courier Setup</h4><p><strong>Sign Up and create a workspace</strong></p><ul><li>Go to <a href="https://www.courier.com/">Courier</a> and <strong>create an account</strong>.</li><li>Click configure,</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*5JPat8BpzKg-ijRU.png" /></figure><p><strong>Integration with email Channel</strong></p><ul><li>Click “email” under integrations and give access to authorizations with email.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*KH4Sp1iqKfkgLJkw.png" /></figure><p>Note down the published production key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GQl97edcLBrArLZZ.png" /></figure><h4><strong>Running the Code Locally</strong></h4><ol><li><strong>Install Dependencies</strong></li></ol><pre>npm init -y<br>npm install express @trycourier/courier</pre><p><strong>2. Start the Server</strong></p><pre>node index.js</pre><p><strong>3. Test Locally</strong></p><ul><li>Open a browser at <a href="http://localhost:3000/router1/ping.">http://&lt;Your IP&gt;:3000/router1/ping.</a></li><li>IP(&lt;Your IP&gt;) can be found in the WiFi settings of the current network connected.</li><li>You can use Postman to check the code.</li></ul><p>Run the following to update the recipient email,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHccu_Fe5Y-pWktSzbp2Lg.png" /></figure><p>Run the following to update the time interval(we set it to 10 seconds here),</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksdJlQ7zLR5IgauG-1wUDQ.png" /></figure><p>Run the following to ping,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3AYJnUk495Mgd2zMj0QHUQ.png" /></figure><p>Then after 10 seconds, you will receive an email as below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7OpXjzsTb1iybyfEIpv1Q.png" /></figure><h4><strong>Configuring Teltonica Router</strong></h4><p><strong>Access the Router</strong></p><ul><li>Log in using its local IP address (e.g., 192.168.1.1).</li><li>Login to the router settings</li></ul><p><strong>Go to Auto Reboot / Wget Section</strong></p><ul><li>Go to System -&gt; Maintainance -&gt; AutoReboot</li><li>Provide the URL like <a href="http://your_server_ip:3000/router1/ping">http://&lt;Your Ip&gt;:3000/router1/ping</a> in the Wget settings.</li></ul><p><strong>Set Interval</strong></p><ul><li>Specify how often the router should ping (for example, every 4 or 5 minutes). It should be a value less than the value you set on the API.</li><li>If you set 900000(15 minutes) on the API, you should set like 3/5 minutes on the router.</li><li>Keep the interval count as 1(It does not affect us since we are not doing any action inside the router.)</li></ul><p><strong>Disable Triggered Reboot</strong></p><ul><li>Make sure you don’t enable triggers to reboot.</li></ul><p><strong>Save and Monitor</strong></p><ul><li>The router will regularly call the ping endpoint, and the app will track those pings.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3ZA4UpSTRS9uhnxfgLg4w.png" /></figure><h4><strong>Deploying on Firebase</strong></h4><p><strong>Set Up Firebase</strong></p><ul><li>Create a new Firebase project or use an existing one.</li><li>Install Firebase CLI: (Run these in the terminal)</li></ul><pre>npm install -g firebase-tools</pre><ul><li>and then,</li></ul><pre>firebase login</pre><p><strong>Initialize</strong></p><pre>firebase init functions</pre><ul><li>Choose the project you created.</li></ul><p><strong>Copy Your Code</strong></p><ul><li>Place the code in functions/index.js and replace the <strong>courier Token</strong>.</li><li>Add the following code,</li></ul><pre>//Using Node.js, Express, and Courier on Firebase<br><br>const functions = require(&quot;firebase-functions&quot;);<br>const express = require(&quot;express&quot;);<br>const { CourierClient } = require(&quot;@trycourier/courier&quot;);<br><br>const app = express();<br><br>// Parse JSON in request bodies<br>app.use(express.json());<br><br>// Default configurations<br>let NUM_ROUTERS = 5;<br>let TIME_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes in milliseconds<br><br>// Courier initialization (replace with your token)<br>const courier = new CourierClient({<br>  authorizationToken: &quot;YOUR_COURIER_AUTH_TOKEN_HERE&quot;, // Replace with your Courier token<br>});<br><br>// Track last ping time and timers for each router<br>let routerPingStatus = {};<br>let routerTimers = {};<br><br>// Default email recipient<br>let emailRecipient = &quot;info@example.com&quot;;<br><br>//Helper function to send an email alert<br>async function sendEmail(routerId) {<br>  try {<br>    const { requestId } = await courier.send({<br>      message: {<br>        to: {<br>          email: emailRecipient,<br>        },<br>        content: {<br>          title: `No ping for router ${routerId}`,<br>          body: `No ping received for router ${routerId} in the last ${<br>            TIME_INTERVAL_MS / 60000<br>          } minute(s)!`,<br>        },<br>        routing: {<br>          method: &quot;single&quot;,<br>          channels: [&quot;email&quot;],<br>        },<br>      },<br>    });<br><br>    console.log(&quot;Email sent via Courier, requestId:&quot;, requestId);<br>  } catch (error) {<br>    console.error(&quot;Error sending email via Courier:&quot;, error);<br>  }<br>}<br><br>//Initialize router data structures<br>function initializeRouters(num) {<br>  routerPingStatus = {};<br>  routerTimers = {};<br><br>  for (let i = 1; i &lt;= num; i++) {<br>    routerPingStatus[i] = null; // Last ping timestamp<br>    routerTimers[i] = null;     // setTimeout reference<br>  }<br>}<br><br>//Start the timer for a router<br>function startTimerForRouter(routerId) {<br>  if (routerTimers[routerId]) {<br>    clearTimeout(routerTimers[routerId]);<br>  }<br><br>  routerTimers[routerId] = setTimeout(() =&gt; {<br>    const lastPing = routerPingStatus[routerId];<br>    if (!lastPing || Date.now() - lastPing &gt;= TIME_INTERVAL_MS) {<br>      console.log(<br>        `No ping received for router ${routerId} in the last ${<br>          TIME_INTERVAL_MS / 60000<br>        } minute(s). Sending email.`<br>      );<br>      sendEmail(routerId);<br>    }<br>    routerTimers[routerId] = null;<br>  }, TIME_INTERVAL_MS);<br>}<br><br>//Create router endpoints dynamically<br>function createRouterEndpoints() {<br>  for (let i = 1; i &lt;= NUM_ROUTERS; i++) {<br>    // Health endpoint<br>    app.get(`/router${i}/health`, (req, res) =&gt; {<br>      const routerId = i;<br>      const lastPing = routerPingStatus[routerId];<br>      let secondsSinceLastPing = null;<br><br>      if (lastPing) {<br>        secondsSinceLastPing = Math.floor((Date.now() - lastPing) / 1000);<br>      }<br><br>      return res.status(200).json({<br>        routerId,<br>        status: &quot;healthy&quot;,<br>        lastPing: lastPing ? new Date(lastPing).toISOString() : null,<br>        secondsSinceLastPing,<br>      });<br>    });<br><br>    // Ping endpoint<br>    app.get(`/router${i}/ping`, (req, res) =&gt; {<br>      const routerId = i;<br>      routerPingStatus[routerId] = Date.now();<br><br>      // Restart the timer<br>      startTimerForRouter(routerId);<br><br>      return res.status(200).json({<br>        message: `Ping received for router ${routerId}`,<br>        timestamp: new Date().toISOString(),<br>      });<br>    });<br>  }<br>}<br><br>// Initialize routers and endpoints at startup<br>initializeRouters(NUM_ROUTERS);<br>createRouterEndpoints();<br><br>//Configuration endpoints<br>// Change the number of routers<br>app.post(&quot;/config/num-routers&quot;, (req, res) =&gt; {<br>  const { numRouters } = req.body;<br>  if (!numRouters || typeof numRouters !== &quot;number&quot;) {<br>    return res.status(400).json({<br>      error: &quot;Please provide a valid &#39;numRouters&#39; number&quot;,<br>    });<br>  }<br><br>  NUM_ROUTERS = numRouters;<br>  initializeRouters(NUM_ROUTERS);<br>  createRouterEndpoints();<br><br>  return res.status(200).json({<br>    message: `Number of routers changed to ${NUM_ROUTERS}`,<br>    currentRouters: NUM_ROUTERS,<br>  });<br>});<br><br>// Change the email recipient<br>app.post(&quot;/config/email&quot;, (req, res) =&gt; {<br>  const { recipient } = req.body;<br>  if (!recipient || typeof recipient !== &quot;string&quot;) {<br>    return res.status(400).json({<br>      error: &quot;Please provide a valid &#39;recipient&#39; string&quot;,<br>    });<br>  }<br><br>  emailRecipient = recipient;<br>  return res.status(200).json({<br>    message: &quot;Email recipient updated&quot;,<br>    currentConfig: {<br>      emailRecipient,<br>    },<br>  });<br>});<br><br>// Change the time interval<br>app.post(&quot;/config/time-interval&quot;, (req, res) =&gt; {<br>  const { intervalMs } = req.body;<br>  if (typeof intervalMs !== &quot;number&quot; || intervalMs &lt;= 0) {<br>    return res.status(400).json({<br>      error: &quot;Please provide a valid &#39;intervalMs&#39; (milliseconds) &gt; 0&quot;,<br>    });<br>  }<br><br>  TIME_INTERVAL_MS = intervalMs;<br>  // Reset timers for each router<br>  for (let i = 1; i &lt;= NUM_ROUTERS; i++) {<br>    if (routerTimers[i]) {<br>      clearTimeout(routerTimers[i]);<br>      routerTimers[i] = null;<br>    }<br>    if (routerPingStatus[i] !== null) {<br>      startTimerForRouter(i);<br>    }<br>  }<br><br>  return res.status(200).json({<br>    message: `Time interval changed to ${TIME_INTERVAL_MS} ms`,<br>  });<br>});<br><br>//Export the Express app as a Firebase function<br>exports.app = functions.https.onRequest(app);</pre><p><strong>Deploy</strong></p><pre>firebase deploy - only functions</pre><ul><li>You’ll get a URL for your function, which you can then use instead of <a href="http://localhost:3000.">http://localhost:3000.</a></li></ul><p><strong>Update Teltonica Router</strong></p><ul><li>Replace the ping URL with your Firebase endpoint (e.g., <a href="https://us-central1-your_project.cloudfunctions.net/app/router1/ping).">https://us-central1-YOUR_PROJECT.cloudfunctions.net/app/router1/ping).</a></li></ul><h4><strong>Changing Time Interval, Email, and Number of Routers with Postman</strong></h4><p>Using Postman to dynamically configure your <strong>router connectivity monitoring</strong> is straightforward. Here’s how,</p><ul><li><strong>Change the Number of Routers(Refer the screenshot above)</strong></li></ul><pre>Endpoint: POST /config/num-routers<br><br>Body (JSON): <br><br>{<br>  &quot;numRouters&quot;: 8<br>}</pre><ul><li><strong>Update the Email Recipient(Refer the screenshot above)</strong></li></ul><pre>Endpoint: POST /config/email<br>Body (JSON): <br><br>{<br>  &quot;recipient&quot;: &quot;newemail@example.com&quot;<br>}</pre><ul><li><strong>Modify the Ping Interval(Refer the screenshot above)</strong></li></ul><pre>Endpoint: POST /config/time-interval<br>Body (JSON): <br><br>{<br>  &quot;intervalMs&quot;: 300000<br>}<br><br>(300000 ms = 5 minutes)</pre><ul><li>Make sure the content type is set to <strong>application/json</strong> in your Postman headers.</li><li>If you want to confirm changes, you can also check the server logs or make a GET /routerX/health call to see current states.</li></ul><h3><strong>Conclusion</strong></h3><p>By combining a Teltonica router’s Wget feature with a Node.js server and Courier for email alerts, <strong>router connectivity monitoring</strong> becomes accessible and flexible.</p><p>You can easily expand your monitoring to multiple routers, define how often each router should check in, and adjust the email recipient or time interval whenever you need to.</p><h3>References</h3><ul><li><a href="https://firebase.google.com/docs/functions/get-started">Firebase Cloud Deploying</a></li><li><a href="https://wiki.teltonika-networks.com/">Teltonika Official Documentation</a></li></ul><p><strong>Good Luck with your IoT Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1a23bc9596a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Configuring Teltonika RUTX50: SIM Switching, Email Alerts, and Auto Reboot]]></title>
            <link>https://protonestiot.medium.com/guide-to-configuring-teltonika-rutx50-sim-switching-email-alerts-and-auto-reboot-0d36482b0e3b?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d36482b0e3b</guid>
            <category><![CDATA[email-notifications]]></category>
            <category><![CDATA[router-setup]]></category>
            <category><![CDATA[auto-reboot]]></category>
            <category><![CDATA[sim-switch]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Tue, 11 Feb 2025 09:18:21 GMT</pubDate>
            <atom:updated>2025-02-11T09:18:21.547Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hMK1AXDvpWKbQD92VEG1Q.png" /></figure><p>For IoT projects, routers play a crucial role in ensuring good connectivity. A reliable connection is especially important when developing industrial IoT applications. During one of our projects, we came across Teltonika and had the opportunity to work with the Teltonika RUTX50 Router.</p><p>Official: <a href="https://teltonika-networks.com/products/routers/rutx50">https://teltonika-networks.com/products/routers/rutx50</a></p><p>US :<a href="https://amzn.to/41bemDF"> Amazon</a></p><p>Non US: <a href="https://amzn.to/4jPBVZV">Amazon</a></p><p>We’re excited to share our experience with this powerful and versatile device. In this guide, we will guide you through some applications of Teltonica.</p><h3><strong>The Importance of Teltonika RUTX50 Routers</strong></h3><p>Teltonika’s RUTX50 router is a robust, industrial-grade cellular router designed to provide reliable and secure connectivity for various applications (remote monitoring, IoT systems, enterprise-level networking, etc.).</p><p>Its compact form factor, high-speed 5G/LTE, advanced Wi-Fi, and an array of configurable features make it a versatile option for industries like retail, transportation, energy, and more.</p><h3><strong>Key reasons why RUTX50 routers are important</strong></h3><ul><li><strong>Reliability</strong>: Dual SIM support ensures consistent uptime by automatically switching to a backup SIM if the primary network fails.</li><li><strong>Flexibility</strong>: Multiple WAN interfaces (Ethernet, 5G/LTE) support diverse deployment scenarios.</li><li><strong>Security</strong>: Built-in firewall, VPN capabilities, and remote management options protect your network from threats.</li><li><strong>Scalability</strong>: Easily manage large fleets of routers remotely using Teltonika’s Remote Management System (RMS).</li></ul><h3><strong>Main Features of the RUTX50</strong></h3><ul><li><strong>5G &amp; LTE Connectivity</strong>: High-speed cellular connections with fallback to 4G and 3G if needed.</li><li><strong>Dual SIM</strong>: Automatic failover or backup, ensuring minimal downtime.</li><li><strong>Wi-Fi 6</strong>: Advanced wireless performance for client devices.</li><li><strong>Gigabit Ethernet Ports</strong>: Fast LAN and WAN throughput for bandwidth-intensive environments.</li><li><strong>Advanced Software</strong>: Teltonika’s RutOS with features such as Event Reporting, Auto Reboot, VPN, and customizable firewall rules.</li></ul><h3><strong>Logging into the Router</strong></h3><h4><strong>Physical Setup</strong></h4><ol><li>Insert your active SIM card(s) into the SIM slots.</li><li>Connect the router’s LAN port to your computer if needed.</li><li>Power on the router using the provided power adapter.</li></ol><h4><strong>Accessing the Web Interface</strong></h4><ol><li>Open a web browser on a device connected to the router (via Ethernet or Wi-Fi).</li><li>By default, the router’s LAN IP is usually <strong>192.168.1.1</strong> (check documentation or router label).</li><li>Enter the IP address in your browser’s address bar (e.g., <a href="http://192.168.1.1)./">http://192.168.1.1/login).</a></li><li>Enter your <strong>Username</strong> and <strong>Password</strong> (noted on the router label).</li></ol><h3><strong>Configuring Email Alerts</strong></h3><p>Setting up email alerts allows the router to send notifications for specific events — like reboots, SIM switches, or connection failures.</p><h4><strong>Enable Email Recipient in Administration</strong></h4><ol><li>Go to <strong>System</strong> &gt; <strong>Administration</strong>.</li><li>Click on the <strong>Recipient</strong> or <strong>Email Users</strong> tab (the tab name can vary based on firmware).</li><li>Click on <strong>Add</strong> to configure a new email recipient.</li></ol><figure><img alt="Email setup" src="https://cdn-images-1.medium.com/max/1024/1*VlQtI_SDe1znujO7h7WArg.png" /></figure><h4><strong>Email Configuration</strong></h4><p><strong>Secure Connection</strong>: Turn it <strong>On</strong> (typically TLS/STARTTLS for Gmail).</p><p><strong>SMTP Server</strong>: smtp.gmail.com.</p><p><strong>SMTP Server Port</strong>: <strong>587</strong> (TLS/STARTTLS).</p><p><strong>Credentials</strong>: Turn it <strong>On</strong>.</p><ul><li><strong>Username</strong>: The Gmail address you are using to send the emails.</li><li><strong>Password</strong>: Use an <strong>App Password</strong> created in your Google Account (not your regular Gmail password).</li></ul><p><strong>Sender</strong>: Enter the same Gmail address or an alias if configured.</p><p><strong>Verify Authenticity</strong>: Typically should be ON for security, but if you face issues, you can toggle it <strong>Off</strong>.</p><p>Click <strong>Save</strong>.</p><figure><img alt="Email Setup" src="https://cdn-images-1.medium.com/max/1024/1*-i9etCpBA97enasNWhoVdg.png" /></figure><p>To set up an App Password for Gmail, go to <strong>Manage Google Account</strong> &gt; <strong>Security</strong> &gt; and make sure two-step verification is enabled. (If not, you will not be allowed to create an app password.)</p><p>Type “app passwords” in the search bar and click “App passwords.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K0qT0WAug1PPrY_WAmWheQ.png" /></figure><p>Add a name for the app( eg, “Teltonic Router 1”) and click create.</p><p>Then you will see the app password. Just copy and note it. Click <strong>Done.</strong></p><h3><strong>Setting Up Event Reporting</strong></h3><p>Once your email settings are in place, you can configure the router to send you alerts when certain events occur.</p><p>Go to <strong>Services</strong> &gt; <strong>Events Reporting</strong>.</p><p>Click <strong>Add</strong> to create a new event trigger.</p><figure><img alt="Event Reporting" src="https://cdn-images-1.medium.com/max/1024/1*1wVKCsvvOELCYDmTDsPPHg.png" /></figure><p><strong>Enable Event</strong>: Toggle on.</p><p><strong>Event Type</strong>: e.g., <strong>Reboot</strong>.</p><p><strong>Event Subtype</strong>: (select the specific reboot subtype or other event categories.)</p><p><strong>Action</strong>: Select <strong>Send Email</strong> from the drop-down.</p><p><strong>Subject &amp; Body</strong>: Enter a custom subject and body text for your email alert.</p><p><strong>Sender’s Email Account</strong>: Select the email account you configured previously.</p><p><strong>Add Receiver(s)</strong>: Type in the email address(es) to receive the alert.</p><p>Click <strong>Save</strong>.</p><figure><img alt="Event reporting" src="https://cdn-images-1.medium.com/max/1024/1*98Xv6XAfFR5kmD-qxx6aLA.png" /></figure><h3><strong>Setting Up Auto Reboot</strong></h3><p>This feature allows the router to periodically check a specific host (e.g., 8.8.8.8) and automatically reboot itself if the connection is lost. This is useful in remote locations where manual reboots are impractical.</p><p>Go to <strong>System</strong> &gt; <strong>Maintenance</strong> &gt; <strong>Auto Reboot</strong>.</p><p>Click <strong>Add</strong> to set up a new rule.</p><figure><img alt="Auto Reboot" src="https://cdn-images-1.medium.com/max/1024/1*qSeOZoVnTw00OPYLsK3bVg.png" /></figure><p><strong>Enable</strong>: Toggle on.</p><p><strong>Type</strong>: Select <strong>Ping</strong>.</p><p><strong>Action if no echo is received</strong>: <strong>Device Reboot</strong>.</p><p><strong>Interval</strong>: How often the router pings the host (e.g., <strong>5 minutes</strong>).</p><p><strong>Interval Count</strong>: After how many failures the action is triggered (e.g., fail 5 consecutive times before rebooting).</p><p><strong>Timeout (sec)</strong>: 5 (the router will wait 5 seconds for a reply).</p><p><strong>Packet Size</strong>: 56 bytes (standard size).</p><p><strong>Interface</strong>: Select your WAN or let it set <strong>Automatically</strong> if you are unsure.</p><p><strong>IP Type</strong>: IPV4.</p><p><strong>Action Condition</strong>: <strong>When all requests fail</strong> (ensures it only reboots if every ping fails).</p><p><strong>Host to Ping</strong>: 8.8.8.8 (Google DNS).</p><p>Click <strong>Save</strong>.</p><figure><img alt="Auto Reboot" src="https://cdn-images-1.medium.com/max/1024/1*2t0yetYDbpG3JcCilvFhlw.png" /></figure><h3>Cloud-Based Monitoring for Teltonika RUTX50: Backend Server for Email Alerts on Connection Loss</h3><p>In some cases, you may need to receive an email notification when the router loses connection, but the built-in email alert system might not work due to the lack of an internet connection.</p><p>A practical solution is to set up a <strong>backend server</strong> hosted in the cloud to monitor the router’s connectivity and send alerts when the connection is lost.</p><h4>How It Works</h4><ul><li>The router is configured to <strong>ping</strong> a backend server at regular intervals. Use another event in auto reboot for the task</li><li>If the backend <strong>stops receiving pings</strong> for a predefined duration (e.g., 5 or 10 minutes), it assumes the router has lost connectivity.</li><li>The backend then triggers an <strong>email alert</strong> to notify the user about the downtime.</li></ul><h4>Why Use This Approach?</h4><ul><li><strong>Reliable Alerting</strong>: Since the email is sent from a cloud-hosted backend rather than the router, it works even when the router is completely offline.</li><li><strong>Scalability</strong>: This method can be extended to monitor multiple routers and provide a centralized monitoring solution.</li></ul><h3><strong>Configuring SIM Switching</strong></h3><p>Dual SIM functionality ensures network redundancy by automatically switching to a secondary SIM if the primary SIM loses connectivity or meets custom failover criteria.</p><p>Go to <strong>Network</strong> &gt; <strong>Mobile</strong> &gt; <strong>SIM Switch</strong> (menu options may vary slightly by firmware).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ON4WATwB-ktt2X3jtRos9Q.png" /></figure><p>Arrange <strong>Priority</strong> by dragging SIM1 or SIM2 if needed (SIM1 is typically the default primary).</p><p><strong>Add</strong> a new rule or modify the existing rule.</p><p><strong>Enable</strong> the feature and set the monitoring intervals (e.g., check every 5 minutes, switch after X failures).</p><p><strong>Method</strong>: Choose <strong>LCP echo</strong> or <strong>Ping</strong> (LCP echo is usually the default for mobile connections).</p><p><strong>Enable</strong> conditions such as <strong>No Network</strong> or <strong>Data Connection Fail</strong>.</p><p>Repeat steps as necessary for both SIM cards.</p><p>Click <strong>Save</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmK4n7DKKeB-3Vb-P2NdGg.png" /></figure><h3><strong>Final Checks &amp; Troubleshooting</strong></h3><ul><li><strong>Test Email Alerts</strong>: Go back to your <strong>System</strong> &gt; <strong>Administration</strong> page and look for a <strong>Test Email</strong> or <strong>Send Test</strong> button to confirm your email settings are correct.</li><li><strong>Check Logs</strong>: If alerts are not received, check the <strong>System Logs</strong> or <strong>Events Logs</strong> for errors related to email sending or event triggers.</li><li><strong>Monitor Connectivity</strong>: Ensure your ping-based Auto Reboot and SIM Switch settings work as expected by simulating a network failure.</li><li><strong>Keep Firmware Updated</strong>: Teltonika periodically releases firmware updates that add features and fix bugs, so ensure your RUTX50 is running the latest stable version.</li></ul><h3><strong>Conclusion</strong></h3><p>By following the steps above, you can configure the Teltonika RUTX50 router to:</p><ul><li><strong>Send Email Alerts</strong> for various system events (like reboots or SIM switches).</li><li><strong>Automatically Reboot</strong> if the connection to the internet fails.</li><li><strong>Switch SIM Cards</strong> to maintain connectivity when your primary SIM fails.</li></ul><p>These features help ensure maximum uptime, provide timely notifications for network changes, and reduce the need for manual interventions.</p><p>With its industrial-grade reliability and robust firmware features, the RUTX50 is an excellent choice for businesses and organizations that demand consistent and secure connectivity in mission-critical scenarios.</p><h3><strong>Additional Resources</strong></h3><ul><li><a href="https://wiki.teltonika-networks.com/">Teltonika Official Documentation</a></li><li><a href="https://wiki.teltonika-networks.com/view/RUTX50_Firmware">Firmware Upgrade Guide for RUTX50</a></li><li><a href="https://rms.teltonika-networks.com/">Teltonika RMS (Remote Management System)</a></li></ul><p><strong>Good Luck with your IoT Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d36482b0e3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a Twilio Account and Sending SMS Messages with Render Hosting]]></title>
            <link>https://protonestiot.medium.com/setting-up-a-twilio-account-and-sending-sms-messages-with-render-hosting-06c94189ef09?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/06c94189ef09</guid>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[sms-gateway]]></category>
            <category><![CDATA[render-hosting]]></category>
            <category><![CDATA[sms-api]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 05:54:40 GMT</pubDate>
            <atom:updated>2025-01-26T05:54:40.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lccKPaHCZoiEWng70QwBow.png" /></figure><p>We were searching for a platform that can be used for sending sms internationally, and we found Twilio, which offers many benefits. And also, it is easier to integrate with so many resources on the Internet.</p><p>After that, we are guiding through to making a custom Nodejs script to send sms and deploying the app in render.</p><p><a href="https://www.twilio.com/">Twilio</a> is a cloud communications platform that makes it easy to programmatically send and receive SMS, voice calls, and other communication channels using web service APIs. With Twilio,</p><ul><li>You can sign up for a <strong>free trial</strong> without a credit card.(Limit of 15 USD)</li><li>Pay only for what you use (pay-as-you-go).</li><li>Access various channels like SMS, Voice, WhatsApp, Email, Video, etc.</li></ul><h4><strong>Key Twilio Advantages</strong></h4><ul><li><strong>99.95% uptime SLA</strong> and automated failover.</li><li><strong>Scalable</strong> across global markets.</li><li><strong>Multiple communication channels</strong> from one platform.</li><li><strong>No contracts</strong>: pay as you go, with discounts available at scale.</li></ul><p>Typically, sending sms from the US costs only 0.0079 USD. It varies from country to country.</p><h4><strong>Twilio Pricing Overview(As at 22/01/2025)</strong></h4><p>Twilio’s pricing is usage-based. For SMS, it <strong>starts at $0.0079 per text message</strong> to send or receive. Other channels and features (like WhatsApp, Voice, SendGrid Email, etc.) have their own pricing, but to focus on SMS,</p><ul><li><strong>SMS</strong><br><em>Starts at $0.0079 to send or receive a message.</em></li><li><strong>WhatsApp Business API</strong><br><em>Starts at $0.005 per message.</em></li><li><strong>Voice</strong><br><em>Starts at $0.0085/min to receive and $0.014/min to make a call.</em></li><li><strong>Email (SendGrid)</strong><br><em>Free for up to 100 emails/day; paid plans start at $19.95/month.</em></li></ul><p>You can refer their pricing at: <a href="https://www.twilio.com/en-us/sms/pricing/us">https://www.twilio.com/en-us/sms/pricing/us</a></p><h4><strong>Free Trial Note(Without the credit card info)</strong></h4><ul><li>On the free trial, you can <strong>only send SMS to verified phone numbers</strong> (including the one you used to sign up).</li><li>You also receive a small credit to experiment. Once you upgrade (by adding a payment method), you can send to any phone number.</li><li>Trial messages include “Sent from your Twilio trial account” by default.</li></ul><h3><strong>Create a Twilio Account</strong></h3><p>Now, let’s create a Twilio account,</p><h4><strong>Sign Up</strong></h4><ul><li>Go to <a href="https://www.twilio.com/try-twilio">Twilio</a> and click <strong>Sign up</strong>.</li><li>You can sign up with your email or use a social provider (e.g., GitHub, Google).</li></ul><h4><strong>Free Trial</strong></h4><ul><li>You do not need to add a credit card initially.</li><li>Twilio will provide you with <strong>trial credits</strong> to test sending SMS.</li><li>By default, you can send messages to your <strong>own verified number</strong> without additional charges.</li><li>If you want to send SMS to <strong>unverified numbers</strong>, you must upgrade your account by adding a billing method.</li></ul><h4><strong>Verify Your Phone Number</strong></h4><ul><li>During sign-up, Twilio will ask you to verify your mobile number.</li><li>Once verified, you can send messages to this number using your Twilio trial credits.</li></ul><h3><strong>Get a Twilio Phone Number</strong></h3><h4><strong>Navigate to the Console</strong></h4><ul><li>After logging in, you’ll land on your <a href="https://www.twilio.com/console">Twilio Console</a>.</li></ul><h4><strong>Phone Numbers</strong></h4><ul><li>Click on <strong>Phone Numbers</strong> in the left-hand menu.</li><li>Select <strong>Manage</strong> → <strong>Buy a Number</strong> (for the trial, Twilio often prompts you to choose a free number).</li></ul><h4><strong>Choose Your Number</strong></h4><ul><li>This number is now your Twilio number, which you can use to send and receive SMS.</li></ul><h3><strong>Retrieve Your Account SID and Auth Token</strong></h3><h4><strong>Go to Your Console Dashboard</strong></h4><ul><li>In the <a href="https://www.twilio.com/console">Twilio Console</a>, look for the <strong>Project Info</strong> section.</li></ul><h4><strong>Copy the Credentials</strong></h4><ul><li>You’ll see your <strong>Account SID</strong> and <strong>Auth Token</strong>.</li><li>Keep your <strong>Auth Token</strong> private and never commit it to a public repository.</li></ul><h4><strong>Environment Configuration</strong></h4><ul><li>In your backend code or hosting environment (such as Render), you’ll reference these credentials as environment variables.</li></ul><p>The below image shows where you can find the Auth token, SID, and twilio phone number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*yAdwwcEpVUoBEPJs2XIIIw.png" /></figure><h3>Start working on your SMS sending code in Nodejs</h3><p>Here’s a Node.js example using the official twilio npm package,</p><h4><strong>Initialize a Node.js Project</strong></h4><p>Open a terminal and add the following commads,</p><pre>cd Documents<br>mkdir twilio-sms-demo<br>cd twilio-sms-demo<br>npm init -y<br>npm install twilio</pre><h4><strong>Create an index.js File</strong></h4><p>Open a new file in visual studio code and then add the following code,</p><pre>/* eslint-disable max-len */<br>const express = require(&quot;express&quot;);<br>const twilio = require(&quot;twilio&quot;);<br><br>// Initialize Express<br>const app = express();<br><br>// Middleware to parse JSON<br>app.use(express.json());<br><br>// Twilio setup<br>const accountSid = process.env.TWILIO_ACCOUNT_SID;<br>const authToken = process.env.TWILIO_AUTH_TOKEN;<br>const twilioPhoneNumber = process.env.TWILIO_PHONE_NUMBER;<br>const twilioClient = twilio(accountSid, authToken);<br><br>// Endpoint to send SMS<br>app.post(&quot;/send-sms&quot;, async (req, res) =&gt; {<br>  const { phoneNumber, message } = req.body;<br><br>  if (!phoneNumber || !message) {<br>    return res.status(400).json({<br>      error: &quot;Both &#39;phoneNumber&#39; and &#39;message&#39; fields are required.&quot;,<br>    });<br>  }<br><br>  try {<br>    const sms = await twilioClient.messages.create({<br>      body: message,<br>      from: twilioPhoneNumber,<br>      to: phoneNumber,<br>    });<br>    return res.status(200).json({<br>      message: &quot;SMS sent successfully&quot;,<br>      sid: sms.sid,<br>    });<br>  } catch (error) {<br>    console.error(&quot;Error sending SMS:&quot;, error.message);<br>    return res.status(500).json({<br>      error: &quot;Failed to send SMS&quot;,<br>      details: error.message,<br>    });<br>  }<br>});<br><br>// Start the server<br>const PORT = process.env.PORT || 3000;<br>app.listen(PORT, () =&gt; console.log(`Server running on port ${PORT}`));</pre><p>Save the file as<strong> index.js</strong> in <strong>twilio-sms-demo</strong> folder.</p><p>Create a file named <strong>.env</strong>,</p><pre>TWILIO_ACCOUNT_SID=&lt;Your Account SID&gt;<br>TWILIO_AUTH_TOKEN=&lt;Your Auth Token&gt;<br>TWILIO_PHONE_NUMBER=&lt;Your Twilio Phone Number&gt;</pre><p>Change the SID, authtoken and phone number with the noted info from Twilio console.</p><p>Then run the following command,</p><pre>node index.js</pre><p>If your trial account and environment variables are set correctly, run the API on Postman and as given at the end of the article.</p><h3><strong>Push Your Code to GitHub</strong></h3><ul><li>Login to GitHub or create an account through the link,</li></ul><p><a href="https://github.com/">GitHub · Change is constant. GitHub keeps you ahead. · GitHub</a></p><ul><li>Create a new repo in github and copy the link</li><li>Initialize Git</li></ul><pre>git init<br>git add .<br>git commit -m &quot;Initial commit&quot;</pre><ul><li>Add Remote Repository</li></ul><pre>git remote add origin https://github.com/&lt;your-username&gt;/&lt;your-repo&gt;.git</pre><ul><li>Push to GitHub</li></ul><pre>git push -u origin main</pre><h3>Deploy on Render</h3><p><a href="https://render.com/">Render</a> is a modern hosting platform that lets you deploy full-stack applications easily, often within the <strong>free tier </strong>constraints for small projects.</p><h4><strong>Sign in to Render</strong></h4><ul><li>Go to <a href="https://dashboard.render.com/">Render Dashboard</a> and create an account if you haven’t already.</li></ul><h4><strong>Create a New Web Service</strong></h4><ul><li>Click <strong>New</strong> → <strong>Web Service</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UOqvdQCoHkMaWutQqj7hDA.png" /></figure><ul><li>Connect your GitHub account and <strong>select your repository</strong> with the Twilio code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDFDu7xYWS5XYK7dMv3q5g.png" /></figure><ul><li>Click “connect”</li></ul><h4><strong>Choose a Plan</strong></h4><ul><li>Render has a <strong>free plan</strong> with 750 hours of server runtime per month and auto-sleep after 15 minutes of inactivity.</li><li>When the service is inactive, it will restart within ~50 seconds on the next request.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-582XcQ6mY4wxnvJARKGQ.png" /></figure><h4><strong>Add Environment Variables</strong></h4><ul><li>On Render, find the <strong>Environment</strong> section and add the following,</li></ul><pre>TWILIO_ACCOUNT_SID=&lt;Your Twilio Account SID&gt;<br>TWILIO_AUTH_TOKEN=&lt;Your Twilio Auth Token&gt;<br>TWILIO_PHONE_NUMBER=&lt;Your Twilio Number&gt;</pre><ul><li>Click “<strong>Add Variables”</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ysD7dSGE5wIVrklLg1amg.png" /></figure><h4><strong>Deploy</strong></h4><ul><li>Click <strong>Deploy Web Service</strong>.</li><li>For the free plan, you’ll be asked to add a <strong>credit card</strong> for verification.</li><li>You won’t be charged unless you exceed the free plan limits.</li></ul><p><strong>Note</strong>: Once your service is deployed, you can trigger your code to send an SMS with the API.</p><h3>Usage with Postman</h3><p>Once deployed, Render provides a public URL (e.g., <a href="https://your-app.onrender.com)./">https://your-app.onrender.com)</a></p><ul><li>Note the URL</li><li>Set Postman to send a test request,</li></ul><pre>HTTP Method: POST<br>URL: https://your-app.onrender.com/send-sms<br>Headers: <br>     Content-Type: application/json</pre><ul><li>Body,</li></ul><pre>{<br>  &quot;phoneNumber&quot;: &quot;+1234567890&quot;,<br>  &quot;message&quot;: &quot;Hello, this is a test message from Twilio!&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xpEPvnoNg3HQznbJNs0IQ.png" /></figure><h4>Expected Responses</h4><p><strong>Success</strong></p><pre>{<br>   &quot;message&quot;: &quot;SMS sent successfully&quot;,<br>   &quot;sid&quot;: &quot;SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;<br>}</pre><p>Error</p><pre>{<br>  &quot;error&quot;: &quot;Failed to send SMS&quot;,<br>  &quot;details&quot;: &quot;&lt;Error info&gt;&quot;<br>}</pre><h3><strong>Sending SMS Beyond Your Verified Number</strong></h3><ul><li><strong>Trial Limitations</strong>: By default, you can only send messages to phone numbers you have verified in Twilio.</li><li><strong>Upgrade</strong>: To send SMS messages to <strong>any</strong> phone number, upgrade your account by adding your payment details in the Twilio Console.</li><li><strong>Costs</strong>: Twilio will charge you according to the pay-as-you-go SMS rate (starting at $0.0079/message in the US).</li></ul><h3><strong>Best Practices</strong></h3><h4><strong>Use Environment Variables</strong></h4><ul><li>Always store secret credentials (Auth Token, API keys) as environment variables, never hard-code them.</li></ul><h4><strong>Monitor Usage</strong></h4><ul><li>Twilio provides a usage dashboard to track your spending, so you don’t exceed budgets or run out of credits unexpectedly.</li></ul><p>Twilio’s “pay as you go” model combined with Render’s free tier is an affordable way to build and scale your communication workflows. As you grow, Twilio offers volume discounts and additional channels to help you reach your users on their preferred messaging platform.</p><p><strong>Ready to scale?</strong> Upgrade your Twilio and Render plans as needed, and incorporate other Twilio services (Voice, Email, WhatsApp, etc.) into your application for a richer customer experience.</p><p><strong>Good Luck with your Project!</strong></p><p>If you have questions or need assistance, contact support at info@protonest.co.</p><p>Ready to start your IoT journey? Visit Protonest’s IoT System Design Tool which will guide you through the complete process of IoT system development.</p><p><a href="https://iot-system-design-tool.protonest.co/">https://iot-system-design-tool.protonest.co/</a></p><p><strong>Contact us for any consultations or projects related to IoT and embedded systems.</strong></p><p>Email: info@protonest.co</p><p><a href="https://www.protonest.co/">Protonest</a> for more details.</p><p>Protonest specializes in transforming IoT ideas into reality. We offer prototyping services from concept to completion. Our commitment ensures that your visionary IoT concepts become tangible, innovative, and advanced prototypes.</p><p>For more details: <a href="https://www.protonest.co/">https://www.protonest.co/</a></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06c94189ef09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Secure Motion-Detecting System with Email Alerts for Under $20]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://protonestiot.medium.com/build-a-secure-motion-detecting-system-with-email-alerts-for-under-20-79ca1ff2f7e7?source=rss-f3bc7e6b1fdb------2"><img src="https://cdn-images-1.medium.com/max/1280/1*XBz26GodL175Jisl7MyfHA.png" width="1280"></a></p><p class="medium-feed-snippet">In the current world, security is a top priority. So having a motion detection system is crucial to detecting a motion and informing the&#x2026;</p><p class="medium-feed-link"><a href="https://protonestiot.medium.com/build-a-secure-motion-detecting-system-with-email-alerts-for-under-20-79ca1ff2f7e7?source=rss-f3bc7e6b1fdb------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://protonestiot.medium.com/build-a-secure-motion-detecting-system-with-email-alerts-for-under-20-79ca1ff2f7e7?source=rss-f3bc7e6b1fdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/79ca1ff2f7e7</guid>
            <category><![CDATA[email-alert]]></category>
            <category><![CDATA[iot-platform]]></category>
            <category><![CDATA[firebase-cloud-functions]]></category>
            <category><![CDATA[esp32-tutorial]]></category>
            <category><![CDATA[motion-detection]]></category>
            <dc:creator><![CDATA[Protonest IoT]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 07:25:05 GMT</pubDate>
            <atom:updated>2025-01-20T07:25:05.723Z</atom:updated>
        </item>
    </channel>
</rss>