# Set up device payload formatter

The final step is to set up the payload formatter for a device, so that the information we send is decoded correctly.

We are going to set up a custom formatter for our device, it is possible to use built in formatters and define one custom formatter for all devices

 ```{admonition}  Requirements
 :class: Hint

1. A LoRaWAN capable device
```
## Set up Payload Formatter

Click on End devices then on the device you want to create a formatter for

![TTN Payload Formatting](./images/TTN_pay1.png "TTN End devices")

Which will bring you to this screen

![TTN Payload Formatting](./images/TTN_pay2.png "TTN End devices")

There is losts of useful information here, including live data. So you can come to this screen to confirm connection and that data is being transmitted.

Click on Payload formatters. Then in Formatter type select Custom Javascript formatter.
In the Formatter code box enter the following:
```javascript
function decodeUplink(input) { 
  var decoded = {}; 
    decoded.mean = ((input.bytes[0] << 8) + input.bytes[1]); 
    decoded.sdd = ((input.bytes[2] << 8) + input.bytes[3]); 
  
  return { 
    data: decoded  
  }; 
} 
```
This decodes the data we sent from the [Arduino LoRaWAN example](/Tutorials/Arduino/tut_ard_lorawan)
Each line pulls the two characters from the byte stream that represents one piece of data we sent

If the data was scaled before sending then it should be rescaled back to original here.
For example, if the mean was premultiplied by 10 and the sdd by 100 we change the above to 
 ```javascript
function decodeUplink(input) { 
  var decoded = {}; 
    decoded.mean = ((input.bytes[0] << 8) + input.bytes[1])/10; 
    decoded.sdd = ((input.bytes[2] << 8) + input.bytes[3])/1000; 
  
  return { 
    data: decoded  
  }; 
} 
```
You can test your decoder works by entering the hex value to decode into Byte payload and pressing Test decoder. When happy click on save changes