<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Play with Circuit</title>
    <description>The latest articles on DEV Community by Play with Circuit (@play_withcircuit_241ef87).</description>
    <link>https://dev.to/play_withcircuit_241ef87</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3015801%2Fb43108d4-24c1-491c-9ced-9c27b9020370.jpg</url>
      <title>DEV Community: Play with Circuit</title>
      <link>https://dev.to/play_withcircuit_241ef87</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/play_withcircuit_241ef87"/>
    <language>en</language>
    <item>
      <title>How to Interface the Reyax RYLR999 LoRa Module with Arduino</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Tue, 25 Aug 2026 08:34:01 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/how-to-interface-the-reyax-rylr999-lora-module-with-arduino-k21</link>
      <guid>https://dev.to/play_withcircuit_241ef87/how-to-interface-the-reyax-rylr999-lora-module-with-arduino-k21</guid>
      <description>&lt;p&gt;Long-range wireless communication is an important part of modern IoT systems, particularly when connected devices need to exchange small amounts of data over large distances while operating with limited power. Technologies such as Wi-Fi and Bluetooth are convenient for short-range communication, while cellular networks provide wide coverage but generally involve higher power consumption and operating costs.&lt;/p&gt;

&lt;p&gt;LoRa is designed to address this gap. It provides long-distance wireless communication with relatively low power requirements, making it well suited for applications such as environmental monitoring, agriculture, industrial sensing, remote control, and other IoT projects.&lt;/p&gt;

&lt;p&gt;In this project, we explore the Reyax RYLR999 LoRa module and its interface with an Arduino UNO. The setup demonstrates a simple two-way LoRa communication link in which one Arduino acts as the initiator and another works as the responder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;The basic idea is to establish point-to-point communication between two RYLR999 modules connected to separate Arduino UNO boards.&lt;/p&gt;

&lt;p&gt;The first Arduino works as the &lt;strong&gt;initiator&lt;/strong&gt;. It periodically sends the message &lt;strong&gt;“Are you there?”&lt;/strong&gt; through its RYLR999 module. The second Arduino acts as the &lt;strong&gt;responder&lt;/strong&gt;, listening for the incoming LoRa message and returning &lt;strong&gt;“Yes”&lt;/strong&gt; when the request is received.&lt;/p&gt;

&lt;p&gt;This simple exchange provides a practical way to understand how the RYLR999 communicates with a microcontroller through UART and how AT commands can be used to control LoRa transmission and reception.&lt;/p&gt;

&lt;p&gt;The project also demonstrates the difference between the two sides of a wireless communication link: one device generates and transmits the request, while the other receives the request and sends a response.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is LoRa?
&lt;/h2&gt;

&lt;p&gt;LoRa stands for &lt;strong&gt;Long Range&lt;/strong&gt; and is a wireless communication technology developed by Semtech. It is intended primarily for applications where devices need to transmit relatively small amounts of information over considerably longer distances than conventional short-range wireless technologies.&lt;/p&gt;

&lt;p&gt;LoRa is particularly useful for IoT devices because many IoT nodes send only small packets of information.&lt;/p&gt;

&lt;p&gt;Depending on environmental and radio conditions, LoRa communication can typically reach approximately &lt;strong&gt;15 to 20 km in open environments&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;LoRa commonly operates in license-free ISM frequency bands such as &lt;strong&gt;433 MHz, 868 MHz, and 915 MHz&lt;/strong&gt;. It can also operate in the &lt;strong&gt;2.4 GHz&lt;/strong&gt; band for applications requiring higher data rates, although communication range is generally reduced at this frequency.&lt;/p&gt;

&lt;p&gt;An important characteristic of LoRa is the balance it provides between communication range, data rate, and power consumption. It is therefore better suited to small, infrequent data packets than to applications that continuously transfer large amounts of information.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does LoRa Technology Work?
&lt;/h2&gt;

&lt;p&gt;LoRa operates at the physical layer of wireless communication and defines how information is converted into a radio signal for transmission.&lt;/p&gt;

&lt;p&gt;When a microcontroller needs to send information, the digital data is passed to the LoRa transceiver. The radio then uses &lt;strong&gt;Chirp Spread Spectrum (CSS)&lt;/strong&gt; modulation to encode the information into frequency-swept chirp signals.&lt;/p&gt;

&lt;p&gt;These chirps spread the transmitted information across a wider bandwidth. This improves receiver sensitivity and helps the system operate in the presence of noise and interference.&lt;/p&gt;

&lt;p&gt;One of the major advantages of this approach is that a LoRa receiver can detect relatively weak signals. This contributes to the technology's long communication range while allowing the radio to operate at comparatively low power.&lt;/p&gt;

&lt;p&gt;At the receiving end, the LoRa transceiver demodulates the incoming chirp signal and converts it back into digital information. The resulting data is then made available to the connected microcontroller through the module's UART interface.&lt;/p&gt;

&lt;p&gt;LoRa generally works with &lt;strong&gt;low data rates&lt;/strong&gt; and is intended for small packets rather than continuous high-bandwidth communication. This makes it practical for battery-operated devices that can remain in a low-power state between transmissions.&lt;/p&gt;

&lt;p&gt;It is important to distinguish &lt;strong&gt;LoRa&lt;/strong&gt; from &lt;strong&gt;LoRaWAN&lt;/strong&gt;. LoRa describes the radio communication technology at the physical layer, while LoRaWAN is a higher-level networking protocol designed for connecting LoRa devices to wider networks and infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where LoRa Is Used
&lt;/h3&gt;

&lt;p&gt;LoRa is a good choice when the application needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long-distance communication&lt;/li&gt;
&lt;li&gt;Low power consumption&lt;/li&gt;
&lt;li&gt;Small amounts of transmitted data&lt;/li&gt;
&lt;li&gt;Battery-operated sensor nodes&lt;/li&gt;
&lt;li&gt;Wireless communication in areas without conventional network infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not intended for applications such as video streaming, audio transmission, or transferring large files because its data rate is comparatively low.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to the RYLR999 Module
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;RYLR999 Lite&lt;/strong&gt; is a long-range wireless communication module developed by REYAX Technology. The module combines &lt;strong&gt;868/915 MHz LoRa communication&lt;/strong&gt; with &lt;strong&gt;2.4 GHz Bluetooth Low Energy (BLE)&lt;/strong&gt; capabilities in a compact transceiver.&lt;/p&gt;

