# Code for reading 4 address to get 1 value of sensor

**URL:** https://www.wago.community/t/code-for-reading-4-address-to-get-1-value-of-sensor/921
**Category:** CODESYS
**Tags:** how-to, codesys
**Created:** [May 3, 2024, 3:46am UTC](https://www.wago.community/t/code-for-reading-4-address-to-get-1-value-of-sensor/921 "2024-05-03T03:46:24Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Michael](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/michael/32/271_2.png) [@Michael](https://www.wago.community/u/Michael)
#### Post date: [May 3, 2024, 6:22am UTC](https://www.wago.community/t/code-for-reading-4-address-to-get-1-value-of-sensor/921/2 "2024-05-03T06:22:45Z")

</div>

Hi Umair,

u can use an UNION DUT for this.

1. You have to add an DUT  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/c6b280961828a33c6e1a444c2e5b5378e2244aa4.png)
2. Fill it with your data structures, it is important to know tha every Variable in this union shares the same datastorage. for example you can write your REAL value, by accessing the array of bytes.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/85cfbfbd81d4ef93ee63350a950f4c5b3434fcfd.png)
3. Instanciate the union in you POU (PLC\_PRG, … ) and write your values. Sometimes you have to change the write order of the array, to change Byteorder of the REAL value.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/1X/305c0f9f039ba4618bb47b9d25a985d5a60a7d0f.png)

---

_[View the full topic](https://www.wago.community/t/code-for-reading-4-address-to-get-1-value-of-sensor/921)._
