@jeti said:
found it, it was a not stable 3.3V for the radio... added a cap now everything works!
topic can be closed
Thanks...you pushed me in the right direction! Same issue with the same solution here!
@jeti said:
found it, it was a not stable 3.3V for the radio... added a cap now everything works!
topic can be closed
Thanks...you pushed me in the right direction! Same issue with the same solution here!
@TD22057
Hi I use a relay breakoutboard with optocoupler. I think it is the Radio where I have to add a capacitor. Ist only sometime now an when I can see that the strange behaviour occurs, when a sensor tries to send a message to the GW and received an error.
I think this will be the solution so I close here.
@sundberg84 said:
I have experienced this and it helped me to drav 5v direct from the power source and no through the arduino (Yes, this is hard to do if you have connected usb to a nano). Maybe you can break out the power to a board and try?
I will try. When i am ready with coding and begin soldering, I will use an Pro Mini and so it is no Problem.
Hi,
No its no subset, i have just not finished because of the situation. Where do you expect capacitors (at the moment there aren't any). The Arduino Nano is powerd via ist USB Connection the sensor (DHT11) via the 5V PIN of the Arduino.
In the meantime I did a bit try an error and used PIN2 instead PIN5 for my second relay. No everything seems ok, but I don't think that this the solution, just a workaround.
Is there a known issue with triggering Special PINs when doing an gw.send ?
Hi,
I am coding a sketch for a MySensor-Sensorboard with a few sensors like temperature etc and two relays. I had Problems with the sketches I found, so I tried myself (unfinished).
No problem with the relays, they did what they should. But after adding the first sensor the problem began. At the Point in the code where I want to send the value of the sensor to the Gateway with "gw.send..." my relay (mostly the second one on Pin5, seldom the first on Pin4) powers up and back down. It sounds like the powering after a reset.
I have everything on a breadboard on a Arduino Nano powered over USB. I use Version 1.5 of MySensors.
Is there someone, who knows this Problem?
The message in the Monitor when the sensor send is:
send: 111-111-0-0 s=8,c=1,t=0,pt=7,l=5,sg=0,st=ok:20.0
The Code:
#include <MySensor.h>
#include <SPI.h>
#include <DHT.h>
#define Relay1 1 //Variables for all Sensors for presenting to GW
#define Relay2 2
#define LED 3
#define Piezo 4
#define Motion 5
#define Button1 6
#define Button2 7
#define DHT_temp 8
#define DHT_hum 9
#define Brightness 10
#define Relay1_PIN 4 //Pins for the sensors, actuator and triggers
#define Relay2_PIN 5
#define LED_PIN 9
#define Piezo_PIN 10
#define Motion_PIN 3
#define Button1_PIN 7
#define Button2_PIN 8
#define DHT_PIN 6
#define brightness_PIN A0
MyMessage Meldung_temp(DHT_temp,V_TEMP); //Testmessage for Troubleshooting
MyMessage msg11(DHT_temp,V_TEMP); //Sensormessages
MyMessage msg12(DHT_hum,V_HUM);
MyMessage msg13(Brightness,V_LIGHT_LEVEL);
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
unsigned long previousMillis = 0; // last time update
long interval = 15000; //Intervall for processing the sensors all x (default 60000) milliseconds
MySensor gw;
DHT dht;
void setup()
{
// Initialize library and add callback for incoming messages
gw.begin(incomingMessage, 111, true);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Relay Eigener Entwurf", "0.4");
//-----------Present Sensors, Triggers, Actuators -----------------
gw.present(Relay1, S_LIGHT);
pinMode (Relay1_PIN, OUTPUT); // Then set relay pins in output mode
digitalWrite(Relay1_PIN, gw.loadState(Relay1)?RELAY_ON:RELAY_OFF); // Set relay to last known state (using eeprom storage)
gw.present(Relay2, S_LIGHT);
pinMode (Relay2_PIN, OUTPUT); // Then set relay pins in output mode
digitalWrite(Relay2_PIN, gw.loadState(Relay2)?RELAY_ON:RELAY_OFF); // Set relay to last known state (using eeprom storage)
gw.present(DHT_temp, S_TEMP);
gw.present(DHT_hum, S_HUM);
pinMode(DHT_PIN, INPUT);
gw.present(Brightness, S_LIGHT_LEVEL);
pinMode(brightness_PIN, INPUT);
dht.setup(DHT_PIN);
}
void loop()
{
unsigned long currentMillis = millis();
// Alway process incoming messages whenever possible
gw.process();
delay(dht.getMinimumSamplingPeriod());
if(currentMillis - previousMillis > interval)
{
previousMillis = currentMillis;
Serial.print("Es sind: ");Serial.print(currentMillis);Serial.println(" Millisekunden vergangen!");
float DHT_temp_Read = dht.getTemperature();
if (isnan (DHT_temp_Read))
{
Serial.println("Failed reading temperatur from DHT");
}
else
{
gw.send(Meldung_temp.set(DHT_temp_Read,1));
Serial.print("T: "); Serial.println(DHT_temp_Read);
}
}
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT)
{
int actPin;
if (message.sensor == 1){ actPin = Relay1_PIN;}
if (message.sensor == 2){ actPin = Relay2_PIN;}
if (message.sensor == 3){ actPin = LED_PIN;}
if (message.sensor == 4){ actPin = Piezo_PIN;}
if (message.sensor == 8){ actPin = 55;}
// Change relay state
digitalWrite(actPin, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
Thanks in advance and regards,
Thorsten