Table of Contents:

1. RS485-LB connects to third-party sensors

1.1 How to connect RS485-LB node to UART distance sensor?

Take the A16-15 as an example, but the same setup can support different distance sensors, compare specifications see this link to DDS04-LB.

image-20240703151202-1.png

  • Connection:

image-20240703153033-2.jpeg

  • AT command configuration:  

AT+MOD=2    

AT+COMMAND1=01 02 03 04 05 ,0       AT+SEARCH1=1,ff       AT+DATACUT1=4,2,2~3       AT+CMDDL1=1000

image-20240703153540-3.png

  • Decoder:  Decoding refer to this link.
  • Example in TTN:

image-20240703161941-4.png

2. SN50v3-LB connects to third-party sensors

2.1 Working Modes & Sensor Data. Uplink via FPORT=2

SN50v3-LB/LS has different working mode for the connections of different type of sensors. This section describes these modes. Use can use the AT Command AT+MOD to set SN50v3-LB/LS to different working modes.

For example:

AT+MOD=2     // will set the SN50v3 to work in MOD=2 distance mode which target to measure distance via Ultrasonic Sensor.

Important Notice: 

1. Some working modes has payload more than 12 bytes, The US915/AU915/AS923 frequency bands' definition has maximum 11 bytes in DR0. Server sides will see NULL payload while SN50v3-LB/LS transmit in DR0 with 12 bytes payload.

2. All modes share the same Payload Explanation from HERE.

3. By default, the device will send an uplink message every 20 minutes.

2.1.1 MOD=1 (Default Mode)

In this mode, uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.

Size(bytes)222122
ValueBat

Temperature(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15)&Digital Interrupt(PA8) 

Temperature(SHT20 or SHT31 or BH1750 Illumination Sensor)

Humidity(SHT20 or SHT31)

image-20220627150949-6.png

2.1.2 MOD=2 (Distance Mode)

This mode is target to measure the distance. The payload of this mode is totally 11 bytes. The 8th and 9th bytes is for the distance.

Size(bytes)222122
ValueBAT

Temperature(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15) & Digital Interrupt(PA8)

Distance measure by: 1) LIDAR-Lite V3HP
Or 2) Ultrasonic Sensor

Reserved

1656324539647-568.png

Connection of LIDAR-Lite V3HP:

image-20230512173758-5.png

Connection to Ultrasonic Sensor:

Need to remove R1 and R2 resistors to get low power,otherwise there will be 240uA standby current.

image-20230512173903-6.png

For the connection to TF-Mini or TF-Luna , MOD2 payload is as below:

Size(bytes)221222
ValueBAT

Temperature(DS18B20)(PC13)

Digital in(PB15) & Digital Interrupt(PA8)

ADC(PA4)

Distance measure by:1)TF-Mini plus LiDAR
Or 2) TF-Luna LiDAR

Distance signal  strength

1656376779088-686.png

Connection to TF-Mini plus LiDAR(UART version):

Need to remove R3 and R4 resistors to get low power,otherwise there will be 400uA standby currentimage-20230512180609-7.png

Connection to TF-Luna LiDAR (UART version):

Need to remove R3 and R4 resistors to get low power,otherwise there will be 400uA standby current

image-20230610170047-1.png

2.1.3 MOD=3 (3 ADC + I2C)

This mode has total 12 bytes. Include 3 x ADC + 1x I2C

Size(bytes)

2221221
Value

ADC1(PA4)

ADC2(PA5)

ADC3(PA8)

Digital Interrupt(PB15)

Temperature(SHT20 or SHT31 or BH1750 Illumination Sensor)

Humidity(SHT20 or SHT31)

Bat

2.1.4 MOD=4 (3 x DS18B20)

This mode has total 11 bytes. As shown below:

Size(bytes)222122
ValueBAT

Temperature1(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15) & Digital Interrupt(PA8)  

Temperature2(DS18B20)
(PB9)
Temperature3(DS18B20)(PB8)

1656377606181-607.png

image-20230513134006-1.png

2.1.5 MOD=5 (Weight Measurement by HX711)

image-20230512164658-2.png

