student project

Dependencies:   mbed

Fork of myiot by joseph chen

Committer:
hank51017
Date:
Wed Jun 22 08:12:27 2016 +0000
Revision:
4:07e0a94f29da
Parent:
1:e94d9dab0ef3
OLED+BMP280

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ittraining 0:94c1a94c5a47 1 #include "mbed.h"
ittraining 0:94c1a94c5a47 2 #include "I2C_SSD1306Z.h"
hank51017 4:07e0a94f29da 3 #include "BME280.h"
ittraining 0:94c1a94c5a47 4
ittraining 0:94c1a94c5a47 5
ittraining 0:94c1a94c5a47 6 I2C i2c(I2C_SDA, I2C_SCL);
hank51017 4:07e0a94f29da 7 BME280 sensor(PB_3, PB_10);
ittraining 0:94c1a94c5a47 8
ittraining 0:94c1a94c5a47 9 DigitalOut myled(LED1);
ittraining 0:94c1a94c5a47 10 Serial pc(SERIAL_TX, SERIAL_RX);
ittraining 0:94c1a94c5a47 11
ittraining 0:94c1a94c5a47 12 int main()
ittraining 0:94c1a94c5a47 13 {
ittraining 0:94c1a94c5a47 14
hank51017 4:07e0a94f29da 15 char tbuffer[50], hpbuffer[50], hbuffer[50];
ittraining 0:94c1a94c5a47 16 printf("init oled\n");
ittraining 0:94c1a94c5a47 17
ittraining 0:94c1a94c5a47 18 Init_LCD();
ittraining 0:94c1a94c5a47 19 clear_LCD();
ittraining 0:94c1a94c5a47 20
ittraining 0:94c1a94c5a47 21 while (1) {
hank51017 4:07e0a94f29da 22
hank51017 4:07e0a94f29da 23
hank51017 4:07e0a94f29da 24
hank51017 4:07e0a94f29da 25 sprintf(tbuffer, "Temp: %2.2f degC", sensor.getTemperature());
hank51017 4:07e0a94f29da 26 sprintf(hpbuffer, "P: %4.2f hPa", sensor.getPressure());
hank51017 4:07e0a94f29da 27 sprintf(hbuffer, "Hum: %2.2f %%", sensor.getHumidity());
ittraining 1:e94d9dab0ef3 28
hank51017 4:07e0a94f29da 29 tbuffer[strlen(tbuffer)] = '\0';
hank51017 4:07e0a94f29da 30 hpbuffer[strlen(hpbuffer)] = '\0';
hank51017 4:07e0a94f29da 31 hbuffer[strlen(hbuffer)] = '\0';
hank51017 4:07e0a94f29da 32
hank51017 4:07e0a94f29da 33 print_Line(0, tbuffer);
hank51017 4:07e0a94f29da 34 print_Line(1, hpbuffer);
hank51017 4:07e0a94f29da 35 print_Line(2, hbuffer);
hank51017 4:07e0a94f29da 36
hank51017 4:07e0a94f29da 37
ittraining 0:94c1a94c5a47 38 wait(2.0);
ittraining 0:94c1a94c5a47 39 clear_LCD();
ittraining 0:94c1a94c5a47 40
ittraining 0:94c1a94c5a47 41 }
ittraining 0:94c1a94c5a47 42
ittraining 0:94c1a94c5a47 43 }
ittraining 0:94c1a94c5a47 44
ittraining 0:94c1a94c5a47 45