RESTful call in C (Arduino) using digest authentication

Posted on
Fri Jul 22, 2016 8:43 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

RESTful call in C (Arduino) using digest authentication

Hey all, another REST question,

I have used cURL and other RESTful interactions with Indigo for some time with no problem (in Ruby, python, etc) using digest authentication. I strongly want to avoid basic authentication.

I am toying with an ESP8266 Sparkfun Thing, which used C for the Arduino IDE. My understanding is the Arduino IDE can run most anything that can be compiled in C. I want my device to send temperature and humidity data to variables in Indigo (made one for $10, plan to make more, as well as motion detectors, etc).

Given most tutorials on the web don't reference digest authentication for this type of project, does anybody have any tips for how best to do this.

1) I might be able to include a curl.h library that facilitates it
2) I MIGHT be able to do it in my own C (though I would like to avoid this learning curve)
3) Many appear to sidestep digest authentication by using basic authentication to send to a separate server, then using PHP to forward the information to Indigo Server
4) I believe kw123 made an Indigo plugin, though after reading 24 pages of posts, I might be in over my head, and I am uncertain if it uses digest authentication

Thoughts greatly appreciated!

Posted on
Fri Jul 22, 2016 9:26 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

RESTful call in C (Arduino) using digest authentication

The arduino plugin is very simple: it sends http get to the arduino and the arduino answers with an http reply. No encryption what so ever
If you use the original arduino uno it likely does not have enough ram to do anything sophisticated

The esp has enough ram but you need to make sure that you give it enough time to do it's things. (Add waits ) if not it will reboot.
...
The other option is the photon
That comes with its own environment




Sent from my iPhone using Tapatalk

Posted on
Fri Jul 22, 2016 9:35 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: RESTful call in C (Arduino) using digest authentication

Hey kw123, thanks for the speedy response, and apologies for my simple understanding of this.

So you are telling me I can read the digital input on the ESP (connected to a DHT22 temp/humidity sensor) directly from Indigo? This sounds too good to be true! What kind of client code do I need to run on the ESP? Thank you so much for the direct response!!!

Edit: Just read your plugin description (was previously reading the discussion thread), and yes, I see it can do all of that!

Before I go down the rabbit hole:
1) this plugin retrieves info from Arduino, rather than listens for it, yes?
2) if so, any tips on battery operating an ESP? I suppose I can try to coordinate sleep times between the sketch and Indigo via some hacky algorithm that only makes sense to me, but it may be far easier!

Posted on
Fri Jul 22, 2016 10:55 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: RESTful call in C (Arduino) using digest authentication

Yes it continuously polls. You can set the interval.

Esp on battery is a challenge. When sending it uses > 0.6 amps
Normally 0.3 amps. That will drain any battery quickly.

You can turn it on/ off /on on your schedule. When it turns itself on the plugin will realize it and will configure it~ 2 polling cycles
You will get messages that it is offline when the plugin can not reach it. I could add a switch to turn the logging off

I thought about sending too but that does not work on the arduino as it does not have enough ram. So either sending or receiving. I decided for receiving on the arduino. You can set the query rate in the plugin to 1 second. The response is normally ~ 0.1-0.5 seconds.


If you want to go beyond try the raspberry. It is much more powerful and you can use any digital sensor you like and with an adc ($3 for 8 channels) any analog. I have tested about 15 sensors. It supports sps i2c one wire, ht22, Distance , proximity, movement has sensors ...

Back to the arduino. There is a discussion on how to use multiple ht22 temp sensors

Karl.


Sent from my iPhone using Tapatalk

Posted on
Fri Jul 22, 2016 12:09 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: RESTful call in C (Arduino) using digest authentication

Hmmmm, at 0.6mA, if i poll every 10 minutes, that's just under 10 days on an 850 LiPo, but hourly is 2 months. Your plugin is so elegant, howeer, I may just get some wall warts and add more sensors. Thank you so much for your help, it has saved me many hours of R&D!

Posted on
Fri Jul 22, 2016 5:10 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: RESTful call in C (Arduino) using digest authentication

0.6 amps not 0.6 mA
Factor 1000 more.


Sent from my iPhone using Tapatalk

Posted on
Tue Jul 26, 2016 1:51 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: RESTful call in C (Arduino) using digest authentication

Yeah, I really know very little. I'll try and add curl.h to my code and see if the ESP handles digest and post back. Thanks!


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests