Send the asci command to get the sensor value

Hello,

I'm new to the arduino world!
I am facing a problem. I am trying to create a system based on a radon sensor.
The sensor communicates with the arduino UNO via UART TTL 3.3V, so I connected the RX, TX pins, I used a level converter between the sensor and the arduino (the Arduino UNO has a logical level of 5V).
My problem is that in order to receive a value from sensor, I have to send the character "r" to him and wait for a response. Until now, I have worked with sensors, so to speak, commercially, in which codes are found everywhere.
I am attaching the datasheet of the sensor

If you could help me, I would be very grateful

RADON_SS_1.pdf (1.0 MB)

Post your code!

1 Like

In don't have acces right now to the computer, but i didn't do very much. I tried to use serial.write to send 'r' char and serial.print to read the value if serial is available.

As i said I am now and I really need to solve this because is for my degree project!

Please post whatever you have done so far. Also, post the connection diagram among UNO, level shifter, and sensor.

1 Like

You can't use the same serial port to write('r') and then to print something to the serial monitor. Use 2 different serial ports.

What level translator do you use? Mosfet BSS138? Or TXB010x? Where x stay for 1 or 2 or 4.

1 Like

Hello.

Ok. I will do my best to respond right away!
Thanks

The sensor has to be on for one hour before it reports a result and only has an output once an hour.

Post your code in code tags.

Strict warning if more than 3.3V is on the RxTx line the sensor is poo!

Has the sensor format been set before the attempt to communicate the 72H ('r')?

Seems the sensor needs a trailing cr/lf???

Sensor data is in the format so using the < and > as sentence begin ends will work?
See

1 Like

After powering up for the first time, the sensor requires 1 hour time for warm-up; so, the first valid data is available after 1 hour. After that the fresh data is available in every 10 minute time. The following excerpt is from the sensor data sheet.

radondataupdate

1 Like

Thank you from your answer. I understand. I use Bi-Directional Logic Level Converter Hookup Guide - SparkFun Learn, so its BSS138.

Hello. Thanks for help!
the circuit diagram is as in the attached figure, but instead of what is connected there, I have my sensor. The connection is as follows: I connected the Tx wire to the tx pin of the sensor, Rx to the Rx pin of the sensor, ground to ground, 3.3V to pin 3.3 . V In addition, from a separate 5V power supply I connected the Vload pin of the sensor.
LogicLevelFixed

I know this, but I don't know what code to write to get the values ​​from the sensor and know that it works.

Bloc citat
After powering up for the first time, the sensor requires 1 hour time for warm-up; so, the first valid data is available after 1 hour. After that the fresh data is available in every 10 minute time. The following excerpt is from the sensor data sheet.

Uno Rx to sensor Tx and Uno Tx to sensor Rx.

1 Like

I will try! Thanks, but still i dont know, how to code exactly. maybe you can give me one exemple or hint to know how to start

This was not helpful,

?

I would suggest to make connection among UNO, level shifter, and sensor as per Fig-1; where, the UNO has used Software UART Port (SUART) as the Hardware UART Port (USRT) remains engaged with PC/IDE/SM. At the moment do not connect any other device with the system except the sensor. Once the sensor is found to be working, then connect other devices one-by-one.


Figure-1:

Test Codes: (just a rough idea). You may make it working on trial-and-error basis.

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3); //SRX = DPIN-2, STX = 3
char myData[20];

void setup()
{
  Serial.begin(9600);
  SUART.begin(9600);

  SUART.print('k'); //Soft reset/Kill all ongoing processes
  SUART.print('c'); //data will come in ASCII format
}

void loop()
{
  SUART.print('r'); //asking for data ?
  while(SUART.available()>0)
  {
     char y = SUART.read();
     if(y == '<')
     {
         byte m = SUART.readBytesUntil('>', myData, 20);
         myData[m] = '\0';  //insert null-byte
         Serial.println(myData);
         memset(myData, 0, 20);          //array clear
         delay(10*60*1000UL); //wait for 10-min
     }
}
1 Like

wow!

Thank you very much! I can't wait to try it tomorrow and I'll let you know what I get up to.

In some sensor that need an ASCII command to respond, the best way that i use is change the Serial.print by the Serial.write and the value to send always in HEX example Serial.write(0x48).

later, wait the response ande reads the value sending of the sensor. The method of reading using char or string is your choince

1 Like

For the particular sensor of OP of this thread, the required command (to receive ASCII coded data) is:

Serial.print('c');
===> Serial.write(0x63);

1 Like

Hello
question related to the diagram: why do I have to connect the 3.3V pin of the arduino to the 3.3V pin of the sensor?
thanks

So to understand that I should modify with serial.write everywhere?