Data format to be sent to cloud using AT commands
- This topic has 25 replies, 5 voices, and was last updated 8 years, 11 months ago by James Coleman.
-
AuthorPosts
-
October 5, 2015 at 2:01 am #9473mb sParticipant
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
October 5, 2015 at 7:41 am #9475Jason ReissKeymasterThe 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 mLinux2. What cloud service are you wanting to send data to?
October 5, 2015 at 7:45 am #9476mb sParticipantThank 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?
October 5, 2015 at 8:10 am #9477James ColemanParticipantJason,
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
October 5, 2015 at 8:14 am #9478Jason ReissKeymasterBuilding 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:
October 5, 2015 at 8:39 am #9481Jason ReissKeymasterJames,
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.htmlM2X API:
https://m2x.att.com/developer/documentation/v2/overviewOctober 5, 2015 at 10:29 am #9485James ColemanParticipantOk. Thanks for this information. I will review this information and see how much progress I can make based on this information.
James
October 17, 2015 at 9:26 am #9651James ColemanParticipantJason,
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
October 17, 2015 at 10:02 am #9652Andrew LindsayParticipantOne 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
October 17, 2015 at 10:26 pm #9653James ColemanParticipantAndrew,
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.
October 20, 2015 at 9:17 am #9660Brandon BayerBlockedOctober 20, 2015 at 5:48 pm #9673James ColemanParticipantBrandon,
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
October 21, 2015 at 8:48 am #9674James ColemanParticipantBrandon,
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 configurationstatic 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 gatewayOctober 21, 2015 at 9:53 am #9675James ColemanParticipantBrandon,
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
October 21, 2015 at 10:27 am #9676James ColemanParticipantBrandon,
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());October 21, 2015 at 11:46 am #9678Brandon BayerBlockedJames,
Here is an example that transmits temperature data:
-Brandon
October 21, 2015 at 12:07 pm #9679James ColemanParticipantBrandon,
Thanks for the example. This should get me over the hump.
James
October 22, 2015 at 9:16 am #9683James ColemanParticipantBrandon,
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: 24Thanks,
James
October 22, 2015 at 9:22 am #9684Brandon BayerBlockedIf 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
October 22, 2015 at 1:44 pm #9687James ColemanParticipantBrandon,
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.
October 22, 2015 at 2:21 pm #9688James ColemanParticipantBrandon,
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
October 22, 2015 at 2:28 pm #9689James ColemanParticipantBrandon,
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 bytesOctober 23, 2015 at 7:57 am #9690James ColemanParticipantBrandon,
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
October 26, 2015 at 9:33 am #9714James ColemanParticipantBrandon,
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
October 26, 2015 at 10:25 am #9715Brandon BayerBlockedJames,
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 usingcurl
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
October 26, 2015 at 10:31 am #9716James ColemanParticipantOK. Will look at their website and examples.
Thanks,
James
-
AuthorPosts
- You must be logged in to reply to this topic.