Software Serial Program

Hi guys!

I have a gas sensor with 5 pins (GND,VCC,VIN,TXD,RXD). My UNO board is connected using USB cable and external 9V power adaptor. I'm trying to run a software serial program and in the serial monitor if I change the baud rate to 9600, my serial monitor response is random characters .
Any reason why it happening?
Thank you.

SoftwareSerialExample.ino (1.35 KB)

Rishi_me:
How can I get the RX part working?

It's probably not relevant to your problem. The LEDs reflect hardware serial operations. The monitor baud rate must match whatever you set the Serial rate to.

Please provide a link to the gas sensor being used

I can see TX LED blinking on the Arduino but not RX.

Those LEDs are irrelevant when using SoftSerial. I assume that you have connected the sensor to the pins defined for the SS object and not the pins marked Rx and Tx on the board.

Rishi_me:
Hi guys!

I have a gas sensor with 5 pins (GND,VCC,VIN,TXD,RXD) and connected it to UNO board with USB cable

How could you connect it with a USB cable?

Make a drawing showing all the connections and post a photo of the drawing.

Also post a photo of the connected cable.

...R

Thanks for your information guys. My bad for telling you that sensor is connected using USB. It has been modified.

Please see the picture to get an idea of my connection in the attachment-1.

I wanted to check the communication between sensor and Arduino. Can you please suggest a better way to do that ?

Can you please tell me whether I can/can't connect the sensor with TxD and RxD directly to Pin 0 (Rx) and Pin 1 (Tx) on Arduino UNO to check the output?

SoftwareSerialExample.ino (1.35 KB)

Robin2:
Make a drawing showing all the connections and post a photo of the drawing.

Can't see from the picture which pin on the sensor is which. If you want help, then when people request information from you about your project you should provide that information.

I'm using Pin-10(Rx) and Pin-11(Tx) and I have used the sample Software Serial program, how do I know that the sensor is Sending or Receiving data? Do I need to tweak the code a bit?
Thank u

CO gas sensor- Pin Image.PNG

Robin2:
Make a drawing showing all the connections and post a photo of the drawing.

Neither of the pictures you posted show which pin is which. Please do what was asked. If you want help, then make a drawing showing the connections and post it. If you want your thread to die with you getting no help at all, then post something else without the drawing. The choice is entirely yours.

OK. I give up. You're not going to draw us a schematic. You're just not. I'm not sure why you won't. Don't you want help with this? It's not very clear on the left side of the picture you annotated which pin the red and white wires are going into.

But really, don't bother. I bet most folks have moved on by now and figure you just don't really want help. I know for sure I won't try again. You shouldn't have to be asked so many times to provide something so simple.

Bye. Hope you get it working.

Rishi_me:
What do you think I did in the attachment-1? It's just +5V and GND pins and your worried about the side angle now???

That is a picture of a circuit with some text on it. I wanted a circuit schematic. In the picture with some text on it, I can work out a couple of the connections, but not all of them. If you want my help I need to know the whole circuit. When you draw out a schematic then you leave no doubt.

But really, you should just do it because the person you asked for FREE help asked you to. You don't need a reason. You want help, then give the people trying to help you what they say they need to help you.

But don't bother now. I won't try to help you anymore. I don't like it when people waste my time. So you are on the ignore list from now on.

schematic. Please have a look

You layout looks kosher, something it would have smart to do in the first place.

At least the wiring is sensible, but there are no details about the sensor. The sensor is a serial output device but you need to be sure

  1. the output levels are OK for use with Arduino
  2. Arduino's voltage output is sufficient
  3. the baud rate matches Arduino

I imagine all if these will be apparent in the data sheet.

the sensor information has been attached. I am having trouble with the communication protocol in the data sheet especially commands section(pg.5). Stuck understanding the output.

I tried programming by comparing with another similar program. Sorry if the coding doesn't make any sense but I'm still learning. Your time and help much appreciated.

Thank u.
Serial Monitor response: Without Sensor connected

CO ppm = 4294967295
CO ppm = 4294967295

Serial Monitor response: With Sensor connected

