Need Simple Served Web Page Control

I want to use a Particle Core or Photon to run a robot. I found projects that use ESP 8266 to run robots over a WiFi, so I though it would be nice to use the Particles I have around. First I controlled the robot using the Cloud (Particle Build and Console), but there is too much lag to be very useful for driving a robot.

My next approach is to have have the Particle serve up a simple web page with buttons for control on my local WiFi. This has been frustrating.

I modified and flashed TINYWEBSERVER.INO successfully

What I cannot figure out is how the Particle can respond to button pushes on the web page. I’d like to start with a “Push to Toggle LED” button.

I’ve looked through the documentation and found these:

This it too complicated. The “Complete Example” is virtually impossible to understand. And, BTW, it is not complete because it has no setup and loop functions.

I can follow (with difficulty) the HTML page that is stored as one long string. I cut and pasted it into an editor and manually broke it into lines.
As Far As I Can Tell (AFAICT) several JavaScript libraries are defined as almost incomprehensible strings. A couple to handle RSA encryption, I think. Then finally a string variable script_js that defines the functions to handle the call backs.

I guess it works, but it is not very helpful for my much simpler task.
What do I need to just push a button on a served web page, and turn an LED on and off?

Are you trying to simply serve up a webpage that controls your device, or are you also wishing to include SoftAP capability?

I just want to serve a web page that controls some Digital pins. But the delay going through the cloud is too long for robot control.

look at the WebServer.h library in the IDE; plenty of examples included there.

Basically you poll the device for current state (Particle Variables) and Send Commands using Particle Functions.

You can include the JavaScript SDK in the app, or use JQuery or simple JavaScript methods to control the device.

If you need an example, I can send you one, but there are many posted here on the Forum.

Also some advice. Develop the webpage on a desktop text editor and test in a browser first… then convert it for your device… debugging HTML on a Photon can be excruciatingly painful and time consuming.

1 Like

On the contrary, it is complete since it does not need a setup() and loop()
Just try building the sample as is.

I’ve also posted a way to reuse the SoftAP function to interact with the devices

If you then add

void setup() {

The device will start in SoftAP Mode and you can interact with it right away on<whateverYourPage.html>/