An example program using the Sprint Mobile Braodband to provide and SMS alert when the temperature read from the LM75B exceeds 32^C
Dependencies: LM75B SprintUSBModem mbed-rtos mbed
Fork of SprintUSBModemSMSTest by
Revision 1:17036ca8cb9f, committed 2012-10-31
- Comitter:
- chris
- Date:
- Wed Oct 31 01:35:49 2012 +0000
- Parent:
- 0:9488714d539f
- Commit message:
- First commit;
Changed in this revision
| LM75B.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/LM75B.lib Wed Oct 31 01:35:49 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- a/main.cpp Tue Oct 30 10:14:23 2012 +0000
+++ b/main.cpp Wed Oct 31 01:35:49 2012 +0000
@@ -1,67 +1,53 @@
#include "mbed.h"
#include "SprintUSBModem.h"
+#include "LM75B.h"
-#define MY_PHONE_NUMBER "+1xxxxxxxxx"
+LM75B tmp(p28,p27);
+
+#define MY_PHONE_NUMBER "+447957363267"
-void test(void const*)
+void test(void const*)
{
+ DigitalOut led4(LED4);
SprintUSBModem modem(p18);
+ char msg[128];
+
printf("Switching power on\r\n");
-
modem.power(true);
-
+
modem.sendSM(MY_PHONE_NUMBER, "Hello from mbed:)");
- while(true)
- {
- char num[17];
- char msg[128];
- size_t count;
- int ret = modem.getSMCount(&count);
- if(ret)
- {
- printf("getSMCount returned %d\r\n", ret);
- Thread::wait(3000);
- continue;
+ while(true) {
+ if (tmp.read() > 32.0) {
+ led4 = 1;
+ sprintf(msg,"Temperature : %.1f!",tmp.read());
+ modem.sendSM(MY_PHONE_NUMBER, msg);
+ while (tmp.read() > 30.0) {
+ Thread::wait(1000);
+ }
+ led4=0;
}
- if( count > 0)
- {
- printf("%d SMS to read\r\n", count);
- ret = modem.getSM(num, msg, 128);
- if(ret)
- {
- printf("getSM returned %d\r\n", ret);
- Thread::wait(3000);
- continue;
- }
-
- printf("%s : %s\r\n", num, msg);
- }
- Thread::wait(3000);
- }
-
- modem.disconnect();
-
- modem.power(false);
+ }
- while(1) {
- }
+ modem.disconnect();
+
+ modem.power(false);
+
}
int main()
{
- DBG_INIT();
- DBG_SET_SPEED(115200);
- DBG_SET_NEWLINE("\r\n");
- Thread testTask(test, NULL, osPriorityNormal, 1024 * 5);
- DigitalOut led(LED1);
- while(1)
- {
- led=!led;
- Thread::wait(1000);
- }
+ DBG_INIT();
+ DBG_SET_SPEED(115200);
+ DBG_SET_NEWLINE("\r\n");
+ Thread testTask(test, NULL, osPriorityNormal, 1024 * 5);
+ DigitalOut led(LED1);
+ while(1) {
+ led=!led;
+ Thread::wait(1000);
+ }
- return 0;
+ return 0;
}
