Data Logger Without Serial

Hi!

I am working on a project using a scientific probe, an arduino, and a ENV-32x data logger.

Normally over the usb serial monitor I would save data to the data logger using the following commands...
*"the asterisk followed by letters saves the string to the next page of memory."
D <-Clears the memory
R0 <- recalls the memory.

This may be a simple task, but i cant wrap my head around it...

i need this probe to run without being connected to a computer.
So i need code that will take a reading from the probe every 10 seconds, then save that value to the data logger.

Ex.
If the temperature is 55 degrees.
to program the data logger i would need to type.
*t=55

Here is a link to describe the function of the data logger and how it connects to the Arduino.
https://www.atlas-scientific.com/_files/code/Super-EZ-COM.pdf

Thanks

What a stupid page. Load a real sketch, that uses Serial.print() to send commands to the device. Or, connect it to different pins, and use SoftwareSerial to create an instance that talks to, and listens to, the device.

Normally over the usb serial monitor I would save data to the data logger using the following commands...
*"the asterisk followed by letters saves the string to the next page of memory."
D <-Clears the memory
R0 <- recalls the memory.

What is going on here is that The Arduino USB-Serial onboard hardware is being used to send characters from the PC/workstation to the probe... An "interface" at 38.4K BAUD.

To automate the probe, you just need a sketch to loop through a SPST switch on any digital pin. If the Pin is HIGH (open, use the internal pull up resistor) then send a "*D" and if the Pin is LOW, send "*R0". Of course, you could write code to read multiple pins, read time/date from an off-board clock module, and perform most any command the probe can handle... Including reading the probe data and writing to an SD card.

Ray

When I look at that page I see a troubleshooting example and wonder WTH? You need the PC to run THAT.

If I read the first post right, you have TWO devices to connect. ONE is the probe and the OTHER is a datalogger.

If I read the first post right, you have TWO devices to connect. ONE is the probe and the OTHER is a datalogger.

Now, i'm thinking WTF? Maybe you are right GoForSmoke, but my initial read was the probe is the memory logger. The PDF showing the Arduino starts by saying, "This method of communication should be used for troubleshooting...." So, until the Op answers, I think we are in the dark.

Ray

It looks like he's trying to get the data logger going for now.
Still the end code will need to accommodate the probe.

Using Arduino as a pass-through because it sets up PC comms is kind of... well it leaves me a bit uneasy.

That example code is missing the all-important serial set up.

void setup()
{
Serial.begin( 38400 );
}

void loop()
{
}

Sorry for the confusion,
The link was just to show you what the part was, its limitations, capabilities, and how it attaches to the arduino.
I tried using software serial to make it happen but it didnt seem to work properly, I will have to sit down and work hard on it.

If you have an arduino UNO, remove the chip on the socket (ATMEGA328P-PU) and try again. If you have a USB TTL adapter, use that instead of Arduino. You don't need Arduino for testing.

PaulS,

It seems like everybody is jumping on the Arduino band wagon. This company even went through the trouble of creating a Fritzing part. LOL, some sample code they gave.

booliminator:
Sorry for the confusion,
The link was just to show you what the part was, its limitations, capabilities, and how it attaches to the arduino.
I tried using software serial to make it happen but it didnt seem to work properly, I will have to sit down and work hard on it.

Did you wire the SoftwareSerial RX and TX to the logger TX and RX, ie crossed? You're supposed to. What one transmits, the other receives.

liudr:
It seems like everybody is jumping on the Arduino band wagon. This company even went through the trouble of creating a Fritzing part. LOL, some sample code they gave.

I agree, they provided another .ino file that had code that was supposed to work on the UNO but was completely broken and didn't work in the slightest. Thats how I ended up just using the blank sketch to test the device.

Also, I'm sure i tried both orientations of the TX -> TX RX -> RX, and TX -> RX RX -> TX, but i may have made another mistake during that time, i will go back and try again.

Thanks

