Demo using a Nimbelink Skywire cellular modem paired with ST Nucleo. This demo reads several sensors and reports them to a Freeboard dashboard using dweet.io from Buglabs

Dependencies:   LIS3DH LM75B LPS331 hts221 mbed

Fork of Skywire_Demo by NimbeLink

Getting Started Guide

  • Set the JP5 jumper to E5V on the Nucleo
  • Place the Skywire Shield onto the Nucleo as pictured
  • Place the Skywire modem onto the Shield as picture and attach the antenna U.FL coax cable as pictured
  • Plug the 12V wall supply into the Skywire Shield /media/uploads/kholland/st00000002-sm.jpg
  • The new dashboard will show up on you account list under My Freeboards, you can then edit the name to whatever you like /media/uploads/kholland/default_skywire2.jpg
  • Under the Datasources tab on the dashboard, click the skywire link /media/uploads/kholland/default_skywire5.jpg
  • Change the THING NAME field to a unique string, we recommended using the MEID or IMEI on the Skywire Modem, but it could be anything you want. /media/uploads/kholland/default_skywire4.jpg
  • Next, Import the Skywire_Demo program into the online compiler
  • Open main.cpp. Starting at Line 58, there is a list of Skywire Modems. Uncomment the Skywire Modem that you are using. Make sure only one Skywire Modem is uncommented:

main.cpp

/*
 * DEFINE THE SKYWIRE MODEM
 * Uncomment only the modem that you are using.
 * Make sure only one modem is uncommented!
 */
//#define NL_SW_1xRTT_V         // Verizon 2G Modem - CE910-DUAL
//#define NL_SW_1xRTT_S         // Sprint 2G Modem - CE910-DUAL
//#define NL_SW_1xRTT_A         // Aeris 2G Modem - CE910-DUAL
//#define NL_SW_GPRS            // AT&T/T-Mobile 2G Modem
//#define NL_SW_EVDO_V          // Verizon 3G Modem
//#define NL_SW_EVDO_A          // Aeris 3G Modem
//#define NL_SW_HSPAP           // AT&T/T-Mobile 3G Modem
//#define NL_SW_HSPAPG          // AT&T/T-Mobile 3G Modem w/ GPS
//#define NL_SW_HSPAPE          // GSM 3G Modem, EU
//#define NL_SW_LTE_TSVG        // Verizon 4G LTE Modem
//#define NL_SW_LTE_TNAG        // AT&T/T-Mobile 4G LTE Modem
//#define NL_SW_LTE_TEUG        // GSM 4G LTE Modem, EU
//#define NL_SW_LTE_GELS3       // VZW LTE Cat 1 Modem
  • Next, to Line 73 in main.cpp, and change the DeviceID to the THING NAME you entered into your Freeboard:

main.cpp

/* --CHANGE THIS FOR YOUR SETUP" -- */
#define DeviceID "DweetIODeviceName"  //Freeboard DweetIO unique ID
  • If applicable, go to Line 77 in main.cpp and change the APN to your specific APN:

main.cpp

/* --CHANGE THIS FOR YORU SETUP (IF APPLICABLE)-- */
#if defined NL_SW_HSPAP || defined NL_SW_HSPAPG || defined NL_SW_HSPAPE || defined NL_SW_LTE_TSVG || defined NL_SW_LTE_TNAG || defined NL_SW_LTE_TEUG || defined NL_SW_LTE_GELS3
    std::string APN = "yourAPNhere";
#endif
  • Compile and upload to the Nucleo, cycle power to the shield and the sensor data should start to upload to your new Freeboard.