&lt;p&gt;A notable feature of the RYLR999 is that it provides separate UART interfaces for its BLE and LoRa functions. This allows the two wireless communication paths to be handled independently.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;BLE UART interface&lt;/strong&gt; is used for exchanging information with devices such as smartphones, BLE-enabled systems, or compatible microcontrollers. The &lt;strong&gt;LoRa UART interface&lt;/strong&gt;, meanwhile, handles LoRa-related data transmission and reception.&lt;/p&gt;

&lt;p&gt;The module can be configured through &lt;strong&gt;AT commands&lt;/strong&gt;. Parameters such as LoRa addresses, network IDs, operating frequency, and modulation settings can be configured according to the requirements of the application.&lt;/p&gt;

&lt;p&gt;When a transmission command is issued, the module processes the supplied data and sends it wirelessly using LoRa's CSS-based modulation. Another compatible RYLR999 module can receive the transmitted packet and make the received information available through its UART interface.&lt;/p&gt;

&lt;p&gt;Another useful capability of the RYLR999 is its potential to operate as a &lt;strong&gt;BLE-to-LoRa bridge&lt;/strong&gt;. In this type of application, a nearby BLE device can communicate with the module, while the RYLR999 forwards the information through a long-range LoRa connection. This effectively extends the communication reach of a device that would normally be restricted to short-range BLE communication.&lt;/p&gt;

&lt;h2&gt;
  
  
  RYLR999 Pinout
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1pwomsgy1kze5pvewzgl.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1pwomsgy1kze5pvewzgl.PNG" alt=" " width="460" height="540"&gt;&lt;/a&gt;&lt;br&gt;
Understanding the module's pin functions is important because the RYLR999 uses separate UART connections for its BLE and LoRa interfaces.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;VDD (Pin 1):&lt;/strong&gt; This is the module's power supply pin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RST (Pin 2):&lt;/strong&gt; This is the reset input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TXD_BLE (Pin 3):&lt;/strong&gt; This pin functions as the BLE UART transmit output. It is particularly relevant when the module is being used for BLE-to-LoRa bridging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RXD_LoRa (Pin 4):&lt;/strong&gt; This is the receiving input of the LoRa UART interface. AT commands and LoRa-related instructions from a microcontroller, PC terminal, or BLE subsystem are supplied through this pin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TXD_LoRa (Pin 5):&lt;/strong&gt; This is the transmit output of the LoRa UART interface. Received LoRa data and status information are provided through this pin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RXD_BLE (Pin 6):&lt;/strong&gt; This pin receives data intended for the BLE subsystem. Commands or information that need to be sent to the BLE section from a microcontroller or PC are supplied through this pin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GND (Pin 7):&lt;/strong&gt; This is the ground connection.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Interfacing RYLR999 with Arduino UNO
&lt;/h2&gt;

&lt;p&gt;The RYLR999 can be connected to an Arduino UNO to create a simple point-to-point LoRa communication system. In the proposed arrangement, two Arduino UNO boards are used, with each board connected to one RYLR999 module.&lt;/p&gt;

&lt;p&gt;The initiator Arduino is responsible for generating the communication request and sending it through its LoRa module. The responder Arduino remains ready to receive the message and sends a response when the expected request arrives.&lt;/p&gt;

&lt;p&gt;The RYLR999 communicates with the Arduino through its LoRa UART interface. Since the RYLR999's digital I/O operates at 3.3 V logic levels, the UART connection requires appropriate voltage-level conversion when interfacing it with the Arduino UNO's 5 V logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initiator Wiring Concept
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ck215ustx4vbnakqmvk.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3ck215ustx4vbnakqmvk.PNG" alt=" " width="748" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the initiator side, the Arduino UNO sends LoRa commands to the RYLR999 and can display the communication status on a 16×2 I2C LCD.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;VDD pin of the RYLR999 is connected to the 5V output of the Arduino UNO&lt;/strong&gt;, while the &lt;strong&gt;GND pin is connected to the Arduino GND&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For UART communication, the &lt;strong&gt;TXD_LoRa pin of the RYLR999 is connected to the LV1 pin of the voltage shifter&lt;/strong&gt;, and the corresponding &lt;strong&gt;HV1 output is connected to the Arduino Rx pin&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In the opposite direction, the &lt;strong&gt;TX pin of the Arduino is connected to the HV2 pin of the voltage shifter&lt;/strong&gt;, while the corresponding &lt;strong&gt;LV2 output is connected to the RXD_LoRa pin of the RYLR999&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The voltage shifter also requires its power-side connections. The &lt;strong&gt;5V pin of the Arduino is connected to the HV pin of the voltage shifter&lt;/strong&gt;, while the &lt;strong&gt;3.3V pin of the Arduino is connected to the LV pin&lt;/strong&gt;. These connections allow the voltage-level converter to operate correctly.&lt;/p&gt;

&lt;p&gt;The Arduino UNO and RYLR999 LoRa UART connections can therefore be summarized as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO 5V → RYLR999 VDD&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO GND → RYLR999 GND&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO Rx → RYLR999 TXD_LoRa through the voltage shifter&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO Tx → RYLR999 RXD_LoRa through the voltage shifter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  I2C LCD Connection
&lt;/h3&gt;

&lt;p&gt;The initiator setup can also use a 16×2 I2C LCD to display communication information.&lt;/p&gt;

&lt;p&gt;The LCD &lt;strong&gt;VCC and GND&lt;/strong&gt; connections are connected to the corresponding Arduino power and ground pins. The LCD's &lt;strong&gt;SCL and SDA&lt;/strong&gt; lines are connected to the Arduino's I2C pins.&lt;/p&gt;

&lt;p&gt;On the Arduino UNO, the I2C lines correspond to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SCL → A5&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SDA → A4&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LCD address configuration is also relevant. When using the address &lt;strong&gt;0x27&lt;/strong&gt;, the &lt;strong&gt;A0, A1, and A2 address jumpers should not be shorted&lt;/strong&gt;. These jumpers influence the I2C address of the display, so their configuration should match the address used by the software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Responder Wiring Concept
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj56lhnd0vm01tyoff2r6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj56lhnd0vm01tyoff2r6.PNG" alt=" " width="716" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The responder side follows the same basic RYLR999-to-Arduino UART arrangement but does not require the LCD.&lt;/p&gt;

&lt;p&gt;The responder Arduino continuously monitors the LoRa UART interface for incoming communication from the initiator. When the expected request is received, the Arduino processes it and sends the appropriate response through its RYLR999 module.&lt;/p&gt;

