# Homeyduino - no sensor values

**URL:** <https://community.homey.app/t/homeyduino-no-sensor-values/47499>\
**Category:** Questions & Help\
**Tags:** app\
**Created:** [May 17, 2021, 8:50pm UTC](https://community.homey.app/t/homeyduino-no-sensor-values/47499 "2021-05-17T20:50:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuboxMC](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/juboxmc/32/12404_2.png) [@JuboxMC](https://community.homey.app/u/JuboxMC)\
**Post date:** [May 17, 2021, 8:50pm UTC](https://community.homey.app/t/homeyduino-no-sensor-values/47499/1 "2021-05-17T20:50:39Z")

</div>

Hello there

I’ve made a project to measure the water niveau in my rain well. I’m using an arduino but I can’t get the niveau of the water in my homey. Here is my code:

```
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Homey.h>

#define echoPin D7 // Echo Pin
#define trigPin D6 // Trigger Pin

const char* ssid = ******* ;
const char* password = ************ ;
const char* name = "Waterput";
long duration, distance; // Duration used to calculate distance
int water = 0;
unsigned long previousMillis = 0;

void setup()
{

Serial.println("Starting ethernet..."); //If this is the last message you see appear in the serial monitor...
WiFi.begin(ssid, password);

Serial.print("IP address: ");
Serial.println(WiFi.localIP());

Serial.begin (9600);

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

Homey.begin(name);
Homey.setClass("sensor");
Homey.addCapability("niveau");
}

 
void loop()
{
Homey.loop();

unsigned long currentMillis = millis();

if (currentMillis-previousMillis >= 1000) { //Code in this if statement is run once every second
  previousMillis = currentMillis;

  /* The following trigPin/echoPin cycle is used to determine the
  distance of the nearest object by bouncing soundwaves off of it. */
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  
  //Calculate the distance (in mm) based on the speed of sound.
  distance = duration * 0.34/2;
  water = (1650 - distance) * 3.03;

  updateSensor();
  
}
}

void updateSensor() {
  Serial.println(water);
  Homey.setCapabilityValue("niveau", water);
}

```

Thanks in advance

Greetings  
Maarten

---

<div class="post-metadata">

**Author:** ![rindler](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rindler/32/5501_2.png) [@rindler](https://community.homey.app/u/rindler)\
**Post date:** [May 18, 2021, 3:19am UTC](https://community.homey.app/t/homeyduino-no-sensor-values/47499/2 "2021-05-18T03:19:35Z")

</div>

Cool project! I think you need to use one of the standard capabilities, see [Homey Developer Tools](https://tools.developer.homey.app/docs/apps-reference) if you have the app store version of Homeyduino, so you cannot use `nivaeu`.

If you want to use custom capabilities you have to add them to app.json and CLI install [GitHub - athombv/com.athom.homeyduino: Homeyduino is an Homey app which allows you to easily connect your own Arduino projects to homey](https://github.com/athombv/com.athom.homeyduino).

Good luck!

---

<div class="post-metadata">

**Author:** ![JuboxMC](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/juboxmc/32/12404_2.png) [@JuboxMC](https://community.homey.app/u/JuboxMC)\
**Post date:** [May 18, 2021, 5:51am UTC](https://community.homey.app/t/homeyduino-no-sensor-values/47499/3 "2021-05-18T05:51:41Z")

</div>

Thank you, it works now!
