Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
  • 0
DPKok

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

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 1

Or you can build on the Z-Uno, an Arduino board with a Z-wave chip. Very easy to use.

Please login or register to see this link.

 

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • 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?

    Share this post


    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!

    Share this post


    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?

    Share this post


    Link to post
    Share on other sites
    • 0
  • Inquirer
  • I'm not sure, thats behond my knowledge of programming... :(

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×