Tondaj SL-814: Difference between revisions

From Leo's Notes
This page was last edited on 19 May 2020, at 04:31.
No edit summary
m →USB Connection: Added images
Line 1: Line 1:
[[File:Tondaj SL-814 with ESP8266.jpg|alt=Tondaj SL-814 with ESP8266 polling data and pushing it via WiFi|thumb|Tondaj SL-814 with ESP8266 polling data and pushing it via WiFi]]
The Tondaj SL-814 is a sound level meter with a USB port. I bought this from Deal Extreme back in December 2012 for $12.55 USD when they had the 50% off sale.
The Tondaj SL-814 is a sound level meter with a USB port. I bought this from Deal Extreme back in December 2012 for $12.55 USD when they had the 50% off sale.


The product is also called a "7-Range Sound and Noise Meter-3085".
The product is also called a "7-Range Sound and Noise Meter-3085".


== USB Connection ==
==USB Connection==
The meter has an optional USB cable that can be purchased and used with their proprietary software. However the meter I bought did not come with such a cable. Using an ordinary USB mini cable does not work since the device doesn't show up as a proper USB device when connected. On further research, it appears that the USB port is used to expose the internal serial connection to the microcontroller which can be interfaced with using any TTL UART adapter or module.
The meter has an optional USB cable that can be purchased and used with their proprietary software. However the meter I bought did not come with such a cable. Using an ordinary USB mini cable does not work since the device doesn't show up as a proper USB device when connected. On further research, it appears that the USB port is used to expose the internal serial connection to the microcontroller which can be interfaced with using any TTL UART adapter or module.


[[File:SL-814 Pinout.jpg|thumb|center]]
[[File:SL-814 Pinout.jpg|thumb|center|alt=SL-814 USB Pinout|SL-814 USB Pinout]]


The pinouts from the USB port on this device are listed in the table below.  Serial is only enabled when the USBOTGID pin is grounded; if you decide to splice a USB mini cable and it doesn't expose 5 wires, you will need to short the USBOTGID pin to ground inside the meter.
The pinouts from the USB port on this device are listed in the table below.  Serial is only enabled when the USBOTGID pin is grounded; if you decide to splice a USB mini cable and it doesn't expose 5 wires, you will need to short the USBOTGID pin to ground inside the meter.
Line 12: Line 13:
USB Mini Pinout:
USB Mini Pinout:
{| class="wikitable"
{| class="wikitable"
! Pin
!Pin
! Connection
!Connection
! Description
!Description
|-
|-
| 1
|1
| 5V
|5V
| Leave disconnected. 5V power supplied by sound meter battery.  
|Leave disconnected. 5V power supplied by sound meter battery.
|-
|-
| 2
|2
| Serial Rx
|Serial Rx
| Connect to Tx on UART module
|Connect to Tx on UART module
|-
|-
| 3
|3
| Serial Tx
|Serial Tx
| Connect to Rx on UART module
|Connect to Rx on UART module
|-
|-
| 4
|4
| USBOTGID
|USBOTGID
| Short to ground
|Short to ground
|-
|-
| 5
|5
| Ground
|Ground
| Connect to Gnd on UART module
|Connect to Gnd on UART module
|}
|}


== Protocol ==
==Protocol==
Communication on the serial line is done at 9600 baud with 8e1 setting (8 data bit, even parity, 1 stop bit). The page at https://sigrok.org/wiki/Tondaj_SL-814 has the specifics on the protocol.
Communication on the serial line is done at 9600 baud with 8e1 setting (8 data bit, even parity, 1 stop bit). The page at https://sigrok.org/wiki/Tondaj_SL-814 has the specifics on the protocol.


Line 83: Line 84:




== ESP8266 Integration ==
==ESP8266 Integration==
I was able to hook up an ESP8266 to the serial via USB and poll the decibel value. The value is then broadcast via MQTT which NodeRed processes and dumps into InfluxDB as a measurement.
I was able to hook up an ESP8266 to the serial via USB and poll the decibel value. The value is then broadcast via MQTT which NodeRed processes and dumps into InfluxDB as a measurement.


