Pressure Recorder (datalogger)

I was asked to help develop a program that controlled the pressure and would record on file.

The project is a assembly of some form arduino to demonstrate the correct result of the program, come riasked.

Description

This is not meant to be design compyear, I would say only a test of a program. I've put together four modules which can be connected yet Arduino Nano or an Arduino UNO, like that of my friend.

I modules are a liquid crystal display, a reader for SD memory, a clock module with DS3231 and one for the bluetooth. The program also provides a different configuration with a shield that contains the SD card reader and the DS1307 RTC.

Ioreover it includes a divider for the’ entrance of communication HC module-06, for compatibility to 3,3 Volts used by the module bluetooth.

The program allows a large degree of configurability, which it is determined at 'start of the source to the lines of #define, I will explain the details below.

There have been various difficulties, a very special was to understand why he did not write the file to the memory. In fact, as cited from the site, the name remained in the format 8.3. For this the file name is a sequential number dialed in the format ggmmaiii, which

gg I am the day of the date

mm it reported a month

a it is for the 'year

iii is a sequential number, if a file existssse already It adds a new one

The project includes some special features:

  • Automatic control of the display brightness.

  • The file recording provides a programmable period, for both of the samples writing time interval and also the frequency of change of the file name.

  • Reading the report via serial or via bluetooth. Obviously it depends on connections arranged.

  • The files are maintained and are not overwritten. This is to prevent the loss of previous recordings.

  • The program allows two versions of hardware, one for the display connected in parallel and one for the connection via I2C. The latter because my friend has that kind and one shield that contains the 'clock and SD reader. As Picture.

  • Simple implementation via serial communication. classic type with Arduino or TX leg monitors with levels of 5 V, or with a partiore connect the bluetooth module.

 

 

 

As can be seen here alongside with a

connection via smartphone, with the program Serial Bluetooth Terminal.

Well, the date is not the one that sends the program, It is rather included in the Android program.


Electric Scheme

The diagram describes the connection to the leg of the brightness control that is connected to the pin 15 del display. Since the display library has no such representation I made some account. Even with the 'I2C interface connected to the pin 15 It is taken by this scheme. The library for the display, It provides only a simple control on or off the backlight.

Program Description

The program was compiled with the Arduino IDE version 1.8.7. The file also contains the libraries, to avoid misunderstandings and possible changes in future versions.

The variables that are used to configure the following:

#define RS 7

#defined 6

#define D7 2

#define D6 3

#define D5 4

#define D4 5

Normal definitions for parallel connections of the display type.

 

#define CH1 9

Leg assigned for adjusting the brightness.

#define SENSOR A1

It allows you to choose the analog channel the sensor reading.

#define LDR A3

Definisce il channel analog from where to take the photoresistor signal.

#define PARMODEL

This allows to choose the compilation depending on the available hardware configuration.

When removing the comment mark, allora you opt for the model parallel (compatibithe with driver Hitachi HD44780) and the 'clock is the one with the DS3231. In the opposite case it uses an I2C interface with a PCF8574 for the same type of display, much to conserve pins for other functions. With thisto Build using a DS1307 clock edge of a shield aforementioned.

#define DEBUG 0~1~2

You set if you want to use the serial communication. There may be 2 debug levels that give the 'opportunity to determine which messages to present to the serial and display.
If it were written 0 instead of one, then all of the serial is not included in the program compilation.

#define LCD_ROWS 2

#define LCD_COLUMNS 16

It defines the size of the display. By varying this would also imply other changes in the program that only provides for the representation on the actual size defined by these two lines.

#define LOG_INTERVAL 10

This determines the sensor sampling frequency, expressed in seconds. What the program does in every 10 seconds.

#define chipSelect 10

It determines where to be cleared l 'activation of the SD card. Although the library claims to have the leg 10 as an output. So by changing this does not imply that you have the leg 10 set free.

#define VMIN 102

#define VMAX 921

#define MINSCALE 0

#define MAXSCALE 160

Queste definitions determine the values ​​of reading and conversion of the channel. In this case the sensor It has the value of 0,5 V to zero and 4,5 V feet to measure maxim.

Quindi converts to the ADC points with the formula

V / 5 * 1024 for the minimum would 102 and for the maximum 921, rounded

