Jump to content
  • 0

Control Arduino with HC2


Question

Hi there,

 

I'm building a Nextion touchscreen with a arduino ESP8266 chip. I already can start scene's from the display. I'm now struggeling with a way to communicate back. Is there someone who can tell me how to send value's from a variable in Fibaro HC2 to the arduino ESPchip?

 

I created a webserver running on the arduino and can make different actions on it i.e. /ledon runs a led on script on the arduino. But this way i need to make a different script for every single action/value of a variable. undoable when I want to send temp or lux to the arduino. Is there a way, so yes how, to send the value of a global variable in fibaro HC2 to a global variable in the arduino.

 

Cheers,

 

Damien

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
3 hours ago, 10der said:

http://HC2-IP/docs

 

I'm familiar with the docs page, thanks.  Do I have to think the other way around? Let the arduino make GET commands in order to 'fill' it's variables?

Link to post
Share on other sites
  • 0
31 minutes ago, DPKok said:

Let the arduino make GET commands in order to 'fill' it's variables?

yep! absolutely right!

Link to post
Share on other sites
  • 0
Quote

function asyncGet(url, options)
    local headers = {['Content-Type'] = 'application/json'}
    local opt = options or {}
    self.http:request(url, {    
        options={
            headers = headers,
            method = 'GET'
        }, 
        success = function (response)
            if response then
                opt.success(response)
        end,
        error = function (error)
            opt.error(error); 
        end    
    })
end

 

function setLedOn()
    asyncGet(
        'http://' .. ip .. '/ledon', 
        {
        success=function(resp)
            local data = json.decode(resp.data)
            if data.code == 1000 then
            else
            end            
        end, 
        error=function(error)
        end
        }
    )
end
 

Is this what you mean?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...