SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By byter
#190742
Hello,

I recently purchased a couple of Sparkfun Pro Micro 3.3V boards. I am using them to send temperature information over the internet via an ESP-8266 WiFi module.

I had used an arduino uno 3.3v board to do my initial circuit, an everything worked. I have since wired in one of the boards I have purchased from spark fun, and everything still works, albeit with a little quirk.

What I do is that I read the temperature data, and then build an HTTP request that places the temperature information inside URL variables. The end point takes this information and stores it in a database.

On the Sparkfun pro micro, I am using pins 0/1 to communicate with the wifi module. So in the arduino code I am using Serial1. I am also using pins 2/3 as a SoftSerial to get debugging information about what is happening. I set the baud rate for both of these serial connections to 115200. This speed is required for the firmware that comes on the wifi module.

The static information (things I am not reading from Serial1, for example SoftSerial.println("hello world")) I receive over the SoftSerial is always consistent. I don't ever seem to get any messed up characters. However, when I read data from Serial1 and print it out via the SoftSerial, it comes out completely garbled. Interestingly enough though, it's often very consistent in what comes back. The garbled text always matches (at least as far as I can see).

I would think this would then be true for the data that I send via Serial1 to the wifi module, but it does not appear to be the case. The data is transmitted consistently and stored in the database, with the correct information. The header I generate looks like this:
Code: Select all
GET /temp/j_proto_1/24.00/28.75/1 HTTP/1.1
Host: <my_ip>
Connection: close
I believe this to be long enough to get garbled in sending it over if it was going to, but it seems to be sent over to the wifi module just fine. Not to mention all the other commands I need to issue to the wifi module such that it is ready to send an HTTP request.

I have tried the two following ways of reading from Serial1 and sending via the SoftwareSerial (both of which work on the uno):
Code: Select all
if(Serial1.available()) {
            String s = Serial1.readString();
            monitor_serial.println(s);

            if(s.indexOf("OK") != -1) {
                return true;
            }

}
Code: Select all
if(Serial1.available()) {
            monitor_serial.write((char)Serial1.read());
            delay(10);

}

In summary, I am able to send complicated pieces of text to the wifi module, but unfortunately when I try to read them, I get lots of question marks and incorrect characters.

Why is this happening, and how can I go about fixing it? This makes debugging what happens with the wifi module very difficult.
By byter
#190780
Setting a new baud rate for the wifi module seems to have done the trick in solving my issue, though I still find it curious that the baud rate didn't seem to be an issue with the arduino uno and software serial.

Thanks for the help.