Don't take offense: you connected the grounds, right?

booliminator:
Thats how I ended up just using the blank sketch to test the device.

The blank sketch for troubleshooting needs Serial.begin( 38400 ); added in void setup()
For that test you need TX to TX and RX to RX as shown, and power and ground.
The Arduino acts as a passthrough but only after Serial is initialized to get serial on and the speed right.

OOO, taking shots at my intelligence there, haha, no offense taken
Yeah, its all wired up right, and it runs fine with just the blank sketch.

My main question is how, with no serial connection to a pc, can I send serial data to the device.
I was having trouble understanding it because i always run my arduino with a PC, and this probe will be left to log data using a battery pack.

Thanks

If you know how to take data with a PC serial monitor and data acquisition commands, then let arduino send these commands to the device instead. RX-TX this time. How much do you know arduino programming?

booliminator:
OOO, taking shots at my intelligence there, haha, no offense taken
Yeah, its all wired up right, and it runs fine with just the blank sketch.

Sorry if I tell you tell you some things you may know but it's the only way to avoid going in more circles around the maybe one thing that you do not or had not considered. Troubleshooting involves getting rid of unknowns.

I had concern about is it the code or the hardware that's not working. I couldn't be sure from here where the problem is, hence the troubleshooting steps.

I am amazed that a blank sketch gets you 38400 baud serial through the USB chip. It seems like there is a default after all! But hey, this is the first I hear that something actually has worked.

My main question is how, with no serial connection to a pc, can I send serial data to the device.
I was having trouble understanding it because i always run my arduino with a PC, and this probe will be left to log data using a battery pack.

Thanks

You tried SoftwareSerial wired correctly and it did not work? At this point it would be a good idea to trot out your code and at least describe your wiring in exact point to point detail since the problem may be minute and simple.

Do not forget to put your code in code tags, not quote tags. The # button above the edit window makes code tags.

Here is what I have been trying,
I am very familiar with programming with arduino, I have never worked with multiple serial connections, and I just cant understand it.

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

const int delBtn = 5;  
int buttonStateDel = 0; 

void setup()  
{
  
    pinMode(delBtn, INPUT); 
  // Open serial communications and wait for port to open:
  Serial.begin(38400);


  mySerial.begin(38400);

}

void loop() // run over and over
{
  
  buttonStateDel = digitalRead(delBtn);
  
  
  
    if (buttonStateDel == HIGH) {       
       mySerial.println("D");
       Serial.write(mySerial.read());
    }

}

Here, If delBtn is HIGH, I want the arduino to send the "D" command to the device, then for early testing reasons, I want the Arduino to receive the response from the device, which should be "X" and print that in the serial window.

the delete button is attached to pin5, and is properly set up with a resistor to ground.
The RX pin of the device is on on software TX pin 11
The TX pin of the device is on the software RX pin 10

All of the connections are properly set, i tested the device directly prior to use with this code and it responded as usual.

If anyone can show me what I'm doing wrong here, I really don't understand the software serial theory, or how to work with multiple serial connections.

I see one possible issue and one definite issue.

    if (buttonStateDel == HIGH) {       
       mySerial.println("D");
       Serial.write(mySerial.read());
    }

Needs to be broken up so that Serial.write() is not tied to the mySerial.println().

The Serial.write() needs to be inside of it's own if ( Serial.available() ) independent of the if () it is inside of now.

The Serial.write() should happen any time that mySerial() has a character available. Arduino may run 100's to many 1000's of unblocked loop() passes between sending mySerial data and getting anything back. The operations should be independent as if you don't know what to expect or when which is true since "serial has no guarantees".

I don't just want to hand you the code but the next step isn't exactly big.

