- Posts: 2
- Thank you received: 0
Please Log in or Create an account to join the conversation.
Vellur wrote: Hi.
First of all thank you for this amazing website!
I have couple of questions what i couldnt figure out. How I can add second relay module to exiting node. Code says: Arduino Digital I/O pin number for first relay (second on pin+1 etc), but i cant get it to work. no errors, just I cant see it from the web.
Another question: What DHT library you use with temperature/humidity sensor. I have DHT11 device and I just get errors when I try to compile. I use adafruit's but I think its wrong one. Error: 'DHT' does not name a type. I try to use your example.
I hope you can help me. I think I just have missed something out...
Br.
Vellu
/*
V1.0 - first version
V1.1 - adopt to new library
Created by Igor Jarc <igor.jarc1@gmail.com>
See http://iot-playground.com for details
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
#include <Esp8266EasyIoT.h>
#include <SoftwareSerial.h>
Esp8266EasyIoT esp;
SoftwareSerial serialEsp(10, 11);
#define RELAY_1 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
void setup()
{
serialEsp.begin(9600);
Serial.begin(115200);
Serial.println("EasyIoTEsp init");
esp.begin(incomingMessage, 3, &serialEsp, &Serial);
//esp.begin(incomingMessage, 3, &serialEsp);
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_1 + 1, OUTPUT);
esp.present(1, S_DIGITAL_OUTPUT);
esp.present(2, S_DIGITAL_OUTPUT);
}
void loop()
{
esp.process();
}
void incomingMessage(const Esp8266EasyIoTMsg &message) {
// We only expect one type of message from controller. But we better check anyway.
Serial.println("New message");
if (message.type==V_DIGITAL_VALUE) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
Please Log in or Create an account to join the conversation.