pull/8/head
dam_git 2021-01-22 08:21:38 +01:00
rodzic 77738128a7
commit ac2138b8e3
22 zmienionych plików z 312 dodań i 38 usunięć

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -2,7 +2,6 @@
VARIO XCTRACK
arduino nano
sensor ms5611
https://github.com/dvarrel/arduino-ms5xxx
damien varrel 07/2020
@ -10,45 +9,12 @@ Based on Arduino Vario by Benjamin PERRIN 2017 / Vari'Up
Based on Arduino Vario by Jaros, 2012 and vario DFelix 2013
https://github.com/LK8000/LK8000/blob/master/Docs/LK8EX1.txt
$LK8EX1,pressure,altitude,vario,temperature,battery,*checksum
Field 0, raw pressure in hPascal:
hPA*100 (example for 1013.25 becomes 101325)
no padding (987.25 becomes 98725, NOT 098725)
If no pressure available, send 999999 (6 times 9)
If pressure is available, field 1 altitude will be ignored
Field 1, altitude in meters, relative to QNH 1013.25
If raw pressure is available, this value will be IGNORED (you can set it to 99999
but not really needed)!
(if you want to use this value, set raw pressure to 999999)
This value is relative to sea level (QNE). We are assuming that
currently at 0m altitude pressure is standard 1013.25.
If you cannot send raw altitude, then send what you have but then
you must NOT adjust it from Basic Setting in LK.
Altitude can be negative
If altitude not available, and Pressure not available, set Altitude
to 99999 (5 times 9)
LK will say "Baro altitude available" if one of fields 0 and 1 is available.
Field 2, vario in cm/s
If vario not available, send 9999 (4 times 9)
Value can also be negative
Field 3, temperature in C , can be also negative
If not available, send 99
Field 4, battery voltage or charge percentage
Cannot be negative
If not available, send 999 (3 times 9)
Voltage is sent as float value like: 0.1 1.4 2.3 11.2
To send percentage, add 1000. Example 0% = 1000
14% = 1014 . Do not send float values for percentages.
Percentage should be 0 to 100, with no decimals, added by 1000!
test sentence PRS, more shorter
*/
//https://github.com/dvarrel/arduino-ms5xxx
//ms5611 library by Roman Schmitz
#include <MS5611.h>
#include <avr/wdt.h>
#include <SoftwareSerial.h>
@ -63,6 +29,14 @@ SoftwareSerial BTserial(RX, TX); // RX not connected
#define FREQUENCY 10 // freq output in Hz
#define USB_MODE // uncomment for usb mode
#define BLUETOOTH_MODE // uncomment for bluetooth mode
#define USE_LK8000
/*
* sentences to choice :
* $LK8EX1,pressure,altitude,vario,temperature,battery,*checksum
* PRS pressure in pascal in hexadecimal format
* LK8000 : 32 chars to send PRS : 10 chars to send
* bluetooth in 9600bauds -> 1.25ms for a char
*/
const char compile_date[] = "XCTRACK VARIO " __DATE__;
const char mess_check[] = "checking MS5611 sensor...";
@ -75,6 +49,7 @@ void setup() {
Serial.begin(USB_SPEED);
Serial.println(compile_date);
Serial.println(mess_check);
Serial.println(mess_check);
#endif
#ifdef BLUETOOTH_MODE
BTserial.begin(BLUETOOTH_SPEED); // start communication with the HC-05 using 38400
@ -93,7 +68,7 @@ void setup() {
#endif
delay(1200); //for watchdog timeout
}
sensor.ReadProm(); //takes about 3ms
sensor.ReadProm(); //takes about 3ms
}
uint32_t get_time = millis();
@ -116,6 +91,9 @@ void loop(void) {
//$LK8EX1,pressure,altitude,vario,temperature,battery,*checksum
//$LK8EX1,pressure,99999,9999,temp,999,*checksum
#ifdef USE_LK8000
String str_out = String("LK8EX1,")
+String(Pressure)
+String(",0,9999,")
@ -141,6 +119,17 @@ void loop(void) {
BTserial.print("*");
BTserial.println(checksum_end, HEX);
#endif
#else // use PRS sentence
String str_out = String("PRS ")
+ String(Pressure, HEX);
#ifdef USB_MODE
Serial.println(str_out);
#endif
#ifdef BLUETOOTH_MODE
BTserial.println(str_out);
#endif
#endif
}
}

Wyświetl plik

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="44.396732mm"
height="12.294724mm"
viewBox="0 0 44.396732 12.294723"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (unknown)"
sodipodi:docname="dessin.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="67.005617"
inkscape:cy="-10.628394"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="717"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-62.303234,-38.151294)">
<g
aria-label="XCTRACK
VARIO"
transform="matrix(0.26458333,0,0,0.26458333,-17.506154,1.403165)"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.25px;line-height:125%;font-family:OCRA;-inkscape-font-specification:'OCRA, Normal';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.00157475;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="flowRoot834">
<path
d="m 318.46257,153.47135 h -2.29333 v 4.66667 h 7.04 v -4.66667 l -4.53333,-4.66666 4.53333,-4.72 v -4.66667 h -7.04 v 4.69333 h 2.21333 l -2.21333,2.32 h -2.37333 v 4.69334 h 2.37333 z m -9.25333,0 h -2.4 l 2.4,-2.37333 h 2.34667 v -4.64 h -2.34667 l -2.26667,-2.37333 h 2.24 v -4.66667 h -7.04 v 4.66667 l 4.45334,4.85333 -4.45334,4.53333 v 4.66667 h 7.06667 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path901" />
<path
d="m 326.41341,141.71135 2.34666,-2.32 h 7.04001 v 4.69334 h -4.72001 v 9.38666 h 4.72001 v 4.66667 h -7.04001 l -2.34666,-2.34666 z m 16.42667,2.37334 h -4.72 v -4.69334 h 7.04 l 2.34666,2.32 v 4.72 h -4.66666 z m -4.72,9.38666 h 9.36 v 4.66667 h -9.36 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path903" />
<path
d="m 357.72424,144.08469 h -2.37333 v 4.66666 h -4.66667 v -9.36 h 11.70667 v 18.74667 h -4.64 z m 9.38667,0 h -2.37333 v -4.69334 h 7.04 v 9.36 h -4.66667 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path905" />
<path
d="m 390.44841,158.13802 -8.45334,-11.70667 h 9.41334 v -2.34666 h -4.72 v -4.69334 h 7.04 l 2.34667,2.32 v 7.04 l -2.34667,2.4 h -2.88 l 5.2,6.98667 z m -10.8,-4.66667 h 2.34666 v 4.69334 h -7.04 l 0.0267,-0.0267 v -18.74667 h 9.38667 v 4.69334 h -4.72 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path907" />
<path
d="m 406.318,158.16469 v -4.69334 h -2.34667 l 1.2,-2.37333 h 3.54667 v -4.64 h -1.22667 l 1.17333,-2.34667 v -4.69333 H 406.318 l -7.04,14.05333 v 4.69334 z m 7.01333,-4.69334 v 4.69334 h 7.01333 v -4.69334 l -7.01333,-14.05333 H 410.958 v 4.69333 l 1.17333,2.32 H 410.958 v 4.69334 h 3.52 l 1.2,2.34666 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path909" />
<path
d="m 423.54882,141.71135 2.34667,-2.32 h 7.04 v 4.69334 h -4.72 v 9.38666 h 4.72 v 4.66667 h -7.04 l -2.34667,-2.34666 z m 16.42667,2.37334 h -4.72 v -4.69334 h 7.04 l 2.34667,2.32 v 4.72 h -4.66667 z m -4.72,9.38666 h 9.36 v 4.66667 h -9.36 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path911" />
<path
d="m 459.553,158.16469 v -4.69334 h 4.69334 v -2.34666 h -9.38667 l 8.93333,-11.73334 h 5.12 l -5.12,7.01334 h 2.8 l 2.34667,2.4 v 9.36 z m -7.04,-14.08 v 9.38666 h 2.32 v 4.66667 h -6.98667 v -18.72 l -0.0267,-0.0267 h 7.04 v 4.69334 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path913" />
<path
d="m 340.46674,166.11136 h 7.01334 v 4.66667 l -7.01334,14.08 h -2.37333 v -4.72 l 4.72,-9.36 h -2.34667 z m -7.01333,4.66667 h -2.34667 l 4.69334,9.36 v 4.72 h -2.34667 l -7.04,-14.08 v -4.66667 h 7.04 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path915" />
<path
d="m 357.72424,184.83136 v -4.69333 h -2.34666 l 1.2,-2.37334 h 3.54666 v -4.64 h -1.22666 l 1.17333,-2.34666 v -4.69334 h -2.34667 l -7.04,14.05334 v 4.69333 z m 7.01334,-4.69333 v 4.69333 h 7.01333 v -4.69333 l -7.01333,-14.05334 h -2.37334 v 4.69334 l 1.17334,2.32 h -1.17334 v 4.69333 h 3.52 l 1.2,2.34667 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path917" />
<path
d="m 390.44841,184.80469 -8.45333,-11.70666 h 9.41333 v -2.34667 h -4.72 v -4.69333 h 7.04 l 2.34667,2.32 v 7.04 l -2.34667,2.4 h -2.88 l 5.2,6.98666 z m -10.8,-4.66666 h 2.34667 v 4.69333 h -7.04 l 0.0267,-0.0267 v -18.74666 h 9.38667 v 4.69333 h -4.72 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path919" />
<path
d="m 406.31799,180.13803 h -7.04 v 4.69333 h 11.70667 v -18.77333 h -11.70667 v 4.66666 h 7.04 z m 7.01334,-9.38667 h 7.06667 v -4.69333 h -7.06667 z m 7.06667,9.41333 h -7.06667 v 4.66667 h 7.06667 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path921" />
<path
d="m 423.60091,168.37803 v 14.08 l 2.34667,2.34666 h 7.04 v -4.66666 h -4.72 v -9.38667 h 4.72 v -4.69333 h -7.04 z m 16.42667,2.37333 v 9.38667 h -4.72 v 4.66666 h 7.04 l 2.34666,-2.34666 v -14.08 l -2.34666,-2.32 h -7.04 v 4.69333 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:26.66666794px;line-height:100%;font-family:Vyper;-inkscape-font-specification:'Vyper, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:none;stroke:#000000;stroke-width:1.00157475;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path923" />
</g>
</g>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 11 KiB

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,11 @@
Vyper Falcon Truetype Font for Windows
2008 Iconian Fonts - Daniel Zadorozny
http://www.iconian.com/
This font comes with the following 16 versions: Regular, Italic, Shadow, Shadow Italic, Pro, Pro Italic, Expanded, Expanded Italic, Bold, Bold Italic, Condensed, Condensed Italic, Expanded Bold, Expanded Bold Italic, Laser and Laser Italic.
This font may be freely distributed and is free for all non-commercial uses. Use of the fonts are at your own risk. This font is e-mailware; that is, if you like it, please e-mail the author at:
iconian@aol.com

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 58 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 33 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 253 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 253 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 195 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 195 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 312 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 312 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 262 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 262 KiB