The possible issue is button bounce. When your loop() gets fast enough, some buttons make on-off contact that looks like spikes on an oscilliscope. This happens for less than a millisecond up to many milliseconds, way too fast for humans, quite a show for AVR chips. My debounce usually waits for the same reading happening over about 5 millis() before declaring the button pressed or not so I have both a debounce state and a button state as well as a time variable that changes every time I detect a change in the debounce state. The rest of the code only goes by the more stable button state.
I don't read and wait for some time then read again as that is a chance operation AFAIC.

I have been speaking with a representative from the company.
He suggested using a different Software Serial library, shown below.
It looks like there is trouble with the code where I put the comment.

#include <AltSoftSerial.h>

AltSoftSerial altSerial;

const int delBtn = 5;
int buttonStateDel = 0;

void setup() {

pinMode(delBtn, INPUT);

Serial.begin(38400);
Serial.println("AltSoftSerial Test Begin");
altSerial.begin(38400);
}

void loop() {
char c;
buttonStateDel = digitalRead(delBtn);

if (buttonStateDel == HIGH) { //looks like between here....
Serial.println("WOrks");
if (Serial.available()) {
altSerial.print("D"); //And here,.... cant find out whats wrong.
}
}

if (altSerial.available()) {
c = altSerial.read();
Serial.print(c);
}

delay(60);
}

Code needs to go in code tags. They're like quote tags but the word is code instead.
Right above the edit window smileys, find the button with the # and that makes code tags.

I have no trouble with the version of SoftwareSerial that comes with my IDE except at 115200 I get errors that I don't get using hardware serial ports. The IDE incuded libraries are version specific.

That said, I liked the SDfat library more than the included SD library when I ran IDE 0023.

This is the Two Port Receive example directly from the File->Examples->SoftwareSerial in my IDE 1.03.
You should have one in you IDE Examples to click open in a new IDE window.

/*
  Software serial multple serial test
 
 Receives from the two software serial ports, 
 sends to the hardware serial port. 
 
 In order to listen on a software port, you call port.listen(). 
 When using two software serial ports, you have to switch ports
 by listen()ing on each one in turn. Pick a logical time to switch
 ports, like the end of an expected transmission, or when the 
 buffer is empty. This example switches ports when there is nothing
 more to read from a port
 
 The circuit: 
 Two devices which communicate serially are needed.
 * First serial device's TX attached to digital pin 2, RX to pin 3
 * Second serial device's TX attached to digital pin 4, RX to pin 5
 
 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts, 
 so only the following can be used for RX: 
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69
 
 Not all pins on the Leonardo support change interrupts, 
 so only the following can be used for RX: 
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
 
 created 18 Apr. 2011
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's twoPortRXExample
 
 This example code is in the public domain.
 
 */

#include <SoftwareSerial.h>
// software serial #1: TX = digital pin 10, RX = digital pin 11
SoftwareSerial portOne(10,11);

// software serial #2: TX = digital pin 8, RX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(8,9);

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // Start each software serial port
  portOne.begin(9600);
  portTwo.begin(9600);
}

void loop()
{
  // By default, the last intialized port is listening.
  // when you want to listen on a port, explicitly select it:
  portOne.listen();
  Serial.println("Data from port one:");
  // while there is data coming in, read it
  // and send to the hardware serial port:
  while (portOne.available() > 0) {
    char inByte = portOne.read();
    Serial.write(inByte);
  }

  // blank line to separate data from the two ports:
  Serial.println();

  // Now listen on the second port
  portTwo.listen();
  // while there is data coming in, read it
  // and send to the hardware serial port:
  Serial.println("Data from port two:");
  while (portTwo.available() > 0) {
    char inByte = portTwo.read();
    Serial.write(inByte);
  }

  // blank line to separate data from the two ports:
  Serial.println();
}

If your PC has a hub, you can run multiple Arduinos at the same time, each with its own IDE and serial monitor. You might need to power the hub but I've done two on just the hub many times. Don't forget to connect the grounds! If you do run serial, 2 wires for data and 1 for ground. Don't just do the data pins

In your latest code you test if serial is available but don't do anything with the available data. This doesn't sound right.