Line 122: Line 123:
}}
}}


== See Also ==
==See Also==
* https://sigrok.org/wiki/Tondaj_SL-814
 
*https://sigrok.org/wiki/Tondaj_SL-814

Revision as of 04:31, 19 May 2020

Tondaj SL-814 with ESP8266 polling data and pushing it via WiFi
Tondaj SL-814 with ESP8266 polling data and pushing it via WiFi

The Tondaj SL-814 is a sound level meter with a USB port. I bought this from Deal Extreme back in December 2012 for $12.55 USD when they had the 50% off sale.

The product is also called a "7-Range Sound and Noise Meter-3085".

USB Connection

The meter has an optional USB cable that can be purchased and used with their proprietary software. However the meter I bought did not come with such a cable. Using an ordinary USB mini cable does not work since the device doesn't show up as a proper USB device when connected. On further research, it appears that the USB port is used to expose the internal serial connection to the microcontroller which can be interfaced with using any TTL UART adapter or module.

SL-814 USB Pinout
SL-814 USB Pinout

The pinouts from the USB port on this device are listed in the table below. Serial is only enabled when the USBOTGID pin is grounded; if you decide to splice a USB mini cable and it doesn't expose 5 wires, you will need to short the USBOTGID pin to ground inside the meter.

USB Mini Pinout:

Pin Connection Description
1 5V Leave disconnected. 5V power supplied by sound meter battery.
2 Serial Rx Connect to Tx on UART module
3 Serial Tx Connect to Rx on UART module
4 USBOTGID Short to ground
5 Ground Connect to Gnd on UART module

Protocol

Communication on the serial line is done at 9600 baud with 8e1 setting (8 data bit, even parity, 1 stop bit). The page at https://sigrok.org/wiki/Tondaj_SL-814 has the specifics on the protocol.

The following python script will poll the meter every half second:

#!/usr/bin/python3
# Tondaj SL-814 sound level meter Python script
# Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
# Released under the terms of the GNU GPL, version 2 or later.

import time
import serial

s = serial.Serial('/dev/ttyUSB0', baudrate=9600, parity=serial.PARITY_EVEN)

while 1:
    # Query
    s.write(bytes([0x30, 0x01, 0x0d]))
    result = s.read(4)
    print('%02x %02x %02x %02x' % tuple(result), end='   -   ')

    # A/C
    ac = (result[0] & (1 << 7)) >> 7
    print('A' if ac == 0 else 'C', end=', ')

    # Slow/Fast
    sl = (result[0] & (1 << 3)) >> 3
    print('Fast' if sl == 0 else 'Slow', end=', ')

    # Level
    factor = (result[0] & ((1 << 5) | (1 << 4))) >> 4
    print('Level: %d' % (40 + (int(bin(factor), 2) * 20)), end=', ')

    # Value
    val = ((result[0] & 0x7) << 8) | result[1]
    tmp_str = '%d' % val
    val_str = tmp_str[:-1] + '.' + tmp_str[-1:]
    print(val_str + ' dB')

    time.sleep(0.5)

s.close()


ESP8266 Integration

I was able to hook up an ESP8266 to the serial via USB and poll the decibel value. The value is then broadcast via MQTT which NodeRed processes and dumps into InfluxDB as a measurement.

The Arduino sketch used the same protocol as the code above. I'm not certain if a delay is required after the query is sent, but I added a 200ms delay just in case.

void setup() {
	// put your setup code here, to run once:
	Serial.begin(9600, SERIAL_8E1);
	...
}

void process_data() {
	digitalWrite(LED_BUILTIN, LOW);
	
	// write query
	Serial.write(0x30);
	Serial.write(0x01);
	Serial.write(0x0d);
	
	delay(200);
	digitalWrite(LED_BUILTIN, HIGH);
	
	// read 4 bytes.
	// first 2 bytes are what we want.
	int a = Serial.read();
	int b = Serial.read();
	while (Serial.available() > 0) Serial.read();
	
	// got no data after timeout, do nothing.
	if (a == -1

See Also