New answers tagged

7

Serial.write(some_byte) writes a byte on the serial output. The Arduino serial monitor tries to interpret the bytes it receives as text: 0x11 is a control character, displayed as “□” 0x22 is the ASCII code for the double quote (") 0x33 is the ASCII code for the digit 3. 0x44 is the ASCII code for the uppercase letter “D” etc.


1

To store a 2 character string you need a 3 byte array, not a 2 byte array. This is because in C a string consists of the actual string data and a zero ("NULL") byte at the end to indicate where the end of the string is. So you would need: char Hex_Array[3]; so it can store, for the number 0x69: 69\0. Otherwise you overrun the array and corrupt ...


0

You can use .indexOf to find characters in a String. It returns a -1 if a match is not found. See https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/indexof/ mySerial.println("AT"); String str; while (mySerial.available() > 0 ) { str = mySerial.readString(); Serial.println(str); if (str.indexOf(&...


2

You will save yourself a lot of headaches by sending the data in ASCII instead of binary: bluetoothSerial.print("RMSCurrent: "); bluetoothSerial.println(RMSCurrent); Of course, you will then have to parse the data stream on the Python side. If you really want to send binary data, then be aware that the write() method you are using is intended for ...


2

For your needs you don't need actual UARTs. You can do it all with normal GPIO pins and one (or more) interrupts. UART communication is characterised by having a "start bit" at the beginning of all bytes. That is, in TTL terms, a transition from HIGH to LOW. You just need to look out for that transition. You could: Use Pin Change interrupts on 6 ...


Top 50 recent answers are included