Each HX711 need to be calibrated before used. User need to do below two steps:

  1. Zero calibration. Don't put anything on load cell and run AT+WEIGRE to calibrate to Zero gram.
  2. Adjust calibration factor (default value 400): Put a known weight thing on load cell and run AT+WEIGAP to adjust the Calibration Factor.
  3. Weight has 4 bytes, the unit is g.

     

For example:

AT+GETSENSORVALUE =0

Response:  Weight is 401 g

Check the response of this command and adjust the value to match the real value for thing. 

Size(bytes)

22214
ValueBAT

Temperature(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15) & Digital Interrupt(PA8)

Weight

image-20220820120036-2.png

2.1.6 MOD=6 (Counting Mode)

In this mode, the device will work in counting mode. It counts the interrupt on the interrupt pins and sends the count on TDC time.

Connection is as below. The PIR sensor is a count sensor, it will generate interrupt when people come close or go away. User can replace the PIR sensor with other counting sensors.

image-20230512181814-9.png

Note: LoRaWAN wireless transmission will infect the PIR sensor. Which cause the counting value increase +1 for every uplink. User can change PIR sensor or put sensor away of the SN50_v3 to avoid this happen.

Size(bytes)22214
ValueBAT

Temperature(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15)

Count(PA8)

1656378441509-171.png

2.1.7 MOD=7 (Three interrupt contact modes)

Size(bytes)

2221112
ValueBAT

Temperature(DS18B20)
(PC13)

ADC(PA5)

Digital Interrupt1(PA8)

Digital Interrupt2(PA4)Digital Interrupt3(PB15)Reserved

image-20230513111203-7.png

2.1.8 MOD=8 (3ADC+1DS18B20)

Size(bytes)

222122
ValueBAT

Temperature(DS18B20)
(PC13)

ADC1(PA4)

Digital Interrupt(PB15)

ADC2(PA5)

ADC3(PA8)

image-20230513111231-8.png

2.1.9 MOD=9 (3DS18B20+ two Interrupt count mode)

Size(bytes)

2221244
ValueBAT

Temperature
(DS18B20)(PC13)

Temperature2
(DS18B20)(PB9)

Digital Interrupt
(PB15)

Temperature3
(DS18B20)(PB8)

Count1(PA8)

Count2(PA4)

image-20230513111255-9.png

The newly added AT command is issued correspondingly:

 AT+INTMOD1 PA8   pin:  Corresponding downlink:   06 00 00 xx

 AT+INTMOD2 PA4   pin:  Corresponding downlink:   06 00 01 xx

 AT+INTMOD3 PB15    pin:  Corresponding downlink:   06 00 02 xx

AT+SETCNT=aa,bb  

When AA is 1, set the count of PA8 pin to BB    Corresponding downlink:09 01 bb bb bb bb

When AA is 2, set the count of PA4 pin to BB    Corresponding downlink:09 02 bb bb bb bb

2.1.10 MOD=10 (PWM input capture and output mode,Since firmware v1.2)

Note: Firmware not release, contact Dragino for testing.

In this mode, the uplink can perform PWM input capture, and the downlink can perform PWM output.

It should be noted when using PWM mode.

2.1.10.1 Uplink, PWM input capture

image-20230817172209-2.png

Size(bytes)222122
ValueBat

Temperature(DS18B20)(PC13)

ADC(PA4)

PWM_Setting
&Digital Interrupt(PA8) 

Pulse period

Duration of high level

image-20230817170702-1.png

When the device detects the following PWM signal ,decoder will converts the pulse period and high-level duration to frequency and duty cycle.

Frequency:

If AT+PWMSET=0, Frequency= 1000000/Pulse period(HZ);

If AT+PWMSET=1, Frequency= 1000/Pulse period(HZ);

Duty cycle:

Duty cycle= Duration of high level/ Pulse period*100 (%).

image-20230818092200-1.png

2.1.10.2 Uplink, PWM output

image-20230817172209-2.png

AT+PWMOUT=a,b,c

a is the time delay of the output, the unit is ms.

b is the output frequency, the unit is HZ.

c is the duty cycle of the output, the unit is %.

Downlink:   0B 01 bb cc aa 

aa is the time delay of the output, the unit is ms.

bb is the output frequency, the unit is HZ.

cc is the duty cycle of the output, the unit is %.

For example, send a AT command: AT+PWMOUT=65535,1000,50  The PWM is always out, the frequency is 1000HZ, and the duty cycle is 50.

