Wio 3G with Firebase example
Fork of Wio_3G_HTTP-GET-example by
Revision 72:aa14c091f860, committed 2018-08-06
- Comitter:
- MACRUM
- Date:
- Mon Aug 06 09:28:20 2018 +0000
- Parent:
- 71:7d17edde2e03
- Child:
- 73:d47320bcc568
- Commit message:
- Update libraries
Changed in this revision
| Grove_temperature.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Grove_temperature.lib Mon Aug 06 09:28:20 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/MACRUM/code/Grove_temperature/#aee37a51ccbb
--- a/main.cpp Fri Aug 03 06:46:00 2018 +0000
+++ b/main.cpp Mon Aug 06 09:28:20 2018 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "Grove_LCD_RGB_Backlight.h"
+#include "Grove_temperature.h"
#define D20 (PB_4)
#define D19 (PB_3)
@@ -9,25 +10,10 @@
AnalogIn ain(A6);
InterruptIn btn(D20);
Grove_LCD_RGB_Backlight rgbLCD(I2C_SDA, I2C_SCL);
+Grove_temperature temp(A4);
uint32_t button = 0;
-///
-
-float get_temp()
-{
- const int B = 4275; // B value of the thermistor
- const int R0 = 100000; // R0 = 100k
- AnalogIn temp(A4);
-
- float R = 1.0f/temp.read() - 1.0f;
- R = R0*R;
-
- float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet
- return temperature;
-}
-///
-
void push()
{
@@ -49,9 +35,8 @@
int cnt = 0;
printf("hello, Mbed world\n");
while (true) {
- printf("count = %4d, button = %d, analog = %f, temp = %f\n", cnt++, button, ain.read(), get_temp());
+ printf("count = %4d, button = %d, analog = %f, temp = %f\n", cnt++, button, ain.read(), temp.getTemperature());
led1 = !led1;
wait(0.5);
}
}
-
Toyomasa Watarai
