Rest API - Send a data message

Hi,
I’ve a device with an Arduino and a SIM800. I want to send data to it, via the rest API. So on our web server I’ve made a piece of PHP for that. When I send the data using SMS, my device get the data.

When I send the data with the Dashboard using TCP, my device get also the data.

But when I try to call the rest API from my web server to send data using TCP, my device get nothing.
I tried using JSon or direct POST. Each time, Hologram Server replied “{“success”:true}” and on my LOG I can see data has been sent. But in fact they are not… (see log with id 20686880)
My code is a copy past of Hologram · Apiary

Any idea? Also, on the rest API page there is a “TAG: Additional topics to associate with the message. Optional” ???
And when you send data using TCP via the dashboard you set the port. But not when you call the rest API from a web page.

Notice: I know my device get nothing. My device as a small battery. When data are “incoming”, the battery “suffer” and its led turns from blue to red. When I get SMS from dashboard or from my web server or TCP data from dash, the led turn blue. Not when I send to the resp for TCP, while the log say data has been sent.

Optional question: which is the faster, sending by SMS or by DATA? And is DATA more reliable, eg at Xmas when a lot of people send SMS?

Lots of stuff here.

Step 1 is to first use a power supply with sufficient current to support 2A peak loads which is what you will get with the SIM800 and 2G. If your battery voltage is dropping outside of that allowed in the SIMCOM datasheet you will have inconsistent behavior no matter what you do. While ou debug and get started, ditch the battery and use a good power supply.

Next I think you are using the wrong endpoint. I am guessing you are using the “Send a Data Message” API at endpoint https://dashboard.hologram.io/api/1/csr/rdm This is how your device (SIM800) can send a message to Hologram (ie IoT->Cloud). This is not what you want. You want to use the “Send Message to a device” endpoint at https://dashboard.hologram.io/api/1/devices/messages This endpoint is Cloud->IoT and takes a payload:

{
  "deviceids": [
    1234,
    1236
  ],
  "protocol": "TCP",
  "port": 80,
  "encrypted": true,
  "data": "Hello world!",
  "base64data": "SGVsbG8gd29ybGQhCg=="
}

Notice this has protocol and port as parameters which is closer to what you want.

SMS vs DATA:
This depends on your use case, I have found SMS delivery to be unreliable and could take a long time (ie hours up to a day). On the other hand these SMS are free where TCP messages will cost you ~500B + actual payload. For what its worth I use data to send cloud messages to my devices.

Hi Andrew,
First of all thanks a lot for the answer
For the power supply, no problem I know that. As I’m debugging I just use a small battery pluged on USB without a “condo”. So it works but this let me see the battery led “suffering” telling me data are coming. But of course that’s only for testing purpose. :wink:
For second point, thanks a lot. I was suprised by the fact my call didn’t need port or protocole info. In fact the problem came from a confusion on Hologram page:

Here, “Send a SMS to the device” is on the same “block” than “Send a Data Message” while the first is SMS->Device and the second is “Device->Cloud” :no_mouth:
Now it works fine (notice that “encrypted=true” is not yet implemented)

Concerning “SMS vs Data” this is exactly what I was afraid of. As some of my calls are “emergency call”, I’ll use data for them;

Again, thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.