I've been having trouble sending communications to the YUN from a web page.
If I use "arduino.local/digital/8/1" in my browser, I can activate a relay on Digital pin 8. I can also turn it off with the same command having a 0 at the end.
I cannot get these actions to occur as a result of buttons on the web page.
I have been referring to Chapter 2 of "Internet of Things with the Arduino YUN" book. The afore mentioned REST commands work from the "address bar" in the browser but not due to button action.
I've tried sending data to the YUN via HTML/JAVASCRIPT/PHP as in the examples in the book and through a third party offering found in this forum that uses
String command = client.readString();
if (command == "ledon") {
neither work. The buttons react to being clicked but no corresponding action occurs on the relay.
I suspect that I might have toggled some parameter in the YUN configuration. I might be obvious to someone who understands the YUN better than I, what it might be.
The big clue is that http://my yun's IP/digital/pin etc REST calls work but the control of any pins cannot be done from a web page.
I am using a third party YUN Shield on a Leonardo, but it seems to do everything else with no problem.
bradski58:
If I use "arduino.local/digital/8/1" in my browser, I can activate a relay on Digital pin 8. I can also turn it off with the same command having a 0 at the end.
I cannot get these actions to occur as a result of buttons on the web page.
Then your buttons are not causing the same GET message as typing in the browser creates
Can you add a Javascript alert() to show what the buttons produce?
Please note: I am using a Geeetech Iduino YUN Shield.
The problem was resolved with two actions:
1 update the firmware dragino2-yun-common-v2.0.4-kernel.bin
2 Add the baudrate into the Bridge.begin(insert baud here); // it was 250000
After all this, it finally worked. I am not sure if it was one of these or a combination of the two that fixed it.
The strange thing is that the REST commands worked previously. I would have thought that if the linux side was able to communicate with the Arduino side (through ip/digital/8/1 type url commands in a browser) it should be able to work with the html stuff (in /www/index.html)