Display detector data on a LCD

Hi all,

my second attempt for help :wink:

I am using a radiation detector which gives per second data via rs232. This I am transmitting with Zigbee to an Arduino Fio to be displayed on a 16,2 LCD. So far no problem, this works.

Problem: The data I recive looks like 0001 0,125 uSievert/h. Space seperated and ending with a new line. Between first and secend row there are on or two spaces depending on the measurement. This sream is too long for my 16,2 display.

I would like to split the stream insofar that I get the uSievert/h in the second line.
Anyone an idea?

Cheers, Oskar

That should be a fairly easy modification to your code. If you post your code then I'm sure we can advise.

Hi and tnx for the answer.

I have two versions of my code. To bring my detector to sending data I need a command sending to it. The only way by now is to do this in loop. I have a second version to try if it works where the command for the detector is outside the loop. Because of some mistakes I had to order a new fio.

First version of my code which is working:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
boolean executed=false;

// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

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

  lcd.begin(16,2); 

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(150);
    lcd.noBacklight();
    delay(150);
  }
  lcd.backlight(); // finish with backlight on  

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0  
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("SSM1 Display");
  delay(500);
  lcd.setCursor(0,1);
  lcd.print("by OS");
  delay(1500);  

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Verbinde SSM1"); delay(500);
  lcd.setCursor(0,1);
  lcd.print("...programmiere:"); 
  lcd.setCursor(15,1); lcd.blink(); delay(500);
}  /*--(end setup )---*/

void loop()
{

if (executed==false){   //Connection to the detector
executed=true;
  // sende am seriellen port " " für programmmodus
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); 
  Serial.print("1"); delay(50); // actual CPS
  Serial.print("H"); delay(50); // Standart Format im Programmmodus
  Serial.print("l"); delay(300); // licht an und aus
  Serial.print("l"); delay(100);
  Serial.print("l"); delay(300);
  Serial.print("l"); delay(50);
  Serial.print("a"); delay(100); // Programmierung abgeschlossen - beginne mit Daten senden
  lcd.clear();
  lcd.setCursor(0,0); //Display info
  lcd.print("...abgeschlossen"); delay(1000);
  lcd.setCursor(0,1);
  lcd.print("sende..."); delay(3000); lcd.noBlink();
  }

    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }

}

Second version - test if works pending:

// --------- TEST -----------------
#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>

// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/
int ssmdat = Serial.read();

void setup()
{
  Serial.begin(9600);
  while (!Serial) {  // Waiting for data via RS232
    ;
  }

  lcd.begin(16,2);

// ------- Quick 3 blinks of backlight  -------------
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(150);
    lcd.noBacklight();
    delay(150);
  }
  lcd.backlight(); // finish with backlight on  

//-------- Programming ASMG90 ------------------
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("SSM1 Display");
  delay(500);
  lcd.setCursor(0,1);
  lcd.print("by OS");
  delay(1500);  
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Verbinde SSM1"); delay(500);
  lcd.setCursor(0,1);
  lcd.print("...programmiere:"); 
  lcd.setCursor(15,1); lcd.blink(); delay(500);
  // ---------------------  sende am seriellen port " " für programmmodus -----------------
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
  Serial.print(" "); delay(50); Serial.print(" "); delay(50); 
  Serial.print("1"); delay(50); // actual CPS
  Serial.print("H"); delay(50); // Standart Format im Programmmodus
  Serial.print("l"); delay(300); // licht an und aus
  Serial.print("l"); delay(100);
  Serial.print("l"); delay(300);
  Serial.print("l"); delay(50);
  Serial.print("a"); delay(100); // Programmierung abgeschlossen - beginne mit Daten senden
  lcd.clear();
  lcd.setCursor(0,0); //Display info
  lcd.print("...abgeschlossen"); delay(1000);
  lcd.setCursor(0,1);
  lcd.print("sende..."); delay(3000); lcd.noBlink();

}  /*--(end setup )---*/

void loop()
{
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(ssmdat);
      }
    }

}

The part sending to the detector with many spaces and delays is mandatory. I don´t care where in the code but I think when it is outside the loop it will be easier to parse.

On nice additional feature would be the first row which are the seconds to convert in hours/ minutes/ seconds. To see a sort of connection time.

Hope you can help, best regards

Oskar

    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50); Serial.print(" "); delay(50);
    Serial.print(" "); delay(50); Serial.print(" "); delay(50);

Why do you make things so difficult/long for yourself?

  for (int i = 0; i < 20; i++)
  {
     Serial.print(" "); 
     delay(50); 
  }

Hi and thanks for the code!!!
This is why I use this forum. I am no programmer, just testing around. So the simplest solutions are sometimes the most complicated for me :wink:

Will test this coming days. Any solution with my parsing problem?

Thanks again

Hi and tnx again for making live easier. The working code looks like this now:

// --------- TEST -----------------
#include <Wire.h>  // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>

// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/
// 

void setup()
{
  Serial.begin(9600);
  while (!Serial) {  // Waiting for data via RS232
    ;
  }

  lcd.begin(16,2);
  lcd.clear();

// ------- Quick 2 blinks of backlight  -------------
  for(int i = 0; i< 2; i++)
  {
    lcd.backlight();
    delay(150);
    lcd.noBacklight();
    delay(100);
  }
  lcd.backlight(); // finish with backlight on  

//-------- Programming ASMG90 ------------------
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("RAD Display");
  delay(500);
  lcd.setCursor(0,1);
  lcd.print("by OS");
  delay(1500);  
  lcd.clear();
  lcd.setCursor(0,0); //Start at character 0 on line 0
  lcd.print("Verbinde ASMG90"); delay(500);
  lcd.setCursor(0,1);
  lcd.print("...programmiere:"); 
  lcd.setCursor(15,1); lcd.blink(); delay(500);
  // ---------------------  sende am seriellen port " " für programmmodus -----------------
    for (int i = 0; i < 20; i++) // Sende 20 x " " mit delay 50
  {
     Serial.print(" "); 
     delay(150); 
  }
  delay(500);
  Serial.print("1"); delay(50); // actual CPS
  Serial.print("H"); delay(50); // Standart Format im Programmmodus
  Serial.print("l"); delay(300); // licht an und aus
  Serial.print("l"); delay(100);
  Serial.print("l"); delay(300);
  Serial.print("l"); delay(50);
  Serial.print("a"); delay(100); // Programmierung abgeschlossen - beginne mit Daten senden
  lcd.clear();
  lcd.setCursor(0,0); //Display info
  lcd.print("...abgeschlossen"); delay(1000);
  lcd.setCursor(0,1);
  lcd.print("sende..."); delay(3000); lcd.noBlink();

}  /*--(end setup )---*/

void loop()
{
    // when characters arrive over the serial port...
    if (Serial.available()) {
      // wait a bit for the entire message to arrive
      delay(100);
      // clear the screen
      lcd.clear();
      // read all the available characters
      while (Serial.available() > 0) {
        // display each character to the LCD
        lcd.write(Serial.read());
      }
    }

}

What I would need now is a separation of the incoming stream.
By now it looks like 0185 0.089 uSivert/h. First row is seconds counting up to 9999 and restart with 0000 (this would be great to having in h m s as connection time. Between first and second row there are one or two space. Then the measurement data and then the unite which I need in the second line of the LCD as it is too long for the first line. Anyone any idea?

Cheers