such as those set above.

Gthem other two are the values ​​to be presented to the display after the conversion with the function Arduino map(). Minimum and maximum respectively.

#define CHANGEFILE (14400 – LOG_INTERVAL)

Questor defines the period of many seconds to write to a single file. In case breaking of power, the program will not overwrite an existing file. For this there is a routine that checks to see if there are files present.

in this way it calculates the hours correctly in multiples of 3600.

#define BGTVMIN 0

#define BGTVMAX 1024

#define BGTMINSCALE 20

#define BGTMAXSCALE 255

Questand lines, determine which of the PWM control of the display brightness values. Always with the conversion of the function map(). That is the value read from 'analog input of the voltage divider is converted to a PWM-scale from a minimum of 20 a 255. Wanting to make the finer things, you can do the test when the photoresistor is completely obscured and put what a BGTVMAX, also vice versa for when it is strongly illuminated it is detected the value to be put BGTVMIN.

A small description of the function sprintf():

%0?d It is determined to write a decimal number with filling with zeros to the missing digits. With ? It determines the number of digits to represent.

The function newFile() checks whether a file already exists, and then increase the counter.

For this you try a new and occurs if this name is already assigned to a file. For example, if the system is rebooted frequently, l 'last file is not overwritten but it adds one with an increase in value from 0 a 255. I wanted to put the number in hexadecimal, but perhaps I have not yet understood how to write for sprintf(), because it becomes more complicated to interpret.

I considered to use only a figure for the annual period descivere, so as to guarantee the write data 10 years, without removing the files from memory.

In the program there are two conditions that restrict the representation within its extremes:

sensorVal = (sensorVal > VMIN) ? sensorVal : VMIN;

sensorVal = (sensorVal < VMAX) ? sensorVal : VMAX;

What affect the representation beyond the limits. It means that values ​​beyond the limits are not accepted and is therefore only represented the minimum or the maximum, depending on the case.

Last note:

When the program encounters an error in the detection SD or of 'clock, then does not proceed and crashes. Just in case the serial he has not activated may notice messages.

When it detects that the 'form of time has been lost, with the serial connection you can have a further control in order to directly set a time or to allow to load the connected computer.

This option presents a request with 3 choices:

Y It allows you to enter the date and 'time in the format yy / mm / dd hh:mm:ss. There is not
a real constraint in the format, one or 2 figures makes no difference, only worthy of respect
delimiters of the fields that are / : and a space between the date and 'now.

FROM will skip the 'wait and continue the program with the' timetable unchanged.

H It allows you to stop the program proceeding. So as to facilitate the restart with the reset button.

Any other key or waiting for 3 seconds, It allows you to load the 'time of
computer.

For this reason, the choice must be performed in the period 3 second, otherwise the program automatically decide to upgrade the 'time. Considering that the serial monitor the IDE must also enter the d 'send button, to take command.

Therefore you must enable it for this or be able to see the cause of a malfunction. I would therefore advise to keep the serial active during the initial trials and only when one is sure of the operation then disable this option if you wish. After all, it does not occupy much of the Arduino work period.

The display is updated once per second, why even the writing process of the sample returns to the minimum frequency limit. Del rest for periods of writing using the dell 'RTC function that reminds me of the minimum value in seconds.

The sample has a function to take at least 10 readings and to average. The maximum can be 64, but it must intervene directly to the source line. Since it uses a variable 2 then bytes 64 It is the upper limit.

The program is used here for pressure conversion, however, it is not limited to that specific case. In fact, the values ​​that can be configured allow the reading of many types sensors which have an analog voltage in response that can be read with the ADC converter arduino.

The package you can download from my drive.

I put a video on youtube.

VOTE
2 replies
  1. Picmicro675
    Picmicro675 says:

    Bluetooth is connected directly to the hardware serial Arduicoso, which is known in the diagram. You could make a little noise when you want to write a new firmware. For what it is advisable to put a removable jumper when writing a sketch.

    Approvals
  2. gvsoft
    gvsoft says:

    I am not very convinced or maybe I misread: who manages the bluetooh ? In the sketch I do not seem to see it.
    For the rest I intend to read better sketch: the first reading was not convinced.
    Greetings

    Approvals

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply