Temperaturanzeuge mit HC05 und Bluetooth

Dependencies:   LCD_i2c_GSOE

Committer:
jack1930
Date:
Mon Sep 14 14:18:23 2020 +0000
Revision:
0:2a5c7fd2db13
1. Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jack1930 0:2a5c7fd2db13 1 /* mbed Microcontroller Library
jack1930 0:2a5c7fd2db13 2 * Copyright (c) 2019 ARM Limited
jack1930 0:2a5c7fd2db13 3 * SPDX-License-Identifier: Apache-2.0
jack1930 0:2a5c7fd2db13 4 */
jack1930 0:2a5c7fd2db13 5
jack1930 0:2a5c7fd2db13 6 #include "mbed.h"
jack1930 0:2a5c7fd2db13 7 #include "LCD.h"
jack1930 0:2a5c7fd2db13 8
jack1930 0:2a5c7fd2db13 9
jack1930 0:2a5c7fd2db13 10 // Blinking rate in milliseconds
jack1930 0:2a5c7fd2db13 11 #define BLINKING_RATE 500ms
jack1930 0:2a5c7fd2db13 12 BufferedSerial hc05(PB_10,PB_11,9600);
jack1930 0:2a5c7fd2db13 13 AnalogIn ain2(PA_4);
jack1930 0:2a5c7fd2db13 14
jack1930 0:2a5c7fd2db13 15 lcd mylcd;
jack1930 0:2a5c7fd2db13 16
jack1930 0:2a5c7fd2db13 17 int main()
jack1930 0:2a5c7fd2db13 18 {
jack1930 0:2a5c7fd2db13 19 char daten[15];
jack1930 0:2a5c7fd2db13 20
jack1930 0:2a5c7fd2db13 21 float Wert = 0; // variable to store the value read
jack1930 0:2a5c7fd2db13 22 float R2_25 =1500;
jack1930 0:2a5c7fd2db13 23 float R2_theta;
jack1930 0:2a5c7fd2db13 24 float R1=1500;
jack1930 0:2a5c7fd2db13 25 float dt;
jack1930 0:2a5c7fd2db13 26 float t;
jack1930 0:2a5c7fd2db13 27 float alpha=-0.045;
jack1930 0:2a5c7fd2db13 28
jack1930 0:2a5c7fd2db13 29 // Initialise the digital pin LED1 as an output
jack1930 0:2a5c7fd2db13 30 DigitalOut led(LED1);
jack1930 0:2a5c7fd2db13 31 mylcd.clear();
jack1930 0:2a5c7fd2db13 32 mylcd.cursorpos(0);
jack1930 0:2a5c7fd2db13 33 while (true) {
jack1930 0:2a5c7fd2db13 34 led = !led;
jack1930 0:2a5c7fd2db13 35 R2_theta=R1*ain2/(1-ain2);
jack1930 0:2a5c7fd2db13 36 dt=(R2_theta/R2_25-1)/alpha; //näherungsweise
jack1930 0:2a5c7fd2db13 37 t=25+dt;
jack1930 0:2a5c7fd2db13 38 sprintf(daten,"*G%d*",(int)t);
jack1930 0:2a5c7fd2db13 39 hc05.write(daten,12);
jack1930 0:2a5c7fd2db13 40 sprintf(daten,"*T%d*",(int)t);
jack1930 0:2a5c7fd2db13 41 hc05.write(daten,12);
jack1930 0:2a5c7fd2db13 42 mylcd.cursorpos(0);
jack1930 0:2a5c7fd2db13 43 mylcd.printf("%s",daten);
jack1930 0:2a5c7fd2db13 44 ThisThread::sleep_for(BLINKING_RATE);
jack1930 0:2a5c7fd2db13 45 }
jack1930 0:2a5c7fd2db13 46 }