![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test bmp085,mpxv7002dp
Dependencies: BMP085_2 GPS mbed
Fork of HelloBMP085 by
main.cpp@3:3ffa19319516, 2014-04-25 (annotated)
- Committer:
- hanif
- Date:
- Fri Apr 25 14:06:47 2014 +0000
- Revision:
- 3:3ffa19319516
- Parent:
- 0:4c7cde980426
test bmp085, mpxv7002d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TakashiSasaki | 0:4c7cde980426 | 1 | #include "mbed.h" |
TakashiSasaki | 0:4c7cde980426 | 2 | #include "BMP085.h" |
hanif | 3:3ffa19319516 | 3 | #include "GPS.h" |
hanif | 3:3ffa19319516 | 4 | #define pengurang 2.5 |
hanif | 3:3ffa19319516 | 5 | #define massa_jenis_udara 1.2 |
TakashiSasaki | 0:4c7cde980426 | 6 | |
TakashiSasaki | 0:4c7cde980426 | 7 | DigitalOut myled(LED1); |
hanif | 3:3ffa19319516 | 8 | BMP085 bmp085(P0_27, P0_28); |
TakashiSasaki | 0:4c7cde980426 | 9 | Serial pc(USBTX, USBRX); |
hanif | 3:3ffa19319516 | 10 | GPS gps(P4_28, P4_29); |
hanif | 3:3ffa19319516 | 11 | AnalogIn Ain(P0_23); |
hanif | 3:3ffa19319516 | 12 | |
hanif | 3:3ffa19319516 | 13 | float ADCdata; |
hanif | 3:3ffa19319516 | 14 | float konversinya; |
hanif | 3:3ffa19319516 | 15 | float hasilnya; |
hanif | 3:3ffa19319516 | 16 | float sebelum; |
hanif | 3:3ffa19319516 | 17 | float kecepatan; |
hanif | 3:3ffa19319516 | 18 | char kirim[16]; |
hanif | 3:3ffa19319516 | 19 | char simpan; |
TakashiSasaki | 0:4c7cde980426 | 20 | |
TakashiSasaki | 0:4c7cde980426 | 21 | int main() { |
TakashiSasaki | 0:4c7cde980426 | 22 | pc.printf("main\n"); |
hanif | 3:3ffa19319516 | 23 | float p, t, h; |
TakashiSasaki | 0:4c7cde980426 | 24 | |
TakashiSasaki | 0:4c7cde980426 | 25 | while(1) { |
TakashiSasaki | 0:4c7cde980426 | 26 | myled = 1; |
TakashiSasaki | 0:4c7cde980426 | 27 | bmp085.update(); |
TakashiSasaki | 0:4c7cde980426 | 28 | p = bmp085.get_pressure(); |
TakashiSasaki | 0:4c7cde980426 | 29 | t = bmp085.get_temperature(); |
hanif | 3:3ffa19319516 | 30 | |
hanif | 3:3ffa19319516 | 31 | if ( t>30) { |
hanif | 3:3ffa19319516 | 32 | |
hanif | 3:3ffa19319516 | 33 | h = (0.07 * t* t) - (2.75 * t) + 45.5; |
hanif | 3:3ffa19319516 | 34 | } |
hanif | 3:3ffa19319516 | 35 | |
hanif | 3:3ffa19319516 | 36 | else if ( t>20){ |
hanif | 3:3ffa19319516 | 37 | h = (1.1 * t) - 7; |
hanif | 3:3ffa19319516 | 38 | } |
hanif | 3:3ffa19319516 | 39 | |
hanif | 3:3ffa19319516 | 40 | |
hanif | 3:3ffa19319516 | 41 | |
hanif | 3:3ffa19319516 | 42 | ADCdata = Ain.read(); |
hanif | 3:3ffa19319516 | 43 | //konversinya = map( ADCdata, 0, 1023,0,5); |
hanif | 3:3ffa19319516 | 44 | konversinya = (ADCdata*5); |
hanif | 3:3ffa19319516 | 45 | hasilnya = (konversinya) - (pengurang); |
hanif | 3:3ffa19319516 | 46 | sebelum = (2*hasilnya)/ (massa_jenis_udara); |
hanif | 3:3ffa19319516 | 47 | kecepatan = (sqrt(sebelum))- 1.25; |
hanif | 3:3ffa19319516 | 48 | |
hanif | 3:3ffa19319516 | 49 | /* |
hanif | 3:3ffa19319516 | 50 | pc.printf("tekanan %6.2f Pa suhu %6.2f deg C \n", p, t); |
hanif | 3:3ffa19319516 | 51 | myled = 0; |
hanif | 3:3ffa19319516 | 52 | pc.printf("humidity %f ", h); |
hanif | 3:3ffa19319516 | 53 | |
hanif | 3:3ffa19319516 | 54 | |
hanif | 3:3ffa19319516 | 55 | //pc.printf (" data = %f \n",ADCdata); |
hanif | 3:3ffa19319516 | 56 | //pc.printf ("konversi = %f \n", konversinya); |
hanif | 3:3ffa19319516 | 57 | //pc.printf (" P = %f \n", hasilnya); |
hanif | 3:3ffa19319516 | 58 | pc.printf ("v angin = %f \n", kecepatan); |
hanif | 3:3ffa19319516 | 59 | //pc.printf ("latitude= -7.766091, longitude= 110.372009, altitude= 184.30 \n"); |
hanif | 3:3ffa19319516 | 60 | */ |
hanif | 3:3ffa19319516 | 61 | |
hanif | 3:3ffa19319516 | 62 | if(gps.sample()) { |
hanif | 3:3ffa19319516 | 63 | pc.printf("I'm at longitude %f, latitude %f\n", gps.longitude, gps.latitude); |
hanif | 3:3ffa19319516 | 64 | } else { |
hanif | 3:3ffa19319516 | 65 | pc.printf("tunggu lock(\n"); |
hanif | 3:3ffa19319516 | 66 | } |
hanif | 3:3ffa19319516 | 67 | pc.printf ("\n"); |
hanif | 3:3ffa19319516 | 68 | |
hanif | 3:3ffa19319516 | 69 | |
hanif | 3:3ffa19319516 | 70 | //pc.printf(" BALLON 184.30 %6.2f %6.2f %f %f utara 0 %f %f \n",p,t,h,kecepatan,gps.latitude,gps.longitude); |
hanif | 3:3ffa19319516 | 71 | |
hanif | 3:3ffa19319516 | 72 | |
hanif | 3:3ffa19319516 | 73 | wait (1); |
TakashiSasaki | 0:4c7cde980426 | 74 | }//while |
TakashiSasaki | 0:4c7cde980426 | 75 | }//main |