The oscilloscope displays as follows:

image-20230817172209-2.png

2.1.10.3 Downlink, PWM output

image-20230817173800-3.png

Downlink:   0B xx xx xx yy zz zz

                   xx xx xx is the output frequency, the unit is HZ.

                   yy is the duty cycle of the output, the unit is %.

                   zz zz is the time delay of the output, the unit is ms.

For example, send a downlink command: 0B 00 61 A8 32 13 88, the frequency is 25KHZ, the duty cycle is 50, and the output time is 5 seconds.

The oscilloscope displays as follows:

image-20230817173858-5.png

2.1.11 MOD=11 (TEMP117)

In this mode, uplink payload includes in total 11 bytes. Uplink packets use FPORT=2.

Size(bytes)222122
ValueBat

Temperature(DS18B20)(PC13)

ADC(PA4)

Digital in(PB15)&Digital Interrupt(PA8) 

Temperature

(TEMP117)

Reserved position, meaningless

(0x0000)

image-20240717113113-1.png

Connection:

image-20240717141528-2.jpeg

2.1.12 MOD=12 (Count+SHT31)

This mode has total 11 bytes. As shown below:

Size(bytes)22214
ValueBAT

 Temperature_SHT31

Humidity_SHT31

 Digital in(PB15)

Count(PA8)

image-20240717150948-5.png

Wiring example:

image-20240717152224-6.jpeg

2.2 ​Decode payload

While using TTN V3 network, you can add the payload format to decode the payload.

1656378466788-734.png

The payload decoder function for TTN V3 are here:

The payload decoder function for TTN V3 are here:

SN50v3-LB/LS TTN V3 Payload Decoder:  https://github.com/dragino/dragino-end-node-decoder

2.2.1 Battery Info

Check the battery voltage for SN50v3-LB/LS.

Ex1: 0x0B45 = 2885mV

Ex2: 0x0B49 = 2889mV

2.2.2 Temperature (DS18B20)

If there is a DS18B20 connected to PC13 pin. The temperature will be uploaded in the payload.

More DS18B20 can check the 3 DS18B20 mode

Connection:

image-20230512180718-8.png

Example:

If payload is: 0105H:  (0105 & 8000 == 0), temp = 0105H /10 = 26.1 degree

If payload is: FF3FH :  (FF3F & 8000 == 1) , temp = (FF3FH - 65536)/10 = -19.3 degrees.

(FF3F & 8000:Judge whether the highest bit is 1, when the highest bit is 1, it is negative)

2.2.3 Digital Input

The digital input for pin PB15,

  • When PB15 is high, the bit 1 of payload byte 6 is 1.
  • When PB15 is low, the bit 1 of payload byte 6 is 0.

When the digital interrupt pin is set to AT+INTMODx=0, this pin is used as a digital input pin.

Note: The maximum voltage input supports 3.6V.

 

2.2.4 Analogue Digital Converter (ADC)

The measuring range of the ADC is only about 0.1V to 1.1V The voltage resolution is about 0.24mv.

When the measured output voltage of the sensor is not within the range of 0.1V and 1.1V, the output voltage terminal of the sensor shall be divided The example in the following figure is to reduce the output voltage of the sensor by three times If it is necessary to reduce more times, calculate according to the formula in the figure and connect the corresponding resistance in series.

image-20220628150112-1.png

Note: If the ADC type sensor needs to be powered by SN50_v3, it is recommended to use +5V to control its switch.Only sensors with low power consumption can be powered with VDD.

The position of PA5 on the hardware after LSN50 v3.3 is changed to the position shown in the figure below, and the collected voltage becomes one-sixth of the original.

image-20230811113449-1.png

2.2.5  Digital Interrupt

Digital Interrupt refers to pin PA8, and there are different trigger methods. When there is a trigger, the SN50v3-LB/LS will send a packet to the server.

 Interrupt connection method:

image-20230513105351-5.png

Example to use with door sensor :

The door sensor is shown at right. It is a two wire magnetic contact switch used for detecting the open/close status of doors or windows.

1656379210849-860.png

When the two pieces are close to each other, the 2 wire output will be short or open (depending on the type), while if the two pieces are away from each other, the 2 wire output will be the opposite status. So we can use SN50v3-LB/LS interrupt interface to detect the status for the door or window.