&lt;p&gt;The main wiring between the Arduino UNO and RYLR999 therefore remains the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO 5V → RYLR999 VDD&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO GND → RYLR999 GND&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO Rx → RYLR999 TXD_LoRa through the voltage shifter&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arduino UNO Tx → RYLR999 RXD_LoRa through the voltage shifter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The primary difference between the two configurations is that the initiator includes the I2C LCD for displaying communication information, whereas the responder operates without the display.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Communication Flow
&lt;/h2&gt;

&lt;p&gt;The complete communication sequence can be understood as a simple request-and-response cycle.&lt;/p&gt;

&lt;p&gt;First, the initiator Arduino sends an AT command to its RYLR999 module instructing it to transmit the required message. The module converts the data into a LoRa radio signal and broadcasts it to the receiving RYLR999.&lt;/p&gt;

&lt;p&gt;The responder module receives the LoRa packet and forwards the resulting data to its Arduino through the LoRa UART interface.&lt;/p&gt;

&lt;p&gt;After identifying the incoming request, the responder Arduino instructs its RYLR999 to transmit a reply. The second module then sends the response wirelessly back to the initiator.&lt;/p&gt;

&lt;p&gt;The initiator's RYLR999 receives the response and makes the received information available to the Arduino through TXD_LoRa. This completes the two-way communication cycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Considerations
&lt;/h2&gt;

&lt;p&gt;When working with the RYLR999, the power supply and logic-level requirements should be considered carefully. Although the module requires a 5 V supply within the specified range, its digital I/O uses &lt;strong&gt;3.3 V logic levels&lt;/strong&gt;. Appropriate voltage-level conversion should therefore be used for UART communication with the Arduino UNO.&lt;/p&gt;

&lt;p&gt;The RYLR999 can operate at relatively high LoRa transmit power, with the specified maximum output reaching &lt;strong&gt;+30 dBm (1 Watt)&lt;/strong&gt;. The antenna and RF implementation should therefore follow the module manufacturer's recommendations.&lt;/p&gt;

&lt;p&gt;LoRa's long range should also not be interpreted as unlimited bandwidth. The technology is optimized for small data packets and long-distance communication rather than high-speed data transfer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The RYLR999 provides a practical way to add long-range wireless communication to Arduino-based projects. Its LoRa interface allows small packets of information to travel significantly farther than conventional short-range wireless technologies, while its BLE functionality adds another communication option within the same module.&lt;/p&gt;

&lt;p&gt;By connecting two RYLR999 modules to separate Arduino UNO boards, it is possible to create a straightforward point-to-point communication system. The initiator can send a request such as &lt;strong&gt;“Are you there?”&lt;/strong&gt;, while the responder can return &lt;strong&gt;“Yes”&lt;/strong&gt;, demonstrating the basic principles of LoRa data transmission and reception.&lt;/p&gt;

&lt;p&gt;The module's UART interface, AT-command configuration, long-range capability, and BLE-to-LoRa functionality make the RYLR999 useful for a variety of IoT, sensor, automation, and remote-monitoring applications where reliable long-distance communication is required without depending on conventional Wi-Fi or cellular connectivity.&lt;/p&gt;

&lt;p&gt;For source code Visit: Play with Circuit(playwithcircuit.com)&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Use the SH-C30L USB-to-CAN Adapter with Arduino UNO and MCP2515</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Tue, 18 Aug 2026 06:39:35 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/how-to-use-the-sh-c30l-usb-to-can-adapter-with-arduino-uno-and-mcp2515-p8n</link>
      <guid>https://dev.to/play_withcircuit_241ef87/how-to-use-the-sh-c30l-usb-to-can-adapter-with-arduino-uno-and-mcp2515-p8n</guid>
      <description>&lt;p&gt;Controller Area Network (CAN) is one of those technologies that quietly powers a huge number of embedded systems. It is commonly found in cars, EVs, industrial controllers, robotics, and other distributed systems where multiple devices need to exchange data reliably over a shared bus.&lt;/p&gt;

&lt;p&gt;For development and debugging, it is useful to connect that CAN network to a computer. The problem is that a standard computer communicates through USB, while CAN uses a dedicated differential bus. A USB-to-CAN interface solves this problem by translating between the two.&lt;/p&gt;

&lt;p&gt;In this project, we will explore the &lt;strong&gt;DSD TECH SH-C30L USB-to-CAN adapter&lt;/strong&gt;, learn how its different firmware modes work, connect it to a PC, and then use an &lt;strong&gt;Arduino UNO with an MCP2515 CAN module&lt;/strong&gt; to create a simple bidirectional CAN communication setup.&lt;/p&gt;

&lt;p&gt;The goal is not just to make the hardware work, but also to understand what happens between the Arduino, CAN bus, USB adapter, and computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  SH-C30L USB-to-CAN Adapter Overview
&lt;/h2&gt;

&lt;p&gt;The SH-C30L is a compact USB-to-CAN interface designed to connect a computer directly to a CAN network. It is based on an STM32F072C8T6 microcontroller, which contains an integrated CAN controller. This allows the adapter to handle CAN protocol processing without requiring a separate external CAN controller.&lt;/p&gt;

&lt;p&gt;The microcontroller communicates with the computer through USB, while a dedicated CAN transceiver handles the physical CAN interface. The transceiver converts the controller's logic-level signals into the differential &lt;strong&gt;CAN_H&lt;/strong&gt; and &lt;strong&gt;CAN_L&lt;/strong&gt; signals used on a CAN network.&lt;/p&gt;

&lt;p&gt;One of the interesting aspects of the SH-C30L is its firmware flexibility. The adapter can work with &lt;strong&gt;Candlelight firmware&lt;/strong&gt;, which allows it to operate with Linux SocketCAN and compatible CAN applications, or with &lt;strong&gt;SLCAN firmware&lt;/strong&gt;, where it behaves more like a serial CAN interface. This makes the same hardware useful with different operating systems and software environments.&lt;/p&gt;

&lt;p&gt;The adapter supports both CAN 2.0A and CAN 2.0B frames, with CAN speeds of up to 1 Mbps. It also includes a switchable 120Ω termination resistor and a boot switch for entering firmware-update mode.&lt;/p&gt;

&lt;p&gt;For a small development setup, these features make the SH-C30L a useful alternative to more expensive professional CAN interfaces.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need a Driver?
&lt;/h2&gt;

&lt;p&gt;When you plug a USB-to-CAN adapter into a computer, the operating system needs to know how to communicate with the device.&lt;/p&gt;