CO ppm = 4294967295
CO ppm = 4294938112
CO ppm = 654
CO ppm = 4294936066
CO ppm = 4294967174
CO ppm = 4294961919
CO ppm = 235
CO ppm = 0
CO ppm = 0
CO ppm = 0
CO ppm = 4294938112
CO ppm = 654
CO ppm = 4294936066
CO ppm = 4294967174
CO ppm = 0
CO ppm = 0
CO ppm = 0
CO ppm = 0
CO ppm = 0
CO ppm = 0
CO ppm = 0

ZE03 Electrochemical Module V2.4.pdf (472 KB)

sketch_jul19a.ino (1.77 KB)

Hi,

I had a look at the pdf you attached. Since you are currently getting getting probs with the serial COMs with your CO sensor why not try using the analog output of the sensor with one of the Analog inputs of the UNO and print it out to the serial monitor?

At least then you could establish if your sensor is working OK for starters...

Sorry just to confirm, the analog output you mean Pin 11 (Tx)?or Sensor Analog voltage pin VO? Can you please tell me how to achieve "using the analog output of the sensor with one of the Analog inputs of the UNO and print it out to the serial monitor?"

thank you.

It would appear that the device simply sends TTL serial signals every second @9600 baud. I think you just need to read that via software serial, analyse it, and send results to monitor.

The device is 5v but serial is 3v. Arduino should read it OK but, if you want to send signals to it, you should use a 1.2k/2k voltage divider on the Arduino Tx. You might not need to send commands anyway.

http://forum.arduino.cc/index.php?topic=396450.0

I have managed to check the analog voltage of the sensor (VO pin) using AnalogRead program and its 0.6 V mentioned in the data sheet.

At the moment I'm not worried about sending data to the sensor. I'm trying to figure how to use the expressions like:
FF 01 86 00 00 00 00 00 79- active upload

FF 86 00 00 00 00 00 00 7A (concentration value is 0)- receive

I used:

byte readCO[] = {0xFF, 0X86, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X7A}; //Command packet to read CO
byte response[] = {0,0,0,0,0,0,0, 0, 0};

Is this the correct way to approach reading ppm?

Nick_Pyner:
The device is 5v but serial is 3v. Arduino should read it OK but, if you want to send signals to it, you should use a 1.2k/2k voltage divider on the Arduino Tx. You might not need to send commands anyway.

Serial Input Basics - updated - Introductory Tutorials - Arduino Forum

I have gone through the link you posted and in the example- 2 there was a mention about "Receiving several characters from the Serial Monitor". If you can modify that code in terms of the above expressions in HEX form that would be great. Just few line of program will do
Thank u.

I'm afraid that is beyond me. I don't think you need to "modify the code", you just to break up the HEX received to the data you want, which is probably just a little bit of it. I guess this is one for Robin2.

since u got everything in an array, I guess what you want is a for loop to send you hex data using the software serial "write" function

then check for when the sensor reply back to pick up the 8 reply bytes using software serial "available" and "read" functions.

Should be easy enough for you to give it a try and code it in! :slight_smile:

sherzaad:
since u got everything in an array, I guess what you want is a for loop to send you hex data using the software serial "write" function

then check for when the sensor reply back to pick up the 8 reply bytes using software serial "available" and "read" functions.

I know it's too much to ask for. But can you please try and write for me those few lines of code? I don't have much programming experience but please correct me if I'm wrong

According to this code, I'm sending a request (byte packet) as you mentioned

void sendRequest(byte packet[])
{
while(!softSerial.available()) //keep sending request until we start to get a response
{
softSerial.write(readCO,9);
delay(50);
}

waiting until I get a response

int timeout=0; //set a timeoute counter
while(softSerial.available() < 10 ) //Wait to get a 9 byte response
{
timeout++;
if(timeout > 10) //if it takes to long there was probably an error
{
while(softSerial.available()) //flush whatever we have
softSerial.read();

break; //exit and try again
}
delay(50);
}

And if I have the response, then I'm reading the packets.

I think the code needs some tweaks and if you can change it that would be great.