I am trying to use my HC05 so my Arduino can communicate with my Windows 10 PC. I have a program written using the Window API for Serial Communication but the problem is it looks like the Arduino/HC05 can only send or the API can only read one character at a time. It is the same with Arduino; I send an entire string with the API and the Arduino has to read/parse it character by character. I was wondering if there was a solution to this problem or if I will need to develop some sort of coding protocol (like space to separate messages) to send messages. (The other issue is that it will take an age to send long messages this way.)

Windows File Reading API https://msdn.microsoft.com/en-us/library/windows/desktop/aa364232(v=vs.85).aspx

Here is the PC side file.

do {
    // check for data on port and display it on screen.
    ReadFile(file, buffer, sizeof(buffer), &read, NULL);
    int i;
    sscanf(buffer, "%d", &i);
    std::cout << i << std::endl;

    if (read) {
        //WriteFile(screen, buffer, read, &written, NULL);

        //When space seen, add the string to data
        if (buffer[0] == ' ') {
            int convertedDatum = std::stoi(datum, &sz);
            if (convertedDatum < 12) {
                //WriteFile(file, "S " , 2, &written, NULL);
                //WriteFile(screen, "S", read, &written, NULL);
            else {
                //WriteFile(file, "G ", 2, &written, NULL);
                //WriteFile(screen, "G", read, &written, NULL);
            datum = "";

Arduino-side test code

void loop() {

while (true) {
    String sendValue = String(100);
    sendValue.toCharArray(buf, sizeof(buf));

    Serial1.write(' ');

What I am seeing on the console on the PC which is represented by the screen variable when I debug is when I break at the line

std::cout << i << std::endl;

1-Continue-0-Continue-0 or on the console


I am pretty sure that I have seen entire strings sent at once with the Android Bluetooth API so I am not sure exactly if the same can be done with Windows or if the Windows VC++ API's are incapable.


Serial is only ever a character at a time. That is what serial is. If you want to impose some structure on top of that then it is up to you to define that structure.

  • i guess the real problem is that there seems to be a backup between what is transmitted by the arduino and the point at which it is processed by the PC – Jack Frye Sep 13 '17 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.