Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Si7020 LPS25H LSM303D
Diff: main.cpp
- Revision:
- 7:7137218c4432
- Parent:
- 2:b60cb847489c
- Child:
- 8:1b347e764f16
diff -r 4e6ec83d3c83 -r 7137218c4432 main.cpp
--- a/main.cpp Wed Sep 13 11:30:50 2017 +0000
+++ b/main.cpp Sun Jan 06 15:30:36 2019 +0000
@@ -1,12 +1,61 @@
#include "mbed.h"
+#include "Si7020.h"
+#include "LPS25H.h"
+
DigitalOut myled(LED1);
+Serial pc(SERIAL_TX, SERIAL_RX); //serial debug output, 9600 bps 8 bit, no parity 1 stop bit no flow control.
+
+//I2C declarations
+I2C i2c(PB_9,PB_8); // SDA, SCL
+I2CSlave slave(PB_3,PB_10); // SDA, SCL
+Si7020 si(&i2c);
+LPS25H baro(&i2c, LPS25H_G_CHIP_ADDR);
+
+AnalogIn adc(ADC_TEMP);
+
+//int I2C_ADDR = 0x00200;
+static const char I2C_ADDR = 0xE5 ;
int main() {
+
+ //i2c setups
+ i2c.frequency(100000); //Set the clock frequency
+ slave.frequency(100000); //Set the clock frequency
+ slave.address(I2C_ADDR);
+
+ pc.printf("Hello world! \n");
while(1) {
myled = 1; // LED is ON
wait(0.2); // 200 ms
myled = 0; // LED is OFF
wait(1.0); // 1 sec
+ //put the code here!
+ float tempuc = adc.read()*100;
+ pc.printf("This is a loop\n");
+ pc.printf("x=%.1f\r\n", tempuc);
+ float humid;
+ if(si.getHumidity(&humid) != 0) {
+ printf("Error getting humidity\n");
+ humid = -1;
+ }
+
+ float temp;
+ if(si.getTemperature(&temp) != 0) {
+ printf("Error getting temperature");
+ temp = -1;
+ }
+ printf("Humidity = %f%% Temperature = %fC\n", humid, temp);
+
+ baro.get();
+ printf("Pressure: %.1f, Temperature: %.1f\r\n",
+ baro.pressure(), baro.temperature());
+
+
+ wait(1);
}
}
+
+
+
+