Below is the installation example:

Fix one piece of the magnetic sensor to the door and connect the two pins to SN50v3-LB/LS as follows:

  • One pin to SN50v3-LB/LS's PA8 pin

  • The other pin to SN50v3-LB/LS's VDD pin

Install the other piece to the door. Find a place where the two pieces will be close to each other when the door is closed. For this particular magnetic sensor, when the door is closed, the output will be short, and PA8 will be at the VCC voltage.

Door sensors have two types:  NC (Normal close) and NO (normal open). The connection for both type sensors are the same. But the decoding for payload are reverse, user need to modify this in the IoT Server decoder.

When door sensor is shorted, there will extra power consumption in the circuit, the extra current is 3v3/R14 = 3v3/1Mohm = 3uA which can be ignored.

1656379283019-229.png

The above photos shows the two parts of the magnetic switch fitted to a door.

The software by default uses the falling edge on the signal line as an interrupt. We need to modify it to accept both the rising edge (0v --> VCC , door close) and the falling edge (VCC --> 0v , door open) as the interrupt.

The command is:

AT+INTMOD1=1       //  (more info about INMOD please refer AT Command Manual)

Below shows some screen captures in TTN V3:

1656379339508-835.png

In MOD=1, user can use byte 6 to see the status for door open or close. TTN V3 decoder is as below:

door= (bytes[6] & 0x80)? "CLOSE":"OPEN";

2.2.6  I2C Interface (SHT20 & SHT31)

The SDA and SCK are I2C interface lines. You can use these to connect to an I2C device and get the sensor data.

We have made an example to show how to use the I2C interface to connect to the SHT20/ SHT31 Temperature and Humidity Sensor. 

Notice: Different I2C sensors have different I2C commands set and initiate process, if user want to use other I2C sensors, User need to re-write the source code to support those sensors. SHT20/ SHT31 code in SN50v3-LB/LS will be a good reference.

Below is the connection to SHT20/ SHT31. The connection is as below:

image-20230610170152-2.png

The device will be able to get the I2C sensor data now and upload to IoT Server.

1656379664142-345.png

Convert the read byte to decimal and divide it by ten.

Example:

Temperature:  Read:0116(H) = 278(D)  Value:  278 /10=27.8℃;

Humidity:    Read:0248(H)=584(D)       Value:  584 / 10=58.4, So 58.4%

If you want to use other I2C device, please refer the SHT20 part source code as reference.

2.2.7 Distance Reading

Refer Ultrasonic Sensor section.

2.2.8 Ultrasonic Sensor

This Fundamental Principles of this sensor can be found at this link: https://wiki.dfrobot.com/Weather_-_proof_Ultrasonic_Sensor_with_Separate_Probe_SKU___SEN0208

The SN50v3-LB/LS detects the pulse width of the sensor and converts it to mm output. The accuracy will be within 1 centimeter. The usable range (the distance between the ultrasonic probe and the measured object) is between 24cm and 600cm.

The working principle of this sensor is similar to the HC-SR04 ultrasonic sensor.

The picture below shows the connection:

image-20230512173903-6.png

Connect to the SN50v3-LB/LS and run AT+MOD=2 to switch to ultrasonic mode (ULT).

The ultrasonic sensor uses the 8th and 9th byte for the measurement value.

Example:

Distance:  Read: 0C2D(Hex) = 3117(D)  Value:  3117 mm=311.7 cm

2.2.9 Battery Output - BAT pin

The BAT pin of SN50v3-LB/LS is connected to the Battery directly. If users want to use BAT pin to power an external sensor. User need to make sure the external sensor is of low power consumption. Because the BAT pin is always open. If the external sensor is of high power consumption. the battery of SN50v3-LB/LS will run out very soon.

2.2.10 +5V Output

SN50v3-LB/LS will enable +5V output before all sampling and disable the +5v after all sampling.  

The 5V output time can be controlled by AT Command.

AT+5VT=1000

Means set 5V valid time to have 1000ms. So the real 5V output will actually have 1000ms + sampling time for other sensors.

By default the AT+5VT=500. If the external sensor which require 5v and require more time to get stable state, user can use this command to increase the power ON duration for this sensor.

