Articles Hierarchy

Articles Home » Arduino Projects » ARDUINO WATER MONITORING


i got a mail from BIOROCK with some sensors to check on water ( quality ).
some can be fix installed ( possibly even in our underwater powersupplies )
some are lab equipment.

as most of them are serial types,
i will try to use the hardware serial from arduino MEGA for this project.

SENSORS: from atlas-scientific
- Scientific Grade Silver / Silver chloride pH Sensor ( BNC to ser TTL board )
- Oxidation Reduction Potential (ORP) ( BNC to ser TTL board )
- scientific grade platinum conductivity sensor ( BNC to ser TTL board )
- submersible temperature probe ENV-TMP ( analog )
- galvanic dissolved Oxygen D.O. Sensor ( BNC to ser TTL board )
- Color Detector Sensor ENV-RGB ( serial sensor )

as there are several sensors and for each 3 jobs to do:
- calibrate sensor
- make one single measurement
- start continuous measurement ( time slices / multitasking )
i want to use my usb menu structure for arduino,
what can be operated from any terminal software
or even from processing... for a better look.

but this structure has no submenu level and only 1 character input operation.

[ space ] shows the menu options

[0] reset all conti operations

[T] start a basic serial terminal emulation to the ( serial ) sensor

[a] measure sensor a one time

[A] start conti measurement sensor a with timer x sec.

[1] calibrate sensor a


to make documentation more easy i will give just a link to a
google spreadsheet here and i don't need to do
that time consuming job with the snapshot photos, filetransfer, html image..

the sensors come with
- cable and BNC connector,
- a BNC board to breadboard adapter
- a microprocessor doing the measurement and serial communication (PIC..)
also with breadboard pins
and there the
+ arduino hard ( or soft ) -ware serial TTL (5V) ( not RS232 ) can connect,
+ or the also available Atlas Scientific Debugger ( FTDI chip ) USB adapter.

picture from atlas-scientific

checking on the examples provided i see first time the use of the
Serial_Event function.
and as it worked well for a direct terminal emulation
i started to modify all my menu code using it.
after 2 days i give up and started my project again
after i learned the hard way that the event thing only runs in main loop???

- look for usb / operator input by check with
( but only every 500 main loops ), the first character found is used as a menu choice.)

- if a setpoint input / also used as a sub menu / is required i do a new function
serial wait with time out and optional convert to int and float, and default number
-- on timeout,
-- only ENTER ,
-- or if i find any other character besides 0 ..9 , . -
( internal functions i found in libraries do much less checking )

- only the sensor read i do with above serial.Event functions,
as long we use hardware serial.
it's kind of asynchron communication, just print to sensor some string and hope
the event will catch the sensors answer.
- for software serial use serial wait with timeout for sensor reading also,
enabeling each softserial link by the mySoftSerial_X.listen()
still see timeouts on this softserial ports

but this serial wait for softserial sensors might kill the main loop
and with this the serial_Event timing???

hope the arduino MEGA is up to this job,
USB operator interface,
3 hardware serial links,
2 software serial links,
one analog measurement
kB of menu texts. ( sometimes i see the F("") causing error near 29500byte code?? for MEGA!! )

Starting with the hardware is always a big issue for me,
need tools like drill and saw because i could not find a fitting board for the box,
and the too smart prototype copper lines limit the MEGA position layout.

also need holes in the box: for USB, power, 4 BNC, 2 sensor cable
here the start: with arduino mega head down layout

problem again with the softserial, D8,9,10,11,
are on the non fitting spaced arduino header.

show inside of BOX:

and find some more photos

for download pls see code

as i send the hardware away already but not happy about the soft serial timeouts...
i made a new setup.
the sensors with the LEDS anyhow not help me too much about this problem,
? did he not got the question ? did he not answer anyhow ? or not in time ?
so i set up a arduino MEGA ( china copy ) with the project software
( so same hard and software as in above box )
and connect S4 S5 to the T1 T2 of a other old arduino mega 2010,
with a ECHO software.

wiring this board with MEGA softserial
RXD1 19 _ D8 (S4 TX)
TXD1 18 _ D10 (S4 RX)

RXD2 17 _ D9 (S5 TX)
TXD2 16 _ D11 (S5 RX)

now i can operate the project but talk to a other arduino
( instead of the sensors ) and see that in a second terminal window.

add i can adjust delay timer... for simulation

and, i see no timeout, unless i just was uploading new code.

Hmm, i m a little bit disappointed because i wanted to test the
ALTSOFTSERIAL Library from Paul Stoffregen.

But i read something at adafruit what i not fully understand but its heavy: AltSoftSerial Library, for an extra serial port. Paul Stoffregen, designer of the Teensy board we stock has an intriguing new Arduino Software Serial library. This one uses the 16 bit timer to do data capture and transmission…

It’s ideal when you need simultaneous data. If you try the example that comes with SoftwareSerial in Arduino 1.0, and type “Goodnight” in the Arduino Serial Monitor, you’ll see what actually comes out of pin 3 at 4800 baud is “Goot”. The characters “dnigh” are lost. The reason is because while SoftwareSerial is sending the letter “G” at 4800, the letters “oodnigh” arrive at 57600 baud. Only “oo” are held in the UART registers. The rest are lost because interrupts were disabled for too long.

Often people misunderstand these problems and falsely attribute them to NewSoftSerial’s inability to keep up with the rapid pace of data. In this example, the failure is actually on the hardware serial reception. NewSoftSerial is easily able to work at 4800 baud, but in doing so it interferes with other things.

more tests with a longer string echoed back also ok , never miss a character.
the echo is now "Tx got:" and the command
( thats closer to reality, sensor are asked by a 1 character command
( like R and CR ), but the answer contains the measured values, and can be a long string.

i tested echo delays between 10ms and 2800 all ok,
but when i simulated late answer with 1000ms for (S4) T1
and 3100ms for (S5) T2 ( timeout at 3000 )
suddenly i see timeout for both!!
and i see the delayed answer from T2, what actually should NOT SHOW
i have reproduced a error and have something to work on

while when i use the S5 alone i get the expected timeout, and at next read the string in the cleanup read / and question answer timeout again _ all as expected ( softserial buffer for one works well ).

when i do a S4 S5 in very slow cycle ( 5sec / 10sec conti jobs ) also all works fine,
S4 ok, S5 timeout, no bad strings !
but not even cleanup read??? where does the last text go?
possibly S4 S5 have to share one buffer and the Sx.listen command clears it?

but there is a certain timing, (S5 fast conti ) where i get also this S4 timeout
what should not happen with this strictly serial wait functions???

but maybe dummies like me should stay away from projects with 5 serial links!

follow up here