Categories
Statistics
Flag Counter
Since 08.08.2014
Counts only, if "DNT = disabled".

Your IP is 3.236.18.23
ec2-3-236-18-23.compute-1.am
Info
Valid HTML 4.01 Transitional Creative Commons Lizenzvertrag
rss
เราจะทำแบบวิศวกรผู้ยิ่งใหญ่
We love the King
19. March 2024
Your valuable opinion :
3 stars

Avg. 3.14 from 7 votes.



March 2024 Tea Time :-)
Arduino-reads-UT803.php    9147 Bytes    31-05-2023 09:33:39


Arduino / Genuino and the UT803


Managing this serial stuff



We showed here, that this multimeter wants power from an external source in order to be able to send data. Now we present a working arduino sketch to read and understand the sent data ...



✈ Arduino Sketch - The Code



Double click on code to select ...


/* ///////////////////////////////////////////////////////////// 
ARDUINO/Genuino (UNO) Test/Demo Sketch for UT803 Multimeter
https://www.changpuak.ch/electronics/Arduino-reads-UT803.php
Software Version 1.0, 
22.03.2017, Alexander C. Frank
//////////////////////////////////////////////////////////////*/

#include <SoftwareSerial.h>

unsigned int i = 0;
unsigned long data ;
char MValue[12] ;
float Number = 0.0 ;
float OldNumber = 0.0 ;
String Text = "";
String Unit = "";
unsigned int Resolution = 1;

SoftwareSerial mySerial(10, 11); // RX, TX (unused)

void setup() 
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(19200);
 }

void loop() 
{ 
  if (mySerial.available()) 
  {
    data = 0x7F & mySerial.read();
    MValue[i] = data ;
    i += 1;
    if (data == 0x0A) 
    {
      i = 0 ;
      Number =  ( MValue[1] - 0x30 ) * 1000 ;
      Number += ( MValue[2] - 0x30 ) * 100 ;
      Number += ( MValue[3] - 0x30 ) * 10 ;
      Number += ( MValue[4] - 0x30 )  ;
      if (MValue[0] == 0x31 ) Number = Number * 10 ;
      if (MValue[0] == 0x32 ) Number = Number * 100 ;
      if (MValue[0] == 0x33 ) Number = Number * 1000 ;
      if (MValue[0] == 0x34 ) Number = Number * 10000 ;
      if (MValue[0] == 0x35 ) Number = Number * 100000 ;
      Unit = String(MValue[5]) + String(MValue[6]) 
      	+String(MValue[7]) +String(MValue[8]);
      
      
      // VOLTAGE DC POSITIVE
      if ( Unit == ";80:" ) 
      {
        Text = "Volt DC" ;
        Number = Number * 0.001;
        Resolution = ( MValue[0] - 0x30 ) + 1;
      }

      // VOLTAGE AC  
      if ( Unit == ";806" ) 
      {
        Text = "Volt AC" ;
        Number = Number * 0.001;
        Resolution = ( MValue[0] - 0x30 ) + 0;
      }

      // OHMS
      if ( Unit == "3802" ) 
      {
        Text = "Ohm" ;
        Number = Number * 0.1; 
        Resolution = ( MValue[0] - 0x30 ) + 1;
      }
      
      // OUTPUT ONLY IF REASONABLE VALUE
      if ((Number > 0.95 * OldNumber) && (Number < 1.05 * OldNumber)) 
      {
        Serial.print(Number,Resolution);
        Serial.print(" ");
        Serial.print(Text);
        /* Serial.print("\t\t");
        for (int j=0; j<10; j++) 
        {
           Serial.print(char(MValue[j])); 
        }
        */
        Serial.println(" ");
      }
    OldNumber = Number ;
    }
  }
  
}

// ///////////////////////////////////////////////////////////// 
// END OF FILE.
// ///////////////////////////////////////////////////////////// 




✈ The Bits / Bytes in detail




The UT803 uses only seven bits. That's why we masked out the 8th (MSB) in line 33.

Sometimes (when you look away) the UT803 sends garbage, or the arduino receives garbage. For that rare case we introduced some kind of check in line 77.

Under normal circumstances, there are eleven bytes sent. This may look like this :

0x30, 0x30,0x30,0x30,0x30, 0x3B,0x3C,0x30,0x3A, 0x0D,0x0A

The very first byte is a "multiplier". Multiply the following numeric value with ten to the power of this number. (e.g. 10^0 = 1, 10^1 = 10, 10^2 = 100, ...)

Bytes 1,2,3 and 4 represent the numeric value. This is a four digit number between 0000 and 5999. The decimal point is defined by the following "unit" and the multiplier (Byte 0).

Bytes 5,6,7 and 8 represent the unit. We did not test all of them, but will give some examples here. ;80: is Volts DC, ;806 is Volts AC, 3802 is Ohm, 4800 is Degrees Celsius, 9808 is Ampere DC, 6802 is Nanofarad. Feel free to explore the others by yourselves ...

The very last two bytes are always 0x0D and 0x0A. They are "Carriage Return" and "Line Feed". This will end the transmission.




✈ The Serial Plotter




Is a beautiful tool to get an impression on the dynamics of your data . Using the example above you may get a graph like this :


Arduino reads UT803

Monitoring the power grid voltage ...




✈ Share your thoughts



The webmaster does not read these comments regularely. Urgent questions should be send via email. Ads or links to completely uncorrelated things will be removed.


Your Browser says that you allow tracking. Mayst we suggest that you check that DNT thing ?

 
t1 = 6459 d

t2 = 250 ms

★ ★ ★  Copyright © 2006 - 2024 by changpuak.ch  ★ ★ ★

PRchecker.info Impressum