# Help with serial UART communication between arduino and a sensor

**URL:** <https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045>\
**Category:** General Guidance\
**Created:** [December 5, 2025, 1:53am UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045 "2025-12-05T01:53:36Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 4:08pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/21 "2025-12-05T16:08:15Z")

</div>

They are in the diagram. 2k, 2k, 330, 330, in series. Then 2k, 220 in series. I realized I had the voltage divider backwards (5-1.6 =3.4) lol. So it should work now.

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 5, 2025, 4:28pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/22 "2025-12-05T16:28:26Z")

</div>

Make level shifter as per Fig-1:

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/a/d/c/adc48ae6013c411cdb8ef821cf33da8b61d33be2.png)  
Figure-1:

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 4:30pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/23 "2025-12-05T16:30:18Z")

</div>

i already have the old one set up but using it i still get no output with your code

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 5, 2025, 4:31pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/24 "2025-12-05T16:31:52Z")

</div>

Have you tried sketch of #16? Are you using active or passive voltage divider?

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 4:35pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/25 "2025-12-05T16:35:48Z")

</div>

yes the setup in post 17 is following the schematic and using the code from post 16. Any ideas what to try next? i have an oscilloscope with me if needed.

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 4:36pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/26 "2025-12-05T16:36:28Z")

</div>

passive voltage divider to lower the signal voltage

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 5, 2025, 4:46pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/27 "2025-12-05T16:46:55Z")

</div>

> [@chogikyan](#):
>
> yes the setup in post 17 is following the schematic and using the code from post 16. Any ideas what to try next? i have an oscilloscope with me if needed.

**1.** Resistor setup of #17 is dubious. Please, make clean setup using few resistors possible as per Fig-1.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/a/d/c/adc48ae6013c411cdb8ef821cf33da8b61d33be2.png)  
Figure-1:

**2.** Upload the following sketch (active upload mode):

```arduino
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);
byte myData[13];

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);

  //-------active upload mode---------
  uint8_t autoCmd[9] = {0xFF, 0x01, 0x78, 0x40, 0x00, 0x00, 0x00, 0x00, 0x47};
  for (byte i = 0; i < 9; i++)
  {
    SUART.write(autoCmd[i]);
  }
}

void loop()
{
   //----read gas, temp, humidity data-------------
  byte y = SUART.available();
  if (y != 0)
  {
    byte m = SUART.readBytes(myData, 13);
    if (m == 13) //13-byte data hasve arrived
    {
      if (myData[0] == 0xFF && myData[1] == 0x87) //Header AND Command ID
      {
        int rawTemp = (myData[8] << 8) | myData[9];
        int rawHum = (myData[10] << 8) | myData[11];

        float temp = rawTemp / 10.0;
        float hum = rawHum / 10.0;

        Serial.print("Temperature: ");
        Serial.print(temp, 1);
        Serial.println(" °C");

        Serial.print("Humidity: ");
        Serial.print(hum, 1);
        Serial.println(" %RH");

        Serial.println("------------------------");
        delay(1000);
      }
    }
  }
}

```

**3.** Connect oscope at DPin-5 of UNO.  
**4.** Check if the oscope shows pulse activites (there are Highs and Lows).

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 5:04pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/28 "2025-12-05T17:04:10Z")

</div>

i added a delay between the command and reading the response and it works now. Thanks to everyone for the help!

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 5, 2025, 5:11pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/29 "2025-12-05T17:11:44Z")

</div>

Post the sketch and the readings of Serial Monitor.

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 5:15pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/30 "2025-12-05T17:15:20Z")

</div>

```arduino
#include<SoftwareSerial.h>
SoftwareSerial SUART(5, 6);
byte myData[13];

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);

  //-------passive mode---------
  uint8_t autoCmd[9] = {0xFF, 0x01, 0x78, 0x41, 0x00, 0x00, 0x00, 0x00, 0x46};
  for (byte i = 0; i < 9; i++)
  {
    SUART.write(autoCmd[i]);
  }
  Serial.println("Sent passive mode command");
}

void loop()
{
  //---- read command--------
  uint8_t gthReadCmd[9] = {0xFF, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
  for (byte i = 0; i < 9; i++)
  {
    SUART.write(gthReadCmd[i]);
  }
  // Wait for response (up to 500 ms)
  unsigned long start = millis();
  while (SUART.available() < 13 && (millis() - start) < 500) {
    // just waiting
  }

  //----read gas, temp, humidity data-------------
  byte y = SUART.available();
  if (y != 0)
  {
    byte m = SUART.readBytes(myData, 13);
    if (m == 13) //13-byte data have arrived
    {
      if (myData[0] == 0xFF && myData[1] == 0x87) //Frame Header AND Command ID
      {
        int rawTemp = (myData[8] << 8) | myData[9];
        int rawHum = (myData[10] << 8) | myData[11];
        
        int ox = ((myData[6] * 256 + myData[7]));
        float temp = rawTemp / 100.0;
        float hum = rawHum / 100.0;

        Serial.print("Temperature: ");
        Serial.print(temp, 1);
        Serial.println(" °C");

        Serial.print("Humidity: ");
        Serial.print(hum, 1);
        Serial.println(" %RH");

        Serial.print("Oxygen: ");
        Serial.print(ox, 1);
        Serial.println(" ppb");

        Serial.println("------------------------");
        delay(1000);
      }
    }
  }
}

```

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/0/4/9/0491aeb36d89400b58c12dee23844bbade71597a.png)

realized my oxygen level is off by 100,000. i can’t multiply by 100,000 or it goes over int cap i think. should i make it a long?

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 5, 2025, 5:31pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/31 "2025-12-05T17:31:03Z")

</div>

Congratulations!

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 5, 2025, 6:25pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/32 "2025-12-05T18:25:21Z")

</div>

Last follow up. If I wanna run this with no breadboard at all, just wires straight from the arduino to the sensor, is there an arduino model that works on 3.3v logic and has usb connectivity? Would the arduino nano work to this capacity? If not why not?

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 6, 2025, 2:27am UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/33 "2025-12-06T02:27:39Z")

</div>

You can use 30-pin ESP32.

 ![esp32-30Pin-Pic](https://europe1.discourse-cdn.com/arduino/original/4X/c/3/1/c31239fc712fea170e202c117cd4f8b62f7fae2b.jpeg)

---

<div class="post-metadata">

**Author:** ![chogikyan](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/chogikyan/32/1099436_2.png) [@chogikyan](https://forum.arduino.cc/u/chogikyan)\
**Post date:** [December 6, 2025, 2:18pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/34 "2025-12-06T14:18:58Z")

</div>

whats the advantage with this over the arduino MKR board for example. Can i still program it using the arduino IDE?

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [December 6, 2025, 2:26pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/35 "2025-12-06T14:26:45Z")

</div>

**1.** I have no idea on MKR Board.

**2.** You can program ESP32 using Arduino IDE in the same way you do for UNOR3.

**3.** ESP32 as built-in WiFi, Bluetooth, ADC, DAC etc.

**4.** The attached file may give you an introduction on ESP32.  
[ch-18 ESP32Lec.pdf](https://forum.arduino.cc/uploads/short-url/40dO8Owg2FKhdD5LoFyS6mJThJQ.pdf) (1.2 MB)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 4, 2026, 2:27pm UTC](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045/36 "2026-06-04T14:27:29Z")

</div>

Closed on June 4, 2026, 2:27pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.arduino.cc/t/help-with-serial-uart-communication-between-arduino-and-a-sensor/1418045.md?page=1)
