I am trying to add an automatic shutoff based on reported temperature. When I add this code to the page that the device itself reports its data to, it causes an exact 5 minute (300 seconds) delay, I’m unable to see any reports during this time, then it processes all the backed up requests at once. However, if I put that same code into a page and load it from my computer’s browser, it appears to run instantly and does not disrupt the device. Are there any security issues or reasons that the server would treat my computer/browser differently than it treats an identical request from the imp?
This is rather related to your server, not the imp - the code is running on that server and is unrelated to the imp.
One thing I can see from a quick google is that when you use CURLOPT_POSTFIELDS you appear to be supposed to use CURLOPT_POSTFIELDSIZE to indicate the length, vs rolling your own headers as you are here?
I’m a bit confused by what you are doing. Is the imp doing the remote shutoff or is the imp doing the reporting? And you are using a PHP script on a website? or an API from somewhere? What exactly is supposed to happen … the process?
I am moving a mechanical actuator to disable a diesel engine. It must pull a cable, and then return to its original position. Without leaving my main page, I want to send a signal to a device pin to set an analog output voltage. Then 15 seconds later I want to reset that voltage to its original output voltage which returns the actuator to its original position.
So, I’m using this in my index.php, and it calls toggle_diesel.php (further below) to send the CURL
So you have an existing web page that I assume is private (nobody has a link to it)? If you put your imp id in the javascripting on that page, anyone can view the HTML and see your imp id. Do you have at least one limit switch on the mechanism connected to the imp so you can verify the actuator is in the original position?
What you’re doing is very similar to my garage door web app. I have a web page that I can view the door status (using 2 limit switches) and then pulse the door opener to open or close it. It reports back the switches in real-time, like you are wanting to do with JQuery/javascripting.
One other thing I do (and I got a lot of my imp scripting from others here on this forum) is to send an API key with the header. In case anyone else happens to get a hold of my imp id, the PHP sends a key with the CURL POST and the imp has to recognize it. Extra security.
The device electronics: Switches go to imp input pins, and the imp output pin pulses a small relay, which is tied to the garage door opener. Again the same idea you are doing. The imp can switch a large load, like a 12VDC power seat motor (linear actuator) that has a lot of torque … by using a relay w/transistor to switch the higher voltage using a 3.3V imp pin. You probably already have 12VDC at your engine.
Send me a private message/conversation with your email address and I’ll send you copies of my PHP, agent and device.