&lt;p&gt;On modern Windows systems, the SH-C30L can generally be detected using the operating system's built-in USB support, depending on the firmware installed. Linux provides even stronger native CAN support through SocketCAN.&lt;/p&gt;

&lt;p&gt;If the adapter appears as an unknown USB device, a driver may need to be installed manually. Therefore, the first troubleshooting step should always be checking &lt;strong&gt;Device Manager on Windows&lt;/strong&gt; or the relevant USB/CAN interfaces on Linux.&lt;/p&gt;

&lt;h2&gt;
  
  
  Software You Can Use
&lt;/h2&gt;

&lt;p&gt;The software required depends on the firmware and operating system.&lt;/p&gt;

&lt;p&gt;On Linux, &lt;strong&gt;SocketCAN&lt;/strong&gt; is particularly useful. The &lt;code&gt;can-utils&lt;/code&gt; package provides utilities such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;candump&lt;/code&gt; for monitoring CAN traffic&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cansend&lt;/code&gt; for transmitting CAN frames&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cansniffer&lt;/code&gt; for observing changing CAN data&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;canbusload&lt;/code&gt; for checking bus utilization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Windows, &lt;strong&gt;Cangaroo&lt;/strong&gt; provides a graphical interface for monitoring and transmitting CAN messages. It can also work with DBC files for decoding signals.&lt;/p&gt;

&lt;p&gt;For custom applications, Python is another useful option. The &lt;code&gt;python-can&lt;/code&gt; library provides an interface for sending and receiving CAN messages from Python programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the SH-C30L with Linux and SocketCAN
&lt;/h2&gt;

&lt;p&gt;Linux is particularly convenient for CAN development because CAN support is integrated into the operating system through SocketCAN.&lt;/p&gt;

&lt;p&gt;When the SH-C30L is running Candlelight firmware, it can appear as a native CAN interface such as &lt;code&gt;can0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With SLCAN firmware, the setup is slightly different because the adapter is exposed through a serial interface and tools such as &lt;code&gt;slcand&lt;/code&gt; can be used to create a CAN network interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the SH-C30L with Python
&lt;/h2&gt;

&lt;p&gt;Python is useful when CAN communication needs to become part of a larger application.&lt;/p&gt;

&lt;p&gt;Instead of manually watching frames in a CAN analyzer, you can write a program that records messages, checks specific CAN IDs, generates test traffic, or communicates with another application.&lt;/p&gt;

&lt;p&gt;The connection method depends on the firmware. A Candlelight-based setup can use a SocketCAN interface such as &lt;code&gt;can0&lt;/code&gt;, while an SLCAN configuration may use a serial port.&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows Testing with Cangaroo
&lt;/h2&gt;

&lt;p&gt;Windows users can use Cangaroo to verify that the SH-C30L is communicating correctly.&lt;/p&gt;

&lt;p&gt;Start by connecting the adapter to the PC and opening &lt;strong&gt;Device Manager&lt;/strong&gt;. With the factory Candlelight firmware, the adapter may appear as a CANable/&lt;code&gt;gs_usb&lt;/code&gt;-type device.&lt;/p&gt;

&lt;p&gt;Next, launch Cangaroo and open its measurement setup. If the adapter is detected correctly, the available CAN interface should appear in the interface list.&lt;/p&gt;

&lt;p&gt;Select the detected interface and configure the CAN bitrate to match the network. For example, if the CAN network operates at 500 kbps, the software must also be configured for 500 kbps.&lt;/p&gt;

&lt;p&gt;Once the interface is active and another CAN node is transmitting, frames should begin appearing in the monitoring window.&lt;/p&gt;

&lt;p&gt;This is a simple way to verify the adapter before connecting it to a more complicated embedded system.&lt;/p&gt;

&lt;h2&gt;
  
  
  MCP2515 CAN Module Overview
&lt;/h2&gt;

&lt;p&gt;The Arduino UNO is a popular development board, but it does not include a native CAN controller. To add CAN functionality, an external CAN controller and transceiver are required.&lt;/p&gt;

&lt;p&gt;The commonly available &lt;strong&gt;MCP2515 CAN module&lt;/strong&gt; solves this problem by combining an MCP2515 CAN controller with a CAN transceiver, often a TJA1050 on typical modules.&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP2515 CAN Controller
&lt;/h3&gt;

&lt;p&gt;The MCP2515 handles the CAN protocol itself. It communicates with the Arduino through the SPI bus and takes care of CAN frame transmission and reception.&lt;/p&gt;

&lt;p&gt;It supports standard 11-bit identifiers as well as extended 29-bit identifiers and provides hardware filtering and masking features. These functions are useful when a CAN network contains many different message IDs but the Arduino only needs to process a small subset.&lt;/p&gt;

&lt;p&gt;The MCP2515 also has an interrupt output. When a relevant CAN event occurs, the INT pin can notify the Arduino so that the microcontroller does not have to continuously poll the controller.&lt;/p&gt;

&lt;h3&gt;
  
  
  TJA1050 CAN Transceiver
&lt;/h3&gt;

&lt;p&gt;The MCP2515 cannot directly drive the CAN_H and CAN_L lines. The TJA1050 transceiver handles this physical-layer conversion.&lt;/p&gt;

&lt;p&gt;It converts the digital CAN signals from the MCP2515 into the differential signals used on the CAN bus and converts incoming CAN bus signals back into logic-level signals for the controller.&lt;/p&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MCP2515 = CAN protocol controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TJA1050 = CAN physical-layer transceiver&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Together, they provide the Arduino with a practical CAN interface.&lt;/p&gt;

&lt;h3&gt;
  
  
  120Ω Termination
&lt;/h3&gt;

&lt;p&gt;CAN networks normally require termination resistors at both physical ends of the bus.&lt;/p&gt;

&lt;p&gt;Many MCP2515 modules include a 120Ω resistor that can be enabled or disabled with a jumper. Whether you should enable it depends on where the module is located in the CAN network.&lt;/p&gt;

&lt;p&gt;If the MCP2515 is one end of the bus, its termination can be enabled. If it is a middle node, the termination should normally be disabled.&lt;/p&gt;

&lt;p&gt;The SH-C30L also has a switchable 120Ω termination resistor, which makes it convenient to create a correctly terminated two-node test network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Crystal Oscillator
&lt;/h3&gt;

&lt;p&gt;The MCP2515 requires a clock reference for CAN timing. Common breakout boards use either an 8 MHz or 16 MHz oscillator.&lt;/p&gt;