Committer:
kholland
Date:
Mon Jan 12 17:43:04 2015 +0000
Revision:
2:b57e24a42b6f
Parent:
0:3095958bc639
Child:
3:4b2176f6474c
Modified for CE910

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kholland 0:3095958bc639 1
kholland 0:3095958bc639 2
kholland 0:3095958bc639 3 #include "mbed.h"
kholland 0:3095958bc639 4 #include "LPS331.h"
kholland 0:3095958bc639 5 #include "LIS3DH.h"
kholland 0:3095958bc639 6 #include "LM75B.h"
kholland 0:3095958bc639 7
kholland 0:3095958bc639 8 /* --CHANGE THIS FOR YOUR SETUP" -- */
kholland 0:3095958bc639 9 #define DeviceID "mbedskywire" //Freeboard DweetIO unique ID
kholland 0:3095958bc639 10
kholland 0:3095958bc639 11 DigitalOut myled(LED1);
kholland 0:3095958bc639 12 DigitalOut skywire_en(PA_6);
kholland 0:3095958bc639 13 DigitalOut skywire_rts(PA_7);
kholland 0:3095958bc639 14
kholland 0:3095958bc639 15 Serial skywire(PA_9,PA_10);
kholland 0:3095958bc639 16 Serial debug_pc(USBTX, USBRX);
kholland 0:3095958bc639 17
kholland 0:3095958bc639 18 I2C i2c(PB_9,PB_8);
kholland 0:3095958bc639 19 char msg[3];
kholland 0:3095958bc639 20
kholland 0:3095958bc639 21 LPS331 pressure(i2c);
kholland 0:3095958bc639 22 LM75B LM75_temp(PB_9,PB_8);
kholland 0:3095958bc639 23 LIS3DH accel(i2c, LIS3DH_V_CHIP_ADDR, LIS3DH_DR_NR_LP_100HZ, LIS3DH_FS_2G);
kholland 0:3095958bc639 24
kholland 0:3095958bc639 25
kholland 0:3095958bc639 26 char str[512];
kholland 0:3095958bc639 27 char str2[512];
kholland 0:3095958bc639 28 float latitude;
kholland 0:3095958bc639 29 float longitude;
kholland 0:3095958bc639 30 int number;
kholland 0:3095958bc639 31
kholland 0:3095958bc639 32 int main()
kholland 0:3095958bc639 33 {
kholland 0:3095958bc639 34 float axis[3];
kholland 0:3095958bc639 35 float press;
kholland 0:3095958bc639 36 float temp;
kholland 0:3095958bc639 37
kholland 0:3095958bc639 38
kholland 0:3095958bc639 39 debug_pc.baud(115200);
kholland 0:3095958bc639 40 skywire.baud(115200);
kholland 0:3095958bc639 41 skywire_rts=0;
kholland 0:3095958bc639 42 myled=0;
kholland 0:3095958bc639 43 debug_pc.printf("Starting Demo...\n");
kholland 0:3095958bc639 44 debug_pc.printf("Waiting for Skywire to Boot...\n");
kholland 0:3095958bc639 45 //Enable Skywire
kholland 0:3095958bc639 46 skywire_en=0;
kholland 0:3095958bc639 47 wait(2);
kholland 0:3095958bc639 48 skywire_en=1;
kholland 0:3095958bc639 49 wait(2);
kholland 0:3095958bc639 50 skywire_en=0;
kholland 0:3095958bc639 51
kholland 0:3095958bc639 52 myled=1;
kholland 0:3095958bc639 53 wait(5);
kholland 0:3095958bc639 54
kholland 0:3095958bc639 55 LM75_temp.open();
kholland 0:3095958bc639 56
kholland 0:3095958bc639 57 debug_pc.printf("Connecting to Network...\n");
kholland 0:3095958bc639 58 // get IP address
kholland 0:3095958bc639 59 skywire.printf("AT#SGACT=1,1\r\n");
kholland 0:3095958bc639 60 wait_ms(500);
kholland 0:3095958bc639 61 skywire.gets(str, 255);
kholland 0:3095958bc639 62 skywire.gets(str, 255);
kholland 0:3095958bc639 63 debug_pc.printf("Skywire says: %s\n", str);
kholland 0:3095958bc639 64
kholland 0:3095958bc639 65 // connect to dweet.io
kholland 0:3095958bc639 66 skywire.printf("AT#HTTPCFG=1,\"dweet.io\",80,0\r\n");
kholland 0:3095958bc639 67 skywire.gets(str, 255);
kholland 0:3095958bc639 68 skywire.gets(str, 255);
kholland 0:3095958bc639 69 debug_pc.printf("Skywire says: %s\n", str);
kholland 0:3095958bc639 70
kholland 0:3095958bc639 71 //get location approximation from cell tower information
kholland 0:3095958bc639 72 skywire.printf("AT#AGPSSND\r\n");
kholland 0:3095958bc639 73 skywire.gets(str, 255);
kholland 0:3095958bc639 74 skywire.gets(str, 255);
kholland 2:b57e24a42b6f 75 //skywire.gets(str, 255);
kholland 2:b57e24a42b6f 76 //skywire.gets(str, 255);
kholland 0:3095958bc639 77 debug_pc.printf("Skywire says: %s\n", str);
kholland 0:3095958bc639 78 sscanf(str, "%s %d,%f,%f,", str2, &number, &latitude, &longitude);
kholland 0:3095958bc639 79 debug_pc.printf("Location: Latt:%f, Long:%f\n", latitude, longitude);
kholland 0:3095958bc639 80
kholland 0:3095958bc639 81 while(1) {
kholland 0:3095958bc639 82 temp = (float)LM75_temp;
kholland 0:3095958bc639 83 debug_pc.printf("Temp = %.3f\n", temp);
kholland 0:3095958bc639 84 press=(float)pressure.value() / 4096;
kholland 0:3095958bc639 85 debug_pc.printf("Pressure = %.3f\n", press);
kholland 0:3095958bc639 86 accel.read_data(axis);
kholland 0:3095958bc639 87 debug_pc.printf("Accel = %.3f, %.3f, %.3f\n", axis[0], axis[1], axis[2]);
kholland 0:3095958bc639 88
kholland 0:3095958bc639 89 //Report Sensor Data to dweet.io
kholland 0:3095958bc639 90 skywire.printf("AT#HTTPQRY=1,0,\"/dweet/for/%s?temperature=%.3f&pressure=%.3f&X=%.3f&Y=%.3f&Z=%.3f&Latitude=%f&Longitude=%f\"\r\n", DeviceID, temp, press, axis[0], axis[1], axis[2], latitude, longitude);
kholland 2:b57e24a42b6f 91 skywire.gets(str, 255);
kholland 0:3095958bc639 92 skywire.printf("AT#HTTPRCV=1\r\n");
kholland 2:b57e24a42b6f 93 skywire.gets(str, 255);
kholland 0:3095958bc639 94 wait(5);
kholland 0:3095958bc639 95 }
kholland 0:3095958bc639 96
kholland 0:3095958bc639 97 }