Oleg Artamonov
/
STM32_meteo
Simple Mbed example of sleepy program reading OPT3001 and BME280 sensors
Revision 0:002dbf6aef22, committed 2018-08-16
- Comitter:
- olegart
- Date:
- Thu Aug 16 20:22:45 2018 +0000
- Commit message:
- Let's call it release
Changed in this revision
diff -r 000000000000 -r 002dbf6aef22 BME280.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BME280.lib Thu Aug 16 20:22:45 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/MACRUM/code/BME280/#c1f1647004c4
diff -r 000000000000 -r 002dbf6aef22 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Aug 16 20:22:45 2018 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "BME280.h" +#include "OPT3001.h" + +DigitalOut led(LED1); +BME280 sensor_bme(D14, D15); +OPT3001 sensor_opt(D14, D15); +EventQueue eventQueue(/* event count */ 50 * EVENTS_EVENT_SIZE); +Serial pc(SERIAL_TX, SERIAL_RX); +LowPowerTicker lpTicker; + +void printTemperature(void) +{ + pc.printf("%2.2f degC, %04.2f hPa, %2.2f %%\r\n", sensor_bme.getTemperature(), sensor_bme.getPressure(), sensor_bme.getHumidity()); + pc.printf("%ld lux\r\n", sensor_opt.readSensor()); + led = !led; // Toggle LED +} + +void tickerIRQ (void) +{ + eventQueue.call(printTemperature); +} + +int main() +{ + pc.baud(115200); + + lpTicker.attach(tickerIRQ, 1); // every second + + while(1) + { + eventQueue.dispatch(0); + sleep(); + } +} \ No newline at end of file
diff -r 000000000000 -r 002dbf6aef22 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Aug 16 20:22:45 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#f8b140f8d7cb226e41486c5df66ac4f3ce699219
diff -r 000000000000 -r 002dbf6aef22 mbed_opt3001.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_opt3001.lib Thu Aug 16 20:22:45 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/olegart/mbed_opt3001/#05eefffcdcb07bfd55eea53d5ec184fcd2bfff43