&lt;p&gt;This is important when configuring the Arduino library. The oscillator frequency defined in the software must match the actual MCP2515 module.&lt;/p&gt;

&lt;p&gt;Using the wrong oscillator setting can result in CAN initialization or communication problems even when the wiring is correct.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interfacing Arduino UNO with MCP2515
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0dm0tijuse3dx1d7syey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0dm0tijuse3dx1d7syey.png" alt=" " width="678" height="345"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The MCP2515 communicates with the Arduino UNO using SPI.&lt;/p&gt;

&lt;p&gt;For a typical UNO setup, connect:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MCP2515&lt;/th&gt;
&lt;th&gt;Arduino UNO&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;td&gt;5V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CS&lt;/td&gt;
&lt;td&gt;D10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MOSI&lt;/td&gt;
&lt;td&gt;D11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MISO&lt;/td&gt;
&lt;td&gt;D12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SCK&lt;/td&gt;
&lt;td&gt;D13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INT&lt;/td&gt;
&lt;td&gt;Optional interrupt pin&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CS pin can be changed in software, but the SPI data pins are normally connected to the UNO's hardware SPI pins.&lt;/p&gt;

&lt;p&gt;After connecting the SPI interface, the Arduino can configure the MCP2515 and exchange CAN frames through it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting the MCP2515 to the SH-C30L
&lt;/h2&gt;

&lt;p&gt;The second part of the setup is the CAN bus connection.&lt;/p&gt;

&lt;p&gt;Connect:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;MCP2515&lt;/th&gt;
&lt;th&gt;SH-C30L&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CAN_H&lt;/td&gt;
&lt;td&gt;CAN_H&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CAN_L&lt;/td&gt;
&lt;td&gt;CAN_L&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CAN_H and CAN_L lines must not be swapped.&lt;/p&gt;

&lt;p&gt;A common ground is also recommended for this non-isolated setup.&lt;/p&gt;

&lt;p&gt;If the MCP2515 and SH-C30L are the two endpoints of the test bus, enable the 120Ω termination on both devices. With two 120Ω resistors in parallel, the measured resistance between CAN_H and CAN_L should be approximately 60Ω when the system is powered off.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the Complete System Works
&lt;/h2&gt;

&lt;p&gt;Once everything is connected, the communication path looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Arduino UNO
     │
     │ SPI
     ▼
  MCP2515
     │
     │ CAN_H / CAN_L
     ▼
  SH-C30L
     │
     │ USB
     ▼
     PC / Laptop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the Arduino sends data, it first transfers the information to the MCP2515 through SPI.&lt;/p&gt;

&lt;p&gt;The MCP2515 packages the information into a CAN frame and passes it to the CAN transceiver. The transceiver places the differential signal onto CAN_H and CAN_L.&lt;/p&gt;

&lt;p&gt;The SH-C30L receives that CAN frame, converts it into a USB-compatible representation, and forwards it to the computer.&lt;/p&gt;

&lt;p&gt;The process also works in the opposite direction.&lt;/p&gt;

&lt;p&gt;A CAN frame generated by the PC is sent through USB to the SH-C30L. The adapter places it on the CAN bus, where the MCP2515 receives it. The Arduino can then read the frame through SPI and process the information in its program.&lt;/p&gt;

&lt;p&gt;This gives us a simple &lt;strong&gt;bidirectional CAN communication link between Arduino and a computer&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  CAN Termination: Don't Skip This
&lt;/h2&gt;

&lt;p&gt;Termination is one of the first things to check when a CAN network does not behave as expected.&lt;/p&gt;

&lt;p&gt;For this two-node test setup, the MCP2515 and SH-C30L represent the two ends of the bus. Therefore, both ends should have 120Ω termination enabled.&lt;/p&gt;

&lt;p&gt;With power removed, measuring between CAN_H and CAN_L should give approximately 60Ω because:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;120Ω || 120Ω ≈ 60Ω
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you measure approximately 120Ω, only one termination resistor is active. If the measurement is significantly different, check the wiring and termination configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting Tips
&lt;/h2&gt;

&lt;p&gt;If no CAN messages are appearing, check the basics before changing the software configuration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confirm that CAN_H is connected to CAN_H and CAN_L to CAN_L.&lt;/li&gt;
&lt;li&gt;Make sure all devices use the same CAN bitrate.&lt;/li&gt;
&lt;li&gt;Check whether the MCP2515 module uses an 8 MHz or 16 MHz oscillator.&lt;/li&gt;
&lt;li&gt;Verify that the correct MCP2515 CS pin is defined in your Arduino code.&lt;/li&gt;
&lt;li&gt;Check the termination resistors.&lt;/li&gt;
&lt;li&gt;Confirm that the SH-C30L is detected by the operating system.&lt;/li&gt;
&lt;li&gt;Make sure the selected firmware matches the software interface you are using.&lt;/li&gt;
&lt;li&gt;Use a common ground between the Arduino-side CAN hardware and the SH-C30L.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CAN troubleshooting becomes much easier when you verify one layer at a time: first USB detection, then CAN adapter configuration, then CAN bus signaling, and finally Arduino communication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where This Setup Can Be Used
&lt;/h2&gt;

&lt;p&gt;This setup is useful for experimenting with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automotive CAN communication&lt;/li&gt;
&lt;li&gt;ECU development and diagnostics&lt;/li&gt;
&lt;li&gt;EV and battery-system communication&lt;/li&gt;
&lt;li&gt;Industrial controllers&lt;/li&gt;
&lt;li&gt;Robotics&lt;/li&gt;
&lt;li&gt;CAN-based sensor networks&lt;/li&gt;
&lt;li&gt;Embedded-system testing&lt;/li&gt;
&lt;li&gt;CAN protocol learning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is particularly useful for students and hobbyists because it provides a practical way to observe how CAN communication moves between an embedded controller and a computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The SH-C30L provides a convenient bridge between a computer and a CAN network, while the MCP2515 gives the Arduino UNO the CAN capability that it lacks internally.&lt;/p&gt;

&lt;p&gt;Putting the three pieces together creates a useful development platform: the Arduino generates or processes CAN messages, the MCP2515 handles CAN protocol communication, and the SH-C30L provides the connection to PC-based monitoring and debugging software.&lt;/p&gt;

&lt;p&gt;The setup also demonstrates an important concept in embedded systems: communication often involves multiple layers. SPI connects the Arduino to the CAN controller, the CAN transceiver handles the physical bus, and USB connects the CAN network to the computer.&lt;/p&gt;

