# Homeyduino weatherstation

**URL:** <https://community.homey.app/t/homeyduino-weatherstation/131879>\
**Category:** Developers\
**Created:** [March 2, 2025, 9:24am UTC](https://community.homey.app/t/homeyduino-weatherstation/131879 "2025-03-02T09:24:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascal](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/pascal/32/627_2.png) [@Pascal](https://community.homey.app/u/Pascal)\
**Post date:** [March 2, 2025, 9:24am UTC](https://community.homey.app/t/homeyduino-weatherstation/131879/1 "2025-03-02T09:24:49Z")

</div>

Good morning, I was trying to create a weatherstation with arduino using a:

- DHT22 (temperature/humidity sensor)
- Rain/Snow sensor
- NodeMcu V3 ESP-12E

This is working standalone as webserver. After testing it, i’ve tried to change my code, so I could add it to homey with the not further developed homeyduino app. But I’m receiving error:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/0/f0ca1a5367244d4e75ed785bf1fb0d6f865dd3b0.png)

This is my full arduino code:

```auto
#include <ESP8266WiFi.h>
#include <Homey.h>
#include <DHT.h>

#define DHTPIN D4
#define DHTTYPE DHT22
#define RAIN_SENSOR_PIN A0

DHT dht(DHTPIN, DHTTYPE);

const char* ssid = "changed";
const char* password = "changed";

// Statisch IP-adres instellen
IPAddress staticIP(192, 168, 2, 219);  
IPAddress gateway(192, 168, 2, 254);
IPAddress subnet(255, 255, 255, 0);

void setup() {
  Serial.begin(115200);
  dht.begin();
  pinMode(RAIN_SENSOR_PIN, INPUT);

  WiFi.begin(ssid, password);
  WiFi.config(staticIP, gateway, subnet);
  Serial.print("Verbinden met WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Verbonden!");
  Serial.println(WiFi.localIP());

  // Homeyduino setup
  Homey.begin("TempHuminRainSensor", "sensor");
  Homey.setClass("sensor");
  Homey.addCapability("measure_temperature");
  Homey.addCapability("measure_humidity");
  Homey.addCapability("measure_rain");
  Homey.addCapability("alarm_water");
}

void loop() {
  Homey.loop();

  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  int rainValue = analogRead(RAIN_SENSOR_PIN);
  
  float rainAmount = 0.0;
  bool rainAlarm = false;

  if (rainValue < 500) {
    rainAmount = 2.0; // Simuleer regenval in mm
    rainAlarm = true;
  } else if (rainValue >= 500 && rainValue <= 600) {
    rainAmount = 0.5; // Simuleer motregen
    rainAlarm = true;
  } else {
    rainAmount = 0.0; // Droog
    rainAlarm = false;
  }

  // Stuur waarden naar Homey
  Homey.setCapabilityValue("measure_temperature", temperature);
  Homey.setCapabilityValue("measure_humidity", humidity);
  Homey.setCapabilityValue("measure_rain", rainAmount);
  Homey.setCapabilityValue("alarm_water", rainAlarm);

  delay(5000); // Update elke 5 seconden
}

```

Hoping someone could point me into the right direction, so I can get it to work and continue to print a casing for it.

Thank in advance

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [March 2, 2025, 5:13pm UTC](https://community.homey.app/t/homeyduino-weatherstation/131879/2 "2025-03-02T17:13:53Z")

</div>

Please use the app’s topic

> [@\[APP\]\[PRO\] Homeyduino](https://community.homey.app/t/app-pro-homeyduino/75494):
>
> Topic for the Homeyduino App [Homeyduino App voor Homey | Homey](https://homey.app/nl-nl/app/com.athom.homeyduino/Homeyduino/)[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)