BIN
img/img_xctrack.jpg 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 343 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 118 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 118 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 118 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 118 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 164 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 76 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 76 KiB

Wyświetl plik

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 96 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 96 KiB

Wyświetl plik

@ -0,0 +1,57 @@
/*
MS5xxx.h - Library for accessing MS5xxx sensors via I2C
Copyright (c) 2012 Roman Schmitz
This file is part of arduino-ms5xxx.
arduino-ms5xxx is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
arduino-ms5xxx is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with arduino-ms5xxx. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wire.h>
#include <MS5611.h>
MS5611 sensor(&Wire);
void setup() {
Serial.begin(115200);
if(sensor.connect()>0) {
Serial.println("Error connecting...");
delay(500);
setup();
}
}
void loop() {
sensor.ReadProm();
sensor.Readout();
Serial.print("Temperature [0.01 C]: ");
Serial.println(sensor.GetTemp()/100);
Serial.print("Pressure [Pa]: ");
Serial.println(round(sensor.GetPres()));
test_crc();
Serial.println("---");
delay(500);
}
void test_crc() {
Serial.print("CRC=0x");
Serial.print(sensor.Calc_CRC4(), HEX);
Serial.print(" (should be 0x");
Serial.print(sensor.Read_CRC4(), HEX);
Serial.print(")\n");
Serial.print("Test Code CRC=0x");
Serial.print(sensor.CRCcodeTest(), HEX);
Serial.println(" (should be 0xB)");
}

Wyświetl plik

@ -0,0 +1,44 @@
/*
Programme de reception ou config Bluetooth
AT : check the connection
AT+NAME: Change name. No space between name and command.
AT+BAUD: change baud rate, x is baud rate code, no space between command and code.
AT+PIN: change pin, xxxx is the pin, again, no space.
AT+VERSION
HC03 HC05 LF+CR
HC04 HC06 no LF+CR
BLE CC2541 without crystal send with LF + CR
HM-10 (CC2541 with crystal) no LF+CR
AT+HELP list of command
http://www.jnhuamao.cn/bluetooth.asp?id=1
*/
#define RX 11 //RX is MOSI (TX module bluetooth)
#define TX 12 //TX is MISO (RX module bluetooth)
#include <SoftwareSerial.h>
SoftwareSerial BTserial(RX,TX);
byte serialA; // variable de reception de donnée via RX
void setup()
{
Serial.begin(9600);
while (!Serial) ; // Needed for native USB port only
Serial.println("Hello !");
Serial.println("Enter AT commands:");
// set the data rate for the SoftwareSerial port
BTserial.begin(9600);
}
void loop() {
if (BTserial.available())
{
serialA = BTserial.read();
Serial.write(serialA);
}
if (Serial.available())
BTserial.write(Serial.read());
}