&lt;p&gt;For complete step-by-step instructions, wiring details, code, and additional testing information, you can also refer to the original guide on &lt;strong&gt;Play with Circuit&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're just getting started with CAN, this project is a good way to move from simply reading about the protocol to actually sending, receiving, and analyzing CAN frames.&lt;/p&gt;

</description>
      <category>esp32</category>
      <category>embedded</category>
      <category>iot</category>
    </item>
    <item>
      <title>Arduino 5V 4-Channel Relay Module: Pinout, Wiring and How It Works</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Tue, 11 Aug 2026 05:18:24 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/arduino-5v-4-channel-relay-module-pinout-wiring-and-how-it-works-4i16</link>
      <guid>https://dev.to/play_withcircuit_241ef87/arduino-5v-4-channel-relay-module-pinout-wiring-and-how-it-works-4i16</guid>
      <description>&lt;p&gt;An Arduino can easily control LEDs, sensors, displays, and other low-voltage components. But what happens when you need to switch a motor, lamp, fan, or another higher-power load?&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;relay module&lt;/strong&gt; provides a simple interface between the Arduino and the load.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll look at a commonly available &lt;strong&gt;5V 4-channel relay module (HL-52S type)&lt;/strong&gt;, understand its working, and connect it to an Arduino Uno.&lt;/p&gt;

&lt;p&gt;The example uses the relay outputs to control a DC motor and the three channels of a multicolor LED.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Safety:&lt;/strong&gt; Relay contacts can be used with mains voltage. Do not work with 120/230V AC unless you understand mains safety practices. For this example, we'll use DC loads.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  5V 4-Channel Relay Module Pinout
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffpunz539zd2i0vzcnkvb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffpunz539zd2i0vzcnkvb.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Each relay channel has three output terminals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;COM&lt;/strong&gt; — Common&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NO&lt;/strong&gt; — Normally Open&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NC&lt;/strong&gt; — Normally Closed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The module also has the following control connections:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pin&lt;/th&gt;
&lt;th&gt;Function&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;td&gt;Relay module supply&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;Ground&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN1&lt;/td&gt;
&lt;td&gt;Relay 1 control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN2&lt;/td&gt;
&lt;td&gt;Relay 2 control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN3&lt;/td&gt;
&lt;td&gt;Relay 3 control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN4&lt;/td&gt;
&lt;td&gt;Relay 4 control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How the HL-52S Relay Module Works
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0681vvp2nzqzx0rpj24f.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0681vvp2nzqzx0rpj24f.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The relay board contains four 5V relay coils and driver circuitry.&lt;/p&gt;

&lt;p&gt;On this particular type of module, the control inputs are &lt;strong&gt;active LOW&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;HIGH&lt;/code&gt; → relay de-energized&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;LOW&lt;/code&gt; → relay energized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The input signal controls a transistor in the driver circuit. When the input is pulled LOW, the transistor switches the relay coil and the corresponding relay changes state.&lt;/p&gt;

&lt;p&gt;A flyback diode is connected across each relay coil. Its purpose is to suppress the voltage spike produced when the magnetic field of the coil collapses after the relay is switched off.&lt;/p&gt;

&lt;p&gt;The board also provides LEDs to show the power and individual relay states.&lt;/p&gt;

&lt;h2&gt;
  
  
  Relay Module Specifications
&lt;/h2&gt;

&lt;p&gt;Typical specifications for this 5V 4-channel relay board are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Specification&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Supply voltage&lt;/td&gt;
&lt;td&gt;3.75V–6V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Input trigger current&lt;/td&gt;
&lt;td&gt;Approximately 5mA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relay coil current&lt;/td&gt;
&lt;td&gt;Approximately 70mA per relay&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;All four relay coils&lt;/td&gt;
&lt;td&gt;Approximately 300mA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maximum switching current&lt;/td&gt;
&lt;td&gt;10A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maximum contact voltage&lt;/td&gt;
&lt;td&gt;250VAC / 30VDC&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The exact specifications can vary slightly between manufacturers and board revisions, so check the markings or datasheet for your particular module.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Relay Module with Push Buttons
&lt;/h2&gt;

&lt;p&gt;Before connecting an Arduino, you can also test the relay board using push buttons.&lt;/p&gt;

&lt;p&gt;Connect the relay module's &lt;strong&gt;IN1–IN4&lt;/strong&gt; inputs to four push buttons. The buttons can pull the corresponding inputs to ground.&lt;/p&gt;

&lt;p&gt;Because the module uses active-LOW triggering, pressing a button pulls the input LOW and activates that relay.&lt;/p&gt;

&lt;p&gt;The relay's indicator LED will also turn on.&lt;/p&gt;

&lt;p&gt;When the button is released, the input returns HIGH and the relay returns to its inactive state.&lt;/p&gt;

&lt;p&gt;This is a useful way to understand the relay module without writing any code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting the Relay Module to Arduino Uno
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Components
&lt;/h3&gt;

&lt;p&gt;For a basic setup, you'll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arduino Uno R3&lt;/li&gt;
&lt;li&gt;5V 4-channel relay module&lt;/li&gt;
&lt;li&gt;9V DC motor&lt;/li&gt;
&lt;li&gt;Common-cathode multicolor LED&lt;/li&gt;
&lt;li&gt;External DC supply/battery for the loads&lt;/li&gt;
&lt;li&gt;Breadboard&lt;/li&gt;
&lt;li&gt;Jumper wires&lt;/li&gt;
&lt;li&gt;USB cable for the Arduino&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the Arduino example, we'll use the following connections:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Relay Module&lt;/th&gt;
&lt;th&gt;Arduino Uno&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;VCC&lt;/td&gt;
&lt;td&gt;5V&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;td&gt;GND&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN1 — Motor&lt;/td&gt;
&lt;td&gt;Pin 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN2 — RED&lt;/td&gt;
&lt;td&gt;Pin 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN3 — BLUE&lt;/td&gt;
&lt;td&gt;Pin 4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IN4 — GREEN&lt;/td&gt;
&lt;td&gt;Pin 5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The four relay channels are assigned as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Relay 1:&lt;/strong&gt; DC motor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relay 2:&lt;/strong&gt; Red LED channel&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relay 3:&lt;/strong&gt; Blue LED channel&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relay 4:&lt;/strong&gt; Green LED channel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The relay contacts are then used to switch the external DC supply to the respective loads.&lt;/p&gt;

&lt;p&gt;The Arduino can control each relay independently.&lt;/p&gt;

