Training Material using MultiTech Socket Modem-H5, Aeris AerCloud, and ST X-Nucleo-IKS01A1
Dependencies: AerCloud_MutliTech_Socket_Modem_Example MQTT Nucleo_Sensor_Shield mbed
Fork of AerCloud_MutliTech_Socket_Modem_Example by
Revision 5:429135c8bae8, committed 2015-01-21
- Comitter:
- BlueShadow
- Date:
- Wed Jan 21 04:39:46 2015 +0000
- Parent:
- 4:81c6b9d73cb1
- Commit message:
- MultiTech Modem, Aeris AerCloud, and ST IKS01A1
Changed in this revision
diff -r 81c6b9d73cb1 -r 429135c8bae8 AerCloud_MutliTech_Socket_Modem_Example.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AerCloud_MutliTech_Socket_Modem_Example.lib Wed Jan 21 04:39:46 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/AerCloud/code/AerCloud_MutliTech_Socket_Modem_Example/#81c6b9d73cb1
diff -r 81c6b9d73cb1 -r 429135c8bae8 FXLS8471Q.lib --- a/FXLS8471Q.lib Fri Dec 12 22:26:35 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/JimCarver/code/FXLS8471Q/#b1fd3a2572e2
diff -r 81c6b9d73cb1 -r 429135c8bae8 MPL3115A2.lib --- a/MPL3115A2.lib Fri Dec 12 22:26:35 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/teams/components/code/MPL3115A2/#8c90a97b1036
diff -r 81c6b9d73cb1 -r 429135c8bae8 Nucleo_Sensor_Shield.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Nucleo_Sensor_Shield.lib Wed Jan 21 04:39:46 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/ST-Americas-mbed-Team/code/Nucleo_Sensor_Shield/#57888ec40e75
diff -r 81c6b9d73cb1 -r 429135c8bae8 main.cpp --- a/main.cpp Fri Dec 12 22:26:35 2014 +0000 +++ b/main.cpp Wed Jan 21 04:39:46 2015 +0000 @@ -6,15 +6,14 @@ #include "mbed.h" #include "mtsas.h" #include "PubSubClient.h" -#include "FXLS8471Q.h" -#include "MPL3115A2.h" +#include "x_cube_mems.h" // // PLEASE READ THIS! // // Example was created for the following hardware: // ST Nucleo F401RE http://developer.mbed.org/platforms/ST-Nucleo-F401RE/ -// Freescale Multi-Sensor Shield https://developer.mbed.org/components/Freescale-Multi-Sensor-Shield/ +// ST Sensor Board http://developer.mbed.org/teams/ST-Americas-mbed-Team/wiki/Getting-Started-with-Nucleo-Sensors // MultiTech Socket Modem Shield: http://developer.mbed.org/components/Multi-Tech-SocketModem-Arduino-Shield-MT/ // MultiTech MTSMC-H5 GSM Socket Modem http://www.multitech.com/models/92503252LF#gsc.tab=0 // @@ -38,32 +37,42 @@ // You should see the something that looks like this in the browser: // {"sclContentInstances":[{"sclId":"nucleo-0001","containerId":"Nucleo_Test","contentInstance":{"id":"a40c8e60-8248-11e4-8b38-0677f0dfdf5e","contentSize":90,"creationTime":1418420922950,"content":{"contentType":"application/json","contentTypeBinary":"{\"x\":0.005615,\"y\":-0.041260,\"z\":1.015137,\"pressure\":101098.500000,\"temperature\":25.125000}"}}}, // -// + + + +char _APN[] = "Set_carrier_APN"; -char _AERCLOUD_API_KEY[] = "SET_YOUR_API_KEY"; -char _AERCLOUD_ACCOUNT_ID[] = "SET_YOUR_ACCOUNT_NUMBER"; -char _AERCLOUD_CONTAINER[] = "Nucleo_Test"; -char _AERCLOUD_DEVICE_ID[] = "nucleo-0001"; +char _AERCLOUD_API_KEY[] ="_Click_On_KEY_AerCloud_Tab"; +char _AERCLOUD_ACCOUNT_ID[] = "_Company_Number_Top_of_Page"; +char _AERCLOUD_CONTAINER[] = "_From_Container_Page"; +char _AERCLOUD_DEVICE_ID[] = "_Random_Title"; -char _APN[] = "SET_YOUR_CELLULAR_PROVIDERS_APN" "; char _host[] = "mqtt.aercloud.aeris.com"; int _port = 1883; -#define MPL3115A2_I2C_ADDRESS (0x60<<1) - #define DATA_INTERVAL 30 void callback(char* topic, char* payload, unsigned int len) { logInfo("topic: [%s]\r\npayload: [%s]", topic, payload); } +DigitalOut myled(LED1); +Serial pc(SERIAL_TX, SERIAL_RX); +volatile float TEMPERATURE_Value_C; +volatile float TEMPERATURE_Value_F; +volatile float HUMIDITY_Value; +volatile float PRESSURE_Value; +volatile AxesRaw_TypeDef MAG_Value; +volatile AxesRaw_TypeDef ACC_Value; +volatile AxesRaw_TypeDef GYR_Value; + int main() { - printf("Hello World\r\n"); + printf("Hello FUTURE!\r\n"); MTSLog::setLogLevel(MTSLog::TRACE_LEVEL); // for Nucleo boards - MTSSerialFlowControl io(D8, D2, D3, D6); + MTSSerialFlowControl io(D8, D2, D3, D13); // Modified Flow control for ST Sensor Board D13 io.baud(115200); Cellular* radio = CellularFactory::create(&io); @@ -72,8 +81,8 @@ return 1; } - radio->configureSignals(D4,D7,RESET); - Transport::setTransport(radio); + radio->configureSignals(D11,D7,RESET); // Modified Flow Control for ST Sensor Board D11 + Transport::setTransport(radio); // Required to control Cell Radio vs WiFi solution while (radio->setApn(_APN) != MTS_SUCCESS) { logError("failed to set APN [%s]", _APN); @@ -91,13 +100,16 @@ // valid ping, there's a connectivity problem. First step is to verify you've got the right APN set // // Try pinging default server "8.8.8.8" (Google's DNS) - //int ping_valid = 0; - //while (ping_valid == 0) { - // ping_valid = radio->ping(); - // printf("Ping Valid: %s\n\r", ping_valid ? "true" : "false"); + // int ping_valid = 0; + // while (ping_valid == 0) { + // ping_valid = radio->ping(); + // printf("Ping Valid: %s\n\r", ping_valid ? "true" : "false"); // - // if (ping_valid == 0) { - // wait(3); + // if (ping_valid == 0) { + // wait(3); + // printf("wait 33"); + // wait(33); + // } //} @@ -105,22 +117,48 @@ char buf[128]; - FXLS8471Q acc(D11, D12, D13, D10); - MPL3115A2 alt(D14, D15, MPL3115A2_I2C_ADDRESS, D4, D3); - alt.Barometric_Mode(); - - float acc_data[3]; - + static X_CUBE_MEMS *mems_expansion_board = X_CUBE_MEMS::Instance(); + + + /* Get data from all sensors */ + mems_expansion_board->hts221.GetTemperature((float *)&TEMPERATURE_Value_C); + mems_expansion_board->hts221.GetHumidity((float *)&HUMIDITY_Value); + mems_expansion_board->lps25h.GetPressure((float *)&PRESSURE_Value); + mems_expansion_board->lis3mdl.GetAxes((AxesRaw_TypeDef *)&MAG_Value); + mems_expansion_board->lsm6ds0.Acc_GetAxes((AxesRaw_TypeDef *)&ACC_Value); + mems_expansion_board->lsm6ds0.Gyro_GetAxes((AxesRaw_TypeDef *)&GYR_Value); + + TEMPERATURE_Value_F = (TEMPERATURE_Value_C * 1.8f) + 32.0f; + pc.printf("Temperature:\t\t %f C\r\n", TEMPERATURE_Value_C ); +// pc.printf("Humidity:\t\t %f%%\r\n", HUMIDITY_Value); + pc.printf("Pressure:\t\t %f hPa\r\n", PRESSURE_Value); +// pc.printf("Magnetometer (mGauss):\t mX: %d, Y: %d, mZ: %d\r\n", MAG_Value.AXIS_X, MAG_Value.AXIS_Y, MAG_Value.AXIS_Z); + pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n", ACC_Value.AXIS_X, ACC_Value.AXIS_Y, ACC_Value.AXIS_Z); +// pc.printf("Gyroscope (mdps):\t X: %d, Y: %d, Z: %d\r\n", GYR_Value.AXIS_X, GYR_Value.AXIS_Y, GYR_Value.AXIS_Z); + pc.printf("\r\n"); + + while (true) { - if (! mqtt.connect(_AERCLOUD_DEVICE_ID, _AERCLOUD_ACCOUNT_ID, _AERCLOUD_API_KEY)) { + if (! mqtt.connect(_AERCLOUD_DEVICE_ID, _AERCLOUD_ACCOUNT_ID, _AERCLOUD_API_KEY)) { logError("failed to connect to AerCloud Server"); wait(5); continue; } + +// get new data + myled = 1; // LED is ON + wait(0.2); // 200 ms + myled = 0; // LED is OFF - acc.ReadXYZ(acc_data); - - snprintf(buf, sizeof(buf), "{\"x\":%f,\"y\":%f,\"z\":%f,\"pressure\":%f,\"temperature\":%f}", acc_data[0],acc_data[1],acc_data[2], alt.getPressure(), alt.getTemperature()); + mems_expansion_board->hts221.GetTemperature((float *)&TEMPERATURE_Value_C); +// mems_expansion_board->hts221.GetHumidity((float *)&HUMIDITY_Value); + mems_expansion_board->lps25h.GetPressure((float *)&PRESSURE_Value); +// mems_expansion_board->lis3mdl.GetAxes((AxesRaw_TypeDef *)&MAG_Value); + mems_expansion_board->lsm6ds0.Acc_GetAxes((AxesRaw_TypeDef *)&ACC_Value); +// mems_expansion_board->lsm6ds0.Gyro_GetAxes((AxesRaw_TypeDef *)&GYR_Value); + pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n\n", ACC_Value.AXIS_X, ACC_Value.AXIS_Y, ACC_Value.AXIS_Z); + + snprintf(buf, sizeof(buf), "{\"xxx\":%d,\"yyy\":%d,\"zzz\":%d,\"pressure\":%f,\"temperature\":%f}",ACC_Value.AXIS_X, ACC_Value.AXIS_Y, ACC_Value.AXIS_Z, PRESSURE_Value, TEMPERATURE_Value_C); logInfo("publishing: [%s]", buf); if (! mqtt.publish(_AERCLOUD_CONTAINER, buf)) { logError("failed to publish: [%s]", buf); @@ -129,6 +167,8 @@ mqtt.loop(); mqtt.disconnect(); wait(DATA_INTERVAL); + } -} \ No newline at end of file +} +
diff -r 81c6b9d73cb1 -r 429135c8bae8 mtsas.lib --- a/mtsas.lib Fri Dec 12 22:26:35 2014 +0000 +++ b/mtsas.lib Wed Jan 21 04:39:46 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Multi-Hackers/code/mtsas/ +http://developer.mbed.org/teams/Multi-Hackers/code/mtsas/#bb3710d824db