Outbound SMS via either api?

OK, I’m lost - I’ve read and re-read both the REST API, and the embed api. (At this point I think I know just enough to be dangerous) And I’ve been able to send SMS messages to my device via the embeded api using the command line. I’ve been able to send from the command to my phone. But for the life of me I can not figure out how to get the dash to send a sms message.
I did get sms messages by routes - but when I did that I was getting everything the dash was doing (Init, AT commands, everything, my data did finally show up as well) But this isn’t what I wanted - I don’t need to see the AT commands.
It’s my understanding (at least from what I think I am reading) the api is the way to get it to send sms messages, and I know I’m missing something, but it’s just not coming to me what I need to do. Some example code would be very helpful.
I have searched here and on github and I just don’t see an example.

Hello again community -
not getting any answer to this question is a bit frustrating.
But I found something of a work around, I don’t like it, and it seems messy to me - and not so easy to change if I would want to do something different.
I ended up using a webhook, to newtifry notification service. I had to modified the sketch to send my data so that it would be appended to the end of the newtifry url.
something like this:
void doTempSend() {
char buf[8];
dtostrf(dht.readTemperature(true),4,2,buf);
String ret = "&message=Temperature: “;
ret.concat(buf);
ret.concat(”, ");
dtostrf(dht.readHumidity(),4,2,buf);
ret.concat("humidity: ");
ret.concat(buf);

SerialCloud.println(ret);

}

I got the idea from this thread:

This is not really how I wanted to do this project - but it did work. It seems like thou, if I wanted to send the same information to say thingspeak - and send it to a notification system I would be using a lot of data.

Hi @kd8bxp -
One way you could achieve this and save on outbound SMS is to have the Dash receive inbound SMS then respond via serialCloud print to trigger a webhook by SMS.
Here’s an example sketch that includes how to receive SMS on the Dash:

From there you could include a conditional in your sketch to send what you’d want in the SMS message through a Serial Cloud print message to trigger an SMS webhook similar to the ones you’ve found in the other thread.

Let us know if you have any other questions.

Best,
Ryan

One thing to add here: if you’re getting every single Dash message sent via SMS, that means you’re probably feeding the result of SerialCloud.read() into SerialCloud.write() so every system message gets sent to the cloud and hits your SMS rule.

1 Like

Ah, ok, that makes a lot of since - I was trying to learn how everything worked and was using just one of the examples while I had enabled the sms webhook. My current solution seems to be working for me, and I plan on documenting it for my demo I am doing on this Thursday (Jan 12, 2017). There are a few things I wish the webhooks did that they don’t seem to do right now, and it seems like my solution uses quite a bit of data - I’m not that worried about that right now thou, because I have to send a message to the device for it to trigger a response back to me. And I think a lot of the data I used was just in trying to figure things out (what to do, what not to do, etc…)
Some one should take the information from the post I linked to above and at least add the information to the docs. It took me a while to find that, but once I did it was kind of that “a-ah moment” we all need. I Think it was you @Reuben that suggested something like <<data.field1>> <,data.field2>> I like that idea, I think it should be something that would make using the webhook so much easier, and would cut down on the amount of data a device uses. I’d also like to suggest in addition to something like the <<data.fields>> something like <<data.number>> <<data.email>> could be used for the sms webhook, and email hook respectfully - In that way the device could send to a email list or a sms list with the need for a lot of configuration on the dashboard site (Now if it can already do something like that, then I missed it and the docs really need updated :slight_smile: )
I see a lot of possibilities now that I’ve figured out what I have figured out.

Yeah, we’d like to expand those variables a bit. Been trying to do that for a while now. Might have time soon.

BTW, we have this stuff documented here: https://hologram.io/docs/guide/cloud/routing-rules#custom-integrations-with-webhooks

@ryanHologram @Reuben a little update:
My demo of the device is tomorrow, I have upload my code and my documentation to github
and thought you may be interested (maybe someone else would be too) :slight_smile:
https://kd8bxp.github.io/dash_demo/ (After seeing a live screen of the docs I made, I realized I need to go back and re-edit them, but they are ok for now)
GitHub - kd8bxp/dash_demo: Hologram.io Dash Demo of RGB LEDs and DHT11 Temperature sensor using SMS, and APIs

I’ll let you guys know how the demo goes tomorrow night.
Thanks for the help,
LeRoy

Very cool, thanks a lot for sharing that. Good luck with the demo.

One thing I would suggest for stability–on line 190, add this:

if(currChar == '\0') { continue; }

(Turns out Arduino string doesn’t properly handle nulls in the middle of a string and with our new firmware you can get a null when the modem connection resets. I think we added a check for this on HEAD in our repo.)

@Reuben thanks for the update, I did see that the sketch was changed, but when I looked I just didn’t see what changed. I’ll update my code.

@Reuben What is the easiest way to get an sms response on my phone. I want to sms the dash from my cell phone, get a Dash.batteryPercentage(); and then automatically receive the value back via sms. :smile:

Easiest (and least expensive :slight_smile: ) way is a follows:

  1. Have your sketch look for your incoming phone SMS (Hologram has a few examples how to do this, like the RGB LED sketch above). No Hologram charge to send SMS TO the Dash.
  2. Use the HologramCloud to send the battery state of charge to the Hologram Cloud.
  3. Then, to get an SMS back to your phone from the Dash, use the Holgram Dashboard and set a Route to send you an SMS when new Cloud data is uploaded. Here’s an example: Good Luck!
2 Likes

@Existechno

You can also include custom topics now with messages from the Dash to the Cloud.

HologramCloud.sendMessage(Charger.batteryPercentage(), "battery_pct");

and use battery_pct (or another name you choose) in the Subscribes To box shown above. Also note that in Arduino release 0.9.2 and above Dash.batteryPercentage() (and other battery functions) were moved to the Charger class.

1 Like

@MichaelM Wow, thats a lot easier than I thought. Thanks a bunch.

@Erik Wow thanks again. So, just to clarify, I need to include Charger.begin(), and then i can send the Charger.batteryPercentage(). Is the battery_pct just for filtering within the cloud? Also, is there currently a way to auto-send texts directly from the dash to my cell phone? Thx

The Charger class is started before setup(), so there’s no need to call Charger.begin() explicitly.

The topic is mainly for cloud filtering, yes. You can use up to 10 topics per message with the Dash. And if you are capturing other data, you can use other topics also for different routing.

We don’t currently support sending SMS directly from the Dash. It’s on our road map to support, but I don’t have a timeframe I can give at this point.

FYI, one reason we generally push people to do SMS via our cloud is that it’s much cheaper. Outbound SMS directly from a device costs 19 cents per message, but going through our cloud is just a few hundred bytes of data usage which is less than 1 cent.

Hey, Reuben, here’s a question for the true code experts:

I see you recommend here (after the read cloud statement):

if(currChar == '\0') { continue; }

explicitly calling the null character. In another post, you had recommended using just 0 without the quotes:

if(currChar == 0) { continue; }

Which, if either, of these statements is preferable? Do they do the same thing to help the string functions keep working properly when communicating with the modem?

Thanks!!

@MichaelM
They are exactly the same. '\0' is the character symbol for null/zero.

Once you update to Arduino package 0.10.0 and firmware 0.9.8 that check is no longer needed. SerialCloud is going to be removed in the future, so you should start migrating over to the HologramCloud class and its functions.

Both of those are the same. (char) 0 is the same as '\0'
I don’t know if there’s any advantage to one over the other.

Note that you don’t need to do that anymore with the new firmware since you can just set a callback function to receive SMS instead of having to parse the SMSRCVD message.

Heh, we were both on top of that