&lt;p&gt;Because the relay contacts are electrically separate from the Arduino control logic, the load receives power from its own supply rather than directly from an Arduino GPIO pin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A 5V 4-channel relay module is a convenient way to let an Arduino control loads that cannot be driven directly from its GPIO pins.&lt;/p&gt;

&lt;p&gt;For the original circuit diagrams and a more detailed hardware walkthrough, see the full &lt;strong&gt;5V 4-channel relay module with Arduino&lt;/strong&gt; tutorial on &lt;strong&gt;Play with Circuit&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>arduino</category>
      <category>software</category>
      <category>learning</category>
    </item>
    <item>
      <title>Arduino Servo Motor Control</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Wed, 15 Apr 2026 09:38:35 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/arduino-servo-motor-control-53k0</link>
      <guid>https://dev.to/play_withcircuit_241ef87/arduino-servo-motor-control-53k0</guid>
      <description>&lt;p&gt;When working on robotics or automation projects, one of the most commonly used components is the servo motor. Unlike regular DC motors, servo motors are designed for precise position control, making them ideal for applications like robotic arms, camera positioning systems, and mechanical linkages.&lt;/p&gt;

&lt;p&gt;In this project, we will first understand how to interface a servo motor with the Arduino Uno and control its movement. Along with that, we will also build a simple servo tester, which is extremely useful for checking whether a servo is functioning correctly before using it in a larger system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components Required&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arduino Uno&lt;br&gt;
SG90 Micro Servo Motor&lt;br&gt;
Breadboard&lt;br&gt;
Jumper wires&lt;br&gt;
10kΩ Potentiometer&lt;br&gt;
16x2 LCD (optional but useful)&lt;br&gt;
220Ω resistor&lt;br&gt;
USB cable or 5V supply&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Servo Motor
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd10idifymdro5ikpskh1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd10idifymdro5ikpskh1.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
A servo motor is a compact device that combines a DC motor, a gear mechanism, and a feedback system. This feedback system continuously monitors the position of the output shaft and adjusts it to match the desired angle. Because of this closed-loop control, servo motors can move to a specific position and hold it steadily.&lt;/p&gt;

&lt;p&gt;Most hobby servo motors, such as the popular SG90, can rotate approximately from 0° to 180°. They are controlled using a PWM (Pulse Width Modulation) signal. Instead of changing voltage, the control is achieved by varying the width of the pulse sent to the signal pin. The internal electronics interpret this pulse width and rotate the shaft accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working Principle of Servo Control
&lt;/h2&gt;

&lt;p&gt;The core concept behind controlling a servo motor is PWM. The Arduino generates a series of pulses, and the duration of each pulse determines the position of the servo shaft. For example, a shorter pulse corresponds to one extreme position (around 0 degrees), a medium pulse places the servo at the center (around 90 degrees), and a longer pulse moves it to the other extreme (around 180 degrees).&lt;/p&gt;

&lt;p&gt;The servo’s internal control circuit continuously compares the received signal with its current position using feedback from the internal potentiometer. If there is a difference, it drives the motor until the desired position is reached. This is why servo motors are highly accurate and stable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Circuit Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3nmfa1x3zetcbl3deik.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3nmfa1x3zetcbl3deik.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
The circuit for interfacing a servo motor with Arduino is quite simple. The power wire of the servo is connected to the 5V pin of the Arduino, while the ground wire is connected to the GND pin. The control wire is connected to one of the PWM-enabled digital pins, commonly pin 10.&lt;/p&gt;

&lt;p&gt;Once the connections are made, the Arduino sends PWM signals through the control pin, and the servo rotates according to the signal timing. This setup is sufficient for basic control and experimentation.&lt;/p&gt;

&lt;p&gt;However, if you are using multiple servos or require more stable performance, it is often recommended to use an external power supply instead of relying solely on the Arduino’s 5V output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a Servo Tester Using Arduino
&lt;/h2&gt;

&lt;p&gt;A servo tester is a simple yet powerful tool that allows you to manually control and verify the performance of a servo motor. Instead of writing different code snippets repeatedly, a tester provides an intuitive way to check whether the servo responds correctly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xbq625ol7yn9zul4qme.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xbq625ol7yn9zul4qme.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this setup, a 10k potentiometer is used as an input device. The middle pin of the potentiometer is connected to the analog pin A0 of the Arduino. As you rotate the knob, the analog value changes, and the Arduino maps this value to a corresponding servo angle.&lt;/p&gt;

&lt;p&gt;The servo motor is connected in the same way as before, with its signal pin connected to pin 10. When the potentiometer is turned, the servo rotates smoothly, following the input. This gives you direct control over the servo position.&lt;/p&gt;

&lt;p&gt;If you add a 16x2 LCD display, the system becomes even more informative. The Arduino can display the current angle of the servo in real time. This allows you to verify whether the physical movement of the servo matches the expected angle. If the movement is inconsistent or unresponsive, it may indicate a faulty servo.&lt;/p&gt;

&lt;p&gt;This type of tester is particularly useful when working on larger projects where multiple servos are involved, as it helps ensure reliability before integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This project introduces you to both controlling and testing servo motors, which are essential skills in embedded systems and robotics. Understanding how PWM signals translate into physical motion gives you a strong foundation for more advanced designs.&lt;/p&gt;

&lt;p&gt;By building a simple servo tester, you also learn how to validate components efficiently—something that becomes increasingly important as your projects grow in complexity.&lt;/p&gt;

&lt;p&gt;As you move forward, you can expand this concept into multi-servo systems, robotic mechanisms, or even custom-designed hardware using professional PCB services like PCBWay.&lt;/p&gt;

&lt;p&gt;For complete step-by-step instructions, Arduino code, and a detailed servo motor testing setup, check the full guide here:&lt;br&gt;
&lt;a href="https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/how-to-interface-servo-motor-with-arduino/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>arduino</category>
    </item>
    <item>
      <title>Water Level Sensor with Arduino</title>
      <dc:creator>Play with Circuit</dc:creator>
      <pubDate>Fri, 04 Apr 2025 11:21:56 +0000</pubDate>
      <link>https://dev.to/play_withcircuit_241ef87/water-level-sensor-with-arduino-1ic8</link>
      <guid>https://dev.to/play_withcircuit_241ef87/water-level-sensor-with-arduino-1ic8</guid>
      <description>&lt;p&gt;Water wastage due to tank overflow is a common issue faced in many homes and buildings. Fortunately, this problem can be effectively addressed with a simple and affordable solution: a Water Level Sensor. By integrating this sensor with an Arduino, we can monitor the water level inside a tank in real-time and trigger alerts—such as turning on an LED or buzzer—when the tank is about to overflow.&lt;br&gt;
