I how not been able to figure out how I can use Electron as a web client. For example I would like to go to a page a post data like this:
http://www.mysite.com/data.aspx?field1=value1
How can I do that?
I how not been able to figure out how I can use Electron as a web client. For example I would like to go to a page a post data like this:
http://www.mysite.com/data.aspx?field1=value1
How can I do that?
What do you mean with āweb clientā exactly?
But for what you asked to do there will be best done via this
https://docs.particle.io/reference/javascript
Having a look in the docs before posting a question is much appreciated (a.k.a. not so frowned upon than the other way round).
Thank you for your answer, Iām sorry, please bear with me. A part of being a beginner is to learn how to navigate documentation. And ask lots of āwrongā questions. Eventually I will be able to ask better questions (and possible even to contribute). And buy more Electrons!
This is what I would like to do: I want the Electron to take temperature measurements at regular intervals. I know how to do that. Then I want the Electron to post each value to a web page (that I create and host on my own server). Itās easy to create the string (http://www.mysite.com/data.aspx?field1=value1) but how do I make a call to this URL using Electron?
I have already been able to do what I want using an Arduino and an Arduino Ethernet Shield. It works well, but itās a wired solution. Now I want to do the same over GSM.
Thanks for pointing me in the right direction!
Other keywords to look up in the docs for what you said there might be Particle.publish()
which would be one way to actively push data from your device.
In conjunction with this Webhooks would be useful.
And less secure (but since your page is not https
but http
) you could look at TCPClient
or even the HTTPClient
library
Iād go for Particle.publish()
and webhooks, since this is secure and uses little of your data allowance.
Yes, I was able to make it work! Hereās the Electron code:
TCPClient client;
void setup() {
Serial1.begin(9600);
Serial1.println("Connecting...");
if (client.connect("mysite.com", 80))
{
Serial1.println("Connected");
client.println("GET /?temp=89 HTTP/1.0"); //the measured temp is 89 deg
client.println("Host: mysite.com");
client.println("Content-Length: 0");
client.println();
Serial1.println("Temp transmitted");
}
else
{
Serial1.println("connection failed");
}
}
At the server I run an ASP.NET script that captures the temperature when the page loads (in this case with āmysite.com?temp=89ā).
Request.QueryString("temp")
The rest of the ASP.NET script stores the data.
Thatās awesome! Congratulations! Seems as though you are quickly on your way to graduate from ābeginner-hoodā
Let us know if thereās anything we can do to help you continue the journey!