I am having trouble getting my Particle Electron working with the Sparkfun OBDII UART Board.
As a first step I wanted to have the Particle connect to over serial to the board and send commands through the serial monitor in Particle Dev.
I got stuck very early with the command "atz" not being responded to by the UART board.
I am perplexed why this doesn't work on Particle. I try the exact same thing with an Arduino Mega and everything works fine
Does any one have any insight to why I am not able to get it to work?
I thought it may have something to do with the Arduino being 5V and the Particle Electron being 3.3V. However, When I look at the signals sent on O-Scope both traces are the same, and both have an amplitude of 500mv.
Code:
SYSTEM_MODE(MANUAL);
void setup(){
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}
void loop(){
// read from port 1, send to port 0:
if (Serial1.available()){
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()){
//int inByte = Serial.read();
int inByte = Serial.read();
Serial1.write(inByte);
}
}
The hookup guide on SparkFun specifically says that you need a 5 volt Arduino board. How are you measuring this 500mv signal that you are seeing? Have you tried using a 3.3v to 5v level shifter?
I’m going to try a level shifter, I was using an older Sparkfun one BOB-08745, and its actually been retired due to an issue of not returning 5V->3V. I will be getting their latest one and retrying, thank you for the suggestion.
I could use your help though on understanding my mistake for the voltage amplitude of UART signals. I was measuring the RX input on the OBD and Ground on the particle.
The scope showed 500 mV on measure, How would I measure the correct voltage amplitude?
@bko, You beat me to it. But why would he see 5v coming from the Electron? I was assuming that when he said he measured 500mv on both, he was referring to the Electron and the Mega.
Hmm… just looked at the STN1110 data sheet, and it says that the RX input is compatible with 3.3v and 5v logic, so that’s probably not your problem (although I still don’t understand your scope trace).
Still having no luck getting an answer from the OBD board.
Again, I am using the below script to confirm I can send serial commands to the SparkFun OBDII Board.
Here’s the simple script to take data from the serial monitor to the Serial1 output.
Also! I have set the OBD board’s baud rate to 115200 already.
SYSTEM_MODE(MANUAL);
void setup(){
// initialize both serial ports:
Serial.begin(115200);
Serial1.begin(115200);
}
void loop(){
// read from port 1, send to port 0:
if (Serial1.available()){
int inByte = Serial1.read();
Serial.write(inByte);
}
// read from port 0, send to port 1:
if (Serial.available()){
//int inByte = Serial.read();
int inByte = Serial.read();
Serial1.write(inByte);
}
}
Here is my wiring setup. I am using my 5V signal from the USB Voltage. (Battery and USB cord removed for photo)
Finally I am even able to read the opening chirp from the OBDII card where it says its software revision on startup. I observed this by having the particle serial monitor
Have you tried a lower baud rate? There is certainly some rounding of 5V signal rising edges there in your scope photo. It is hard to say at that horizontal scale if there is a problem or not.
If there is some command you can send in a loop that just returns a known status, I would write special test code to just send that in loop with 500 or 1000ms delay and see if it ever works.
That doesn’t really answer my question. The code you posted doesn’t show how you’re sending the AT commands. Are you using a terminal program for that? If so, are you using the same one for the Particle and Arduino tests?
Can you use the same monitor for both tests? I’m wondering if they both append carriage returns or not, or whether there is some other difference between the two that might be causing your problem.
I tested the two monitors. The Particle monitor in Dev appends a linefeed character (Decimal 10) to the text you send; I didn’t see anywhere that you can change that. The Arduino monitor lets you set that with a drop down menu at the bottom of the monitor window. If it’s set to carriage return, it sends a decimal 13 (is yours setup that way?).