[SOLVED] Sample Code on How to Setup Control Switch - Electric Imp

Hello,

I am trying to setup a Control ON/OFF switch to start / stop logging to ubidots from my electric imp. On the electric imp I have my code setup to receive the message from ubidots. What I need help is on how to setup the button to send the request to electric imp.

Turn log On:
https://agent.electricimp.com/_9WCyhj-OhFx?log=1

Turn log Off:
https://agent.electricimp.com/_9WCyhj-OhFx?log=0

Well did not get a reply but I was able to get it solved using answer from this post: WiDo IoT Node Tutorial data not showing up in dashboard

 function getUbiDotsPwrBtn(){
    
       local headers = { "Content-Type": "GET", "X-Auth-Token": UBIDOTS_X_Auth_Token }; // Replace the token with yours
       local url = "http://things.ubidots.com/api/v1.6/variables/<<YOUR VARIABLE>>/values/?page_size=1&token=<<YOUR TOKEN>>";
       local request = http.get(url, headers);
       local response = request.sendsync(); 
}

You will get a response like this:

{
    "count": 11, 
    "next": "http://things.ubidots.com/api/v1.6/variables/57562c06762542450a5e3226/values/?token=AIRwWfUENGTOKEN&page=2&page_size=1", 
    "previous": null, 
    "results": [
        {
            "url": "http://things.ubidots.com/api/v1.6/values/57661ce276254261831098aa", 
            "value": 1.0, 
            "timestamp": 1466309858069, 
            "context": {}, 
            "created_at": "2016-06-19T04:17:38.069"
        }
    ]
}

Hi James, sorry to hear you didn’t got an answer before, but thanks a lot for your contribution. We’re releasing an official MQTT broker this month, so instead of doing continuous GET requests you could leave an open connection and get a faster response. Will let you know when it’s up.

Hi @Prospec007 our MQTT broker documentation is now live at: http://ubidots.com/docs/api/index.html#mqtt-api-reference