# Homey and Arduino

**URL:** <https://community.homey.app/t/homey-and-arduino/54464>\
**Category:** Developers\
**Created:** [November 7, 2021, 9:27pm UTC](https://community.homey.app/t/homey-and-arduino/54464 "2021-11-07T21:27:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikael\_Sandberg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mikael_sandberg/32/33829_2.png) [@Mikael\_Sandberg](https://community.homey.app/u/Mikael_Sandberg)\
**Post date:** [November 7, 2021, 9:27pm UTC](https://community.homey.app/t/homey-and-arduino/54464/1 "2021-11-07T21:27:34Z")

</div>

I have gotten the Arduino MKR WiFi 1010 to work with HomeyArduino app.

I have a stable connection and I can change capabilities from Homey on the Arduino board. I can execute actions and check conditions. But I have one problem…

I can not synchronize the state of the Arduino board on power cycle or reset. I have a sync function that contains this

Homey.setCapabilityValue(“onoff”,s\_state,true);  
Homey.setCapabilityValue(“dim”,s\_intensity);  
Homey.setCapabilityValue(“light\_hue”,s\_hue);  
Homey.setCapabilityValue(“light\_saturation”,s\_saturation);

This is called from the setup function in the Arduino sketch, after Homey is initialized as follows:

Homey.begin(“AnimLED-C414”);  
Homey.setClass(“light”);

Homey.addCapability(“onoff”, setStateCallback);  
Homey.addCapability(“dim”, IntensityCallback);  
Homey.addCapability(“light\_hue”, HueCallback);  
Homey.addCapability(“light\_saturation”, SaturationCallback);

Homey.addCondition(“state”, getStateCallback);

I can get “dim”, “light\_hue” and “light\_saturation” to work if I spend som 10 seconds calling Homey.loop() and then sync, how ever “onoff” does not work. It would be kind of nice if I can get it to work and without the 10 sec delay.

Any solutions are welcome!

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [November 8, 2021, 8:18am UTC](https://community.homey.app/t/homey-and-arduino/54464/2 "2021-11-08T08:18:25Z")

</div>

> [@Mikael\_Sandberg](#):
>
> how ever “onoff” does not work.

Perhaps this works:

```auto
Homey.setCapabilityValue("onoff",s_state,true);
Homey.setCapabilityValue("onoff",s_state);
Homey.setCapabilityValue("dim",s_intensity, true);
Homey.setCapabilityValue("dim",s_intensity);
Homey.setCapabilityValue("light_hue",s_hue, true);
Homey.setCapabilityValue("light_hue",s_hue);
Homey.setCapabilityValue("light_saturation",s_saturation, true);
Homey.setCapabilityValue("light_saturation",s_saturation);

```

Which, from the source, seems to be equivalent to:

```auto
Homey.emit("onoff", s_state);
Homey.setCapabilityValue("onoff", s_state);
Homey.emit("dim", s_intensity);
Homey.setCapabilityValue("dim", s_intensity);
Homey.emit("light_hue", s_hue);
Homey.setCapabilityValue("light_hue", s_hue);
Homey.emit("light_saturation", s_saturation);
Homey.setCapabilityValue("light_saturation", s_saturation);

```

---

<div class="post-metadata">

**Author:** ![Johnny\_Sjoo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johnny_sjoo/32/76031_2.png) [@Johnny\_Sjoo](https://community.homey.app/u/Johnny_Sjoo)\
**Post date:** [May 7, 2023, 11:46am UTC](https://community.homey.app/t/homey-and-arduino/54464/3 "2023-05-07T11:46:02Z")

</div>

Hi,  
How did you get it to work? I have the same device but it refuses to connect to the HomeyDuino app. It cant be discovered and it does not work if I put in the IP adress manually.  
I have a WIFI connection with the WiFiNiNA library and i’m currently printing the IP on a display. I also see it among the WIFI devices in the router, so it feels like it’s not a problem with the actual connection.

I’m then running Homey.begin(“xxx”); and also Homey.loop(); in the loop method. But I still can not connect it to homey.

Do you have any tips and tricks?

---

<div class="post-metadata">

**Author:** ![Joepenzo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/joepenzo/32/55879_2.png) [@Joepenzo](https://community.homey.app/u/Joepenzo)\
**Post date:** [December 8, 2023, 7:27pm UTC](https://community.homey.app/t/homey-and-arduino/54464/4 "2023-12-08T19:27:26Z")

</div>

Hi!

Did you get it working?  
My MKR1010 won’t connect either, so I hope you can point me in the right direction 🙃.