2.2.11 BH1750 Illumination Sensor

MOD=1 support this sensor. The sensor value is in the 8th and 9th bytes.

image-20230512172447-4.png

image-20220628110012-12.png

2.2.12 PWM MOD

  • The maximum voltage that the SDA pin of SN50v3 can withstand is 3.6V, and it cannot exceed this voltage value, otherwise the chip may be burned.

  • If the PWM pin connected to the SDA pin cannot maintain a high level when it is not working, you need to remove the resistor R2 or replace it with a resistor with a larger resistance, otherwise a sleep current of about 360uA will be generated. The position of the resistor is shown in the figure below:

      image-20230817183249-3.png

  • The signal captured by the input should preferably be processed by hardware filtering and then connected in. The software processing method is to capture four values, discard the first captured value, and then take the middle value of the second, third, and fourth captured values.

  • Since the device can only detect a pulse period of 50ms when AT+PWMSET=0 (counting in microseconds), it is necessary to change the value of PWMSET according to the frequency of input capture.

  • PWM Input allows low power consumption. PWM Output to achieve real-time control, you need to go to class C. Power consumption will not be low.

    For PWM Output Feature, there are two consideration to see if the device can be powered by battery or have to be powered by external DC. 

    a) If real-time control output is required, the SN50v3-LB/LS is already operating in class C and an external power supply must be used.

    b) If the output duration is more than 30 seconds, better to use external power source.  

     

2.2.13 Working MOD

The working MOD info is contained in the Digital in & Digital Interrupt byte (7th Byte).

User can use the 3rd ~ 7th   bit of this byte to see the working mod:

Case 7th Byte >> 2 & 0x1f:

  • 0: MOD1
  • 1: MOD2
  • 2: MOD3
  • 3: MOD4
  • 4: MOD5
  • 5: MOD6
  • 6: MOD7
  • 7: MOD8
  • 8: MOD9
  • 9: MOD10

3. PS-LB-NA connects to third-party sensors

PS-LB-NA might connect to different kind of probes, 4~20mA represent the full scale of the measuring range. So a 12mA output means different meaning for different probe.  

For example.

Probe Type4~20mA scale for this probeExample: 12mA actually meaning for this probe
PH Combination Electrodes0 ~ 14 pHPH Value: 7
Water Pressure Sensor0~5 meters2.5 meters pure water
Pressure transmitter probe0~1MPa0.5MPa air / gas or water pressure 

User can set different probe model for above probes. So IoT server is able to se identical how it should parse the 4~20mA or 0~30v sensor value and get the correct value.

3.1 0~20mA value (IDC_IN)

Payload Example:

27AE(H) = 10158 (D)/1000 = 10.158mA.

image-20230821150704-1.png

Connect to a 2 wire 4~20mA sensor.

image-20230225154759-1.png

3.2 0~30V value ( pin VDC_IN)

Measure the voltage value. The range is 0 to 30V.

Example:

138E(H) = 5006(D)/1000= 5.006V

3.3 IN1&IN2&INT pin

IN1 and IN2 are used as digital input pins.

Example:

09 (H): (0x09&0x08)>>3=1    IN1 pin is high level.

09 (H): (0x09&0x04)>>2=0    IN2 pin is low level.

This data field shows if this packet is generated by Interrupt Pin or not. Click here for the hardware and software set up. Note: The Internet Pin is a separate pin in the screw terminal.

Example:

09 (H): (0x09&0x02)>>1=1    The level of the interrupt pin.

09 (H): 0x09&0x01=1              0x00: Normal uplink packet.

0x01: Interrupt Uplink Packet.

3.4 Sensor value, FPORT=7

Size(bytes)

2n
ValueBAT

Voltage value, each 2 bytes is a set of voltage values.

image-20230220171300-1.png

Multiple sets of data collected are displayed in this form:

[voltage value1], [voltage value2], [voltage value3],…[voltage value n/2]

3.5 ​Decode payload in The Things Network

While using TTN network, you can add the payload format to decode the payload.

1675144839454-913.png

PS-LB-NA TTN Payload Decoder: https://github.com/dragino/dragino-end-node-decode

4. Differences between three different motherboards

image-20240924102931-1.png

 

Tags:
    
Copyright ©2010-2024 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0