In this tutorial, you'll learn how water level sensors work, how to connect them to an Arduino.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does a Water Level Sensor Work?
&lt;/h2&gt;

&lt;p&gt;A water level sensor detects the presence or height of water in a container by measuring the electrical resistance between exposed conductive traces. When water comes into contact with the sensor, it changes the resistance between these traces, which in turn alters the output voltage.&lt;/p&gt;

&lt;p&gt;Here's how it works:&lt;br&gt;
More water → more conductivity → lower resistance → higher output voltage&lt;br&gt;
Less water → less conductivity → higher resistance → lower output voltage&lt;br&gt;
This analog voltage output is then read by an Arduino analog pin and mapped to represent the water level. The deeper the water covers the sensor, the higher the voltage output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Water Level Sensor Specifications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Operating voltage: 3 to 5V, &amp;lt; 20mA&lt;/li&gt;
&lt;li&gt;Humidity: 10%-90% non-condensing&lt;/li&gt;
&lt;li&gt;Operating Temperature: 10℃-30℃&lt;/li&gt;
&lt;li&gt;Sensor Type: Analog&lt;/li&gt;
&lt;li&gt;Output Voltage Range: 0 to 3.85V&lt;/li&gt;
&lt;li&gt;Detection Area: 40mm (height) x 16mm (width)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Water Level Sensor Hardware Overview
&lt;/h2&gt;

&lt;p&gt;The water level sensor consists of 10 parallel conductive traces:&lt;br&gt;
5 Power Traces (connected to VCC)&lt;br&gt;
5 Sense Traces (connected to signal output)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3i97hin6soznhg8b7kc9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3i97hin6soznhg8b7kc9.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
These traces are arranged alternately so that each sensing trace is placed between two power traces. When water bridges the traces, it allows current to flow, which is interpreted by the internal circuit as an increase in water level.&lt;br&gt;
The module also contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A power LED to indicate the sensor is powered.&lt;/li&gt;
&lt;li&gt;An NPN transistor for switching behavior.&lt;/li&gt;
&lt;li&gt;Multiple resistors to limit current and protect the components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pinout of Water Level Sensor
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y78aebl3p17h2seyy66.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y78aebl3p17h2seyy66.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;VCC:&lt;/strong&gt; Power supply pin (connect to 5V on Arduino)&lt;br&gt;
&lt;strong&gt;GND:&lt;/strong&gt; Ground connection&lt;br&gt;
&lt;strong&gt;OUT:&lt;/strong&gt; Analog output (connect to Arduino analog pin)&lt;/p&gt;

&lt;h2&gt;
  
  
  Schematic Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz34w3a62agx7emezf5k3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz34w3a62agx7emezf5k3.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The internal working of the sensor module can be broken down into these parts:&lt;br&gt;
&lt;strong&gt;NPN Transistor (Q1):&lt;/strong&gt; Acts as a switch, turning on when the sensor detects water.&lt;br&gt;
&lt;strong&gt;Resistors (R1, R2, R3):&lt;/strong&gt; Limit the current and protect the components.&lt;br&gt;
&lt;strong&gt;Copper Traces:&lt;/strong&gt; The power traces are connected to VCC through resistors, and sense traces go to the transistor's base.&lt;/p&gt;

&lt;p&gt;**Working Principle: **When water bridges the traces, it creates a voltage at the transistor’s base. This allows current to flow from collector to emitter, effectively turning the transistor ON. As a result, the signal pin provides an analog voltage output that increases with water level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wiring a Water Level Sensor to Arduino
&lt;/h2&gt;

&lt;p&gt;The circuit diagram is shown as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2s2yzllmk6hfoe0b590.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2s2yzllmk6hfoe0b590.PNG" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wiring:&lt;/strong&gt;&lt;br&gt;
Sensor VCC → Arduino 5V&lt;br&gt;
Sensor GND → Arduino GND&lt;br&gt;
Sensor OUT → Arduino A0 (analog pin)&lt;br&gt;
SCK and SDA pins of LCD → I2C pin of the Arduino&lt;/p&gt;

&lt;h2&gt;
  
  
  Arduino Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* 
Interfacing Water Level Sensor with Arduino UNO using Analog Output pin of Module
by www.playwithcircuit.com
Using this code we will know the Analog Value when water level is very low and when it is very high.
*/
#include &amp;lt;LiquidCrystal_I2C.h&amp;gt;  // Library to Run I2C LCD
// define the size of filter array
#define FILTER_SIZE 20
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the analog pin for the soil moisture sensor
const int WaterSensorPin = A0;
// Analog Value filter
int Filter(int sensorValue);
void setup() {
  // initialize the lcd
  lcd.init();
  // Turn on the Backlight
  lcd.backlight();
  // Clear the display buffer
  lcd.clear();
  // Print a message to the LCD
  lcd.setCursor(0, 0);
  lcd.print("Analog Value:");
}
void loop() {
  // Variable to store sensor values
  int sensorValue;
  // Variable to store filtered values
  int filteredValue;
  // Read the value from the soil moisture sensor
  sensorValue = analogRead(WaterSensorPin);
  filteredValue = Filter(sensorValue);
  // Display the filtered Analog Value on the LCD
  lcd.setCursor(0, 1);
  lcd.print(filteredValue);
  // Clear Previous Data
  lcd.print("   ");
  // Wait for 50ms before the next loop
  delay(50);
}
// Averaging filter to filter Analog Values
int Filter(int sensorValue) {
  static int analogArray[FILTER_SIZE] = { 0 };
  int filteredValue = 0;
  int i;
  // Shift the Elemnent removing the oldest value stored at index 0
  for (i = 0; i &amp;lt; (FILTER_SIZE - 1); i++) {
    analogArray[i] = analogArray[i + 1];
  }
  // Put the current value in the last element of Array i.e at index FILTER_SIZE-1 
  analogArray[FILTER_SIZE-1] = sensorValue;
  for (i = 0; i &amp;lt; FILTER_SIZE; i++) {
    filteredValue += analogArray[i];
  }
  // Return Filtered Analog Value
  return (filteredValue / FILTER_SIZE);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To learn how to create a water level indicator checkout: &lt;a href="https://playwithcircuit.com/water-level-sensor-arduino-tutorial/" rel="noopener noreferrer"&gt;https://playwithcircuit.com/water-level-sensor-arduino-tutorial/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>arduino</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
