# The Manchester code data written to arduino board using python can see the flipped output on the RX pin

**URL:** <https://forum.arduino.cc/t/the-manchester-code-data-written-to-arduino-board-using-python-can-see-the-flipped-output-on-the-rx-pin/1165665>\
**Category:** Programming\
**Created:** [September 5, 2023, 8:19pm UTC](https://forum.arduino.cc/t/the-manchester-code-data-written-to-arduino-board-using-python-can-see-the-flipped-output-on-the-rx-pin/1165665 "2023-09-05T20:19:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranjithaprasanna](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@ranjithaprasanna](https://forum.arduino.cc/u/ranjithaprasanna)\
**Post date:** [September 5, 2023, 8:19pm UTC](https://forum.arduino.cc/t/the-manchester-code-data-written-to-arduino-board-using-python-can-see-the-flipped-output-on-the-rx-pin/1165665/1 "2023-09-05T20:19:58Z")

</div>

HI ,

I have written the code to send hex value to the Arduino board serially , and the hex data is converted to Manchester formate and then sent to ARduino board .  
But when i tap the receiver pin on the arduino board using Pico scope can see the 8 bits data splitted in to nibbles and each nibble is flipped and an additional bit is added b/w each nibble . Can you please help me where I am doing wrong , I have given print statement in the python , in python can see the encoded and decoded byte is printing correct value ,now i can see the issue only when i check the data on the RX pin data is corrupted.  
Need help on this matter pls  
import typing

import serial

import time

import manchester\_code

```arduino
type or paste code here

```

def send\_data\_to\_arduino(encoded\_data):  
arduino\_port='COM4'  
baud\_rate=19200  
with serial.Serial(arduino\_port,baud\_rate,timeout=1) as ser:  
time.sleep(2)  
ser.write(encoded\_data)

#data\_to\_send1 = bytearray(b'\x15\x16\x00\x00\x77\x7C\xFA\xCC\xF4\xA4\x7C\x81') # Frame 1  
data\_to\_send1 = bytearray(b'\x00\x11') # Frame 1  
#data\_to\_send =bytearray(b'\x17') # note in the picoscope binary value is it shown as 1000001110- need to check what issue is  
#data\_to\_send2 = bytearray(b'\x15\x16\x00\x00\x77\x7C\xFA\xCC\xF4\xA4\x7C\x81') # Frame 2  
data\_to\_send2 = bytearray(b'\x00\x12') # Frame 2  
try:  
while True:  
delay =0.1  
############################## sending frame 1 ##############################  
encoded\_data1 =manchester\_code.encode(data\_to\_send1)  
send\_data\_to\_arduino(encoded\_data1)  
print(''.join(['{:08b}'.format(m) for m in encoded\_data1])) # this is to print the hex data converted to machester in to binary format.  
print("Encoded Data1 : ",encoded\_data1 )  
delay=0.12  
############################# sending frame 2 ####################################  
encoded\_data2 =manchester\_code.encode(data\_to\_send2)  
send\_data\_to\_arduino(encoded\_data2)  
print(''.join(['{:08b}'.format(m) for m in encoded\_data2])) # this is to print the hex data converted to machester in to binary format.  
print("Encoded Data2 : ",encoded\_data2 )

```
  ############################# decoding frame 1 ######################################  
  decoded_data1=manchester_code.decode(encoded_data1)

```

* * *

Result in the terminal  
Received data in binary1: 00000000 00010001  
Decoded\_Data 2: b'\x00\x12'  
Received data in binary2: 00000000 00010010  
01010101010101010101011001010110  
Encoded Data1 : b'UUVV'  
01010101010101010101011001011001  
Encoded Data2 : b'UUVY'  
Decoded\_Data 1: b'\x00\x11'  
Received data in binary1: 00000000 00010001  
Decoded\_Data 2: b'\x00\x12'  
Received data in binary2: 00000000 00010010

And on the Arduino side I am using the below code

```arduino
type or paste code here

```

void setup() {  
Serial.begin(19200);

}

void loop() {

while( Serial.available()\>0)  
{

char receivedData= Serial.read();  
Serial.print("Received : ");  
Serial.println(receivedData);  
}  
}

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [September 5, 2023, 8:24pm UTC](https://forum.arduino.cc/t/the-manchester-code-data-written-to-arduino-board-using-python-can-see-the-flipped-output-on-the-rx-pin/1165665/2 "2023-09-05T20:24:06Z")

</div>

I moved your topic to an appropriate forum category @ranjithaprasanna.

In the future, please take some time to pick the [forum category](https://forum.arduino.cc/categories) that best suits the subject of your topic. There is an " **About the \_\_\_\_\_ category**" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in [the " **How to get the best out of this forum**" guide](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966). The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [March 3, 2024, 8:24pm UTC](https://forum.arduino.cc/t/the-manchester-code-data-written-to-arduino-board-using-python-can-see-the-flipped-output-on-the-rx-pin/1165665/3 "2024-03-03T20:24:36Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
