Data format to be sent to cloud using AT commands

Home Forums mDot/xDot Data format to be sent to cloud using AT commands

Tagged: , , ,

Viewing 26 posts - 1 through 26 (of 26 total)
  • Author
    Posts
  • #9473
    mb s
    Participant

    I just started using the mDot board. It is very helpful if i came to know about updating of firmware, format of dat to send to cloud using AT commands

    #9475
    Jason Reiss
    Keymaster

    The format of the cloud data will be dependent on the Cloud back-end you are using. Also delivery methods will be different depending on the version of Conduit you have. AEP includes Node-RED to connect to a cloud service, where as mLinux will need a separate application to deliver the data.

    Questions:
    1. What flavor of Conduit do you have? AEP or mLinux

    2. What cloud service are you wanting to send data to?

    #9476
    mb s
    Participant

    Thank you Jason Reiss,

    I just started working for LoRa communication to Cloud using JSON format on WINDOWS platform. I want to know the steps from starting like what should be the platform to be used for coding in C?

    #9477
    James Coleman
    Participant

    Jason,

    I would like to be a part of this post also. I would like to develop a quick demo with mDot and Conduit that shows how I can send data from my mDot to the Conduit and then have the Conduit forward the data to the Cloud.

    The flavor of my Conduit is mLinux.
    The cloud service that I want to send data to is the AT&T M2X cloud service.

    Where do I find the information that shows examples, details, etc on how to configure the mDot, etc?

    Thanks,

    James

    #9478
    Jason Reiss
    Keymaster

    Building software for Conduit will require using a Linux distribution, we support and test Ubuntu and Debian.

    Information for coding C for applications running in mLinux in Conduit can be found here:

    Application Development

    C/C++ Toolchain

    #9481
    Jason Reiss
    Keymaster

    James,

    The quickest way to develop a demo using mLinux will be using node.js to post data via http/https to M2X.

    Node.js https:
    https://nodejs.org/api/https.html

    M2X API:
    https://m2x.att.com/developer/documentation/v2/overview

    #9485
    James Coleman
    Participant

    Ok. Thanks for this information. I will review this information and see how much progress I can make based on this information.

    James

    #9651
    James Coleman
    Participant

    Jason,

    Would it be possible for you to walk me through the process of transferring data from mDot to Conduit gateway and then posting this data to a webpage on M2X site.

    I need to sense when a box is powered on, and then measure the battery used to power the box, then show both the power state of the box and the battery voltage on the webpage. I also would like to monitor the state of one additional event in the box and show this state at state at a specified time intervals on the site. This time interval can be 10 minutes for demo purposes.

    Any example code, guidance you can provide would really help.

    Thanks,

    James

    #9652
    Andrew Lindsay
    Participant

    One thing you need to bear in mind is that the mDot to Conduit communications via LoRaWAN will require the smallest possible data payload if you are looking to use maximum range. In some cases this could be as small as 12 bytes. This is also dependant on the SF and BW used. The Conduit to Cloud is a different area and you’re not restricted in the payload size as you are going over the internet.

    Andrew

    #9653
    James Coleman
    Participant

    Andrew,

    Thanks for the information. The data that I want to transfer is not much. All I need to do is monitor the status of two Digital Input pins and an Analog Input pin. I need to report a status change of the two Digital Input pins and need to report the initial Analog Input voltage value and then report when the Analog voltage drops below a certain value.

    So 12 bytes should be fine for this application.

    #9660
    Brandon Bayer
    Blocked

    James,

    This page has a sample nodejs app with usage instructions. Have you used that yet?

    -Brandon

    #9673
    James Coleman
    Participant

    Brandon,

    I have used this before. I will take a look at the example again to see if I understand what is going on code wise. All I need to do is send two binary data values and one analog data value to the Conduit Gateway and then to the cloud to a webpage. Might you be able to walk me through the process?

    Thanks,

    James

    #9674
    James Coleman
    Participant

    Brandon,

    I am currently trying to use the mDot_LoRa_Connect_Example program to transfer the data that I want to transfer to the Conduit gateway. As you know the example program transfers the string value “hello” to the Conduit gateway.

    I have modified the mDot_LoRa_Connect_Example program (shown below) to include the additional code that monitors the value of two Digital Input pins and the value on one Analog Input pin on the mDot. These are the three values that I want to send to the Conduit. Not sure how to add the code to send these values. An example to get me started would help.

    I am also sending these values to the USB Debug Terminal Window. The terminal window output is also shown below for reference.

    /**********************************************************************************
    * This program monitors the power on state, kill state and battery voltage on
    * Woodstream mouse trap using the Multitech mDot and UDK2 development system.
    * The power on state is monitored on the PA_4(UDK2 Pin D10)and the kill state is
    * monitored on the PA_5 (UDK2 Pin D13) Digital Input Pins. The battery voltage
    * is monitored on the PB_1 (UDK2 Pin A0) Analog Input. The status of these pins
    * are transferred from the mDot LoRa to the Conduit LoRa gateway. The status is
    * also shown on the USB Debug Terminal Window.
    *********************************************************************************/

    #include “mbed.h”
    #include “mDot.h”
    #include “MTSLog.h”
    #include <string>
    #include <vector>
    #include <algorithm>

    // These options must match the settings on the Conduit
    // Uncomment the following lines and edit their values to match your configuration

    static std::string config_network_name = “JFETENGINEERING”;
    static std::string config_network_pass = “Deboraheng”;
    static uint8_t config_frequency_sub_band = 7;

    int main() {

    int32_t ret;
    mDot* dot;
    std::vector<uint8_t> data;
    std::string data_str = “hello!”;

    //Line 34 to Line 54 is code added by James Coleman for Woodstream mousetrap demo
    //Read Analog Input Voltage Pin PB_1 (UDK2 pin A0)
    AnalogIn batt_voltage(PB_1);

    //Read Digital Input Pins PA_4 (UDK2 pin D10) and PA_5 (UDK2 pin D13)
    DigitalIn mt_pwron(PA_4);
    DigitalIn mt_caught(PA_5);

    int old_mt_pwron = -1;
    int old_mt_caught = -1;

    if (mt_pwron != old_mt_pwron){
    old_mt_pwron = mt_pwron;
    }
    if (mt_caught != old_mt_caught){
    old_mt_caught = mt_caught;
    }
    //printf(“\n\r batt_voltage: %f”,(batt_voltage*3.3));
    printf(“\n\r mt_pwron: = %d mt_caught: = %d batt_voltagge: %f”, old_mt_pwron, old_mt_caught, (batt_voltage*3.3));
    wait_ms(500);

    // get a mDot handle
    dot = mDot::getInstance();

    // print library version information
    // logInfo(“\n\r version: %s”, dot->getId().c_str());
    // James Coleman Added printf statement below. I commented out statement above which is part of original program
    printf(“\n\r version: %s”, dot->getId().c_str());

    //*******************************************
    // configuration
    //*******************************************
    // reset to default config so we know what state we’re in
    dot->resetConfig();

    dot->setLogLevel(mts::MTSLog::INFO_LEVEL);

    // set up the mDot with our network information: frequency sub band, network name, and network password
    // these can all be saved in NVM so they don’t need to be set every time – see mDot::saveConfig()

    // frequency sub band is only applicable in the 915 (US) frequency band
    // if using a MultiTech Conduit gateway, use the same sub band as your Conduit (1-8) – the mDot will use the 8 channels in that sub band
    // if using a gateway that supports all 64 channels, use sub band 0 – the mDot will use all 64 channels
    logInfo(“setting frequency sub band”);
    if ((ret = dot->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) {
    logError(“failed to set frequency sub band %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo(“setting network name”);
    if ((ret = dot->setNetworkName(config_network_name)) != mDot::MDOT_OK) {
    logError(“failed to set network name %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo(“setting network password”);
    if ((ret = dot->setNetworkPassphrase(config_network_pass)) != mDot::MDOT_OK) {
    logError(“failed to set network password %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    }

    // a higher spreading factor allows for longer range but lower throughput
    // in the 915 (US) frequency band, spreading factors 7 – 10 are available
    // in the 868 (EU) frequency band, spreading factors 7 – 12 are available
    logInfo(“setting TX spreading factor”);
    if ((ret = dot->setTxDataRate(mDot::SF_10)) != mDot::MDOT_OK) {
    logError(“failed to set TX datarate %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    }

    // request receive confirmation of packets from the gateway
    logInfo(“enabling ACKs”);
    if ((ret = dot->setAck(1)) != mDot::MDOT_OK) {
    logError(“failed to enable ACKs %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    }

    // save this configuration to the mDot’s NVM
    logInfo(“saving config”);
    if (! dot->saveConfig()) {
    logError(“failed to save configuration”);
    }
    //*******************************************
    // end of configuration
    //*******************************************

    // attempt to join the network
    logInfo(“joining network”);
    while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
    logError(“failed to join network %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());
    // in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
    osDelay(std::max((uint32_t)1000, (uint32_t)dot->getNextTxMs()));
    }

    // format data for sending to the gateway
    for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
    data.push_back((uint8_t) *it);

    while (true) {
    // send the data to the gateway
    if ((ret = dot->send(data)) != mDot::MDOT_OK) {
    logError(“failed to send”, ret, mDot::getReturnCodeString(ret).c_str());
    } else {
    logInfo(“successfully sent data to gateway”);
    }

    // in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
    osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
    }

    return 0;

    }

    Terminal Window Output

    mt_pwron: = 0 mt_caught: = 0 batt_voltagge: 2.532015
    version: 0.0.9-1-ge7286ba[INFO] setting frequency sub band
    [INFO] setting network name
    [INFO] setting network password
    [INFO] setting TX spreading factor
    [INFO] enabling ACKs
    [INFO] saving config
    [INFO] joining network
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway
    [INFO] successfully sent data to gateway

    #9675
    James Coleman
    Participant

    Brandon,

    Have one more question for you. I am trying to set the TX power for mDot using the following statement. I receive an error when I compile.
    Is this syntax not correct?

    logInfo(“setting TX power”);
    if ((ret = dot->setTxPower(mDot::20dBm)) != mDot::MDOT_OK) {
    logError(“failed to set TX power %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());

    Thanks,

    James

    #9676
    James Coleman
    Participant

    Brandon,

    I fixed the issue with setting the TX power. I used the following statements.
    The code compiled with these statements.

    static const uint32_t config_txpower = 20;

    logInfo(“setting TX power”);
    if ((ret = dot->setTxPower(config_txpower)) != mDot::MDOT_OK) {
    logError(“failed to set TX power %d:%s”, ret, mDot::getReturnCodeString(ret).c_str());

    #9678
    Brandon Bayer
    Blocked

    James,

    Here is an example that transmits temperature data:

    https://developer.mbed.org/teams/Multi-Hackers/code/thermostat_fan_demo-sensor/file/d55b476ea5e6/main.cpp

    -Brandon

    #9679
    James Coleman
    Participant

    Brandon,

    Thanks for the example. This should get me over the hump.

    James

    #9683
    James Coleman
    Participant

    Brandon,

    I am in the process of modifying your temperature sensor program to use for my application. I am getting the following errors when I compile.
    Why is the compiler having trouble with the dot identifier? Where is this defined? Same question for other Identifiers compiler is complaining about also.

    Error: Identifier “ledTick” is undefined in “main.cpp”, Line: 54, Col: 6
    Error: Identifier “dot” is undefined in “main.cpp”, Line: 63, Col: 6
    Error: Identifier “datachanged” is undefined in “main.cpp”, Line: 101, Col: 10
    Warning: Single-precision operand implicitly converted to double-precision in “main.cpp”, Line: 113, Col: 118
    Error: Identifier “dot” is undefined in “main.cpp”, Line: 131, Col: 27
    Error: Identifier “dot” is undefined in “main.cpp”, Line: 138, Col: 24

    Thanks,

    James

    #9684
    Brandon Bayer
    Blocked

    If they are undefined, it means you haven’t defined them. As you can see in the example sensor program, dot is defined like this:

    
    mDot* dot;
    Ticker ledTick;

    -Brandon

    #9687
    James Coleman
    Participant

    Brandon,

    I have fixed all of my compile errors except for the one shown below. I have no idea what this means. Any ideas on what is going on here?

    Error: “/extras/mbed_34e6b704fe68/TARGET_MTS_MDOT_F411RE/TOOLCHAIN_ARM_STD/stm32f411re.sct”, line 36 (column 9): Error: L6235E: More than one section matches selector – cannot all be FIRST/LAST.

    #9688
    James Coleman
    Participant

    Brandon,

    I figured out what the problem is. My program is compiling now.
    Now I will see if I can send my data to the Conduit.

    Thanks,

    James

    #9689
    James Coleman
    Participant

    Brandon,

    I am very close. It appears that the size of my data is one byte to large.

    Reference terminal window capture below.

    I have my mDot Tx Power set to 20 and the Conduit Tx Power set to 26.
    The spreading factor I am using is 10.

    What parameter(s) do I need to change in order to increase the number of bytes that I can send?

    power on: 0, kill status: 0, battery voltage: 2.517509
    Sending data… [ERROR] Data size 54 invalid, max 53 bytes
    Invalid Parameter – Data size 54 invalid, max 53 bytes

    #9690
    James Coleman
    Participant

    Brandon,

    I figured out how to set the spreading factor to a different value. I am now able to transfer data from my mDot to the Conduit.

    Next step is to get the data to the cloud and show the data on a website.

    Thanks for your help.

    James

    #9714
    James Coleman
    Participant

    Brandon,

    Now that I have data transferring from my mDot to the Conduit, what are the best examples to use for sending data from the Conduit to a cloud server such as Bug Labs or M2X. I want to show the data that is being sent from Conduit to the Cloud on a webpage.

    Thanks,

    James

    #9715
    Brandon Bayer
    Blocked

    James,

    I suggest looking at the documentation for whatever cloud server you want to use. They probably have examples for posting data from the command line using curl and for different programming languages. Get it working using curl and then use the same keys, settings, etc. in your preferred language. If you need further help getting data to the cloud server, I suggest contacting them for help. We can help with Conduit specific things (like running the nodejs sample app), but we can’t support other cloud servers.

    -Brandon

    #9716
    James Coleman
    Participant

    OK. Will look at their website and examples.

    Thanks,

    James

Viewing 26 posts - 1 through 26 (of 26 total)
  • You must be logged in to reply to this topic.