Wyświetl plik

@ -0,0 +1,57 @@
#include <SoftwareSerial.h>
#define RX 11 // not used (TX module bluetooth)
#define TX 12 // MISO on ISCP (RX module bluetooth)
SoftwareSerial BTserial(RX, TX); // RX not connected
// Connect the HC-05 TX to Arduino pin 11 RX (MOSI).
// Connect the HC-05 RX to Arduino pin 12 TX (MISO).
#define USB_SPEED 115200 //define serial transmision speed
#define BLUETOOTH_SPEED 9600 //bluetooth speed (9600 by default)
#define FREQUENCY 10 // freq output in Hz
#define USB_MODE // uncomment for usb mode
#define BLUETOOTH_MODE // uncomment for bluetooth mode
void setup() // setup() function to setup all necessary parameters before we go to endless loop() function
{
#ifdef USB_MODE
Serial.begin(USB_SPEED); // set up arduino serial port
#endif
#ifdef BLUETOOTH_MODE
BTserial.begin(BLUETOOTH_SPEED); // start communication with the HC-05 using 38400
#endif
}
uint32_t Pressure=91000;
uint32_t get_time = millis();
void loop(void) {
if (millis() >= (get_time + (1000/FREQUENCY)))
{
get_time = millis();
Pressure -= 1;
if (Pressure<90000) Pressure = 91000;
String str_out = String("LK8EX1,")
+String(Pressure)
+String(",0,9999,0,999,");
unsigned int checksum_end, ai, bi; // Calculating checksum for data string
for (checksum_end = 0, ai = 0; ai < str_out.length(); ai++)
{
bi = (unsigned char)str_out[ai];
checksum_end ^= bi;
}
#ifdef USB_MODE
Serial.print("$");
Serial.print(str_out);
Serial.print("*");
Serial.println(checksum_end, HEX);
#endif
#ifdef BLUETOOTH_MODE
BTserial.print("$"); //print first sign of NMEA protocol
BTserial.print(str_out); //print data string
BTserial.print("*"); //end of protocol string
BTserial.println(checksum_end, HEX);
#endif
}
}