IT WORKS, thank you very much!
One thing, the interrupt (motion) status is only sent when the other data (temp hum) is being send. So once a minute it jumps from "on" to "off" in stead of every time the Sensor goes HI/LO.
Is there a way to fix that?
Thanks again, you are a HERO
xypzo
@xypzo
Best posts made by xypzo
Latest posts made by xypzo
- 
    RE: Combine several scetches to 1 nodeposted in Development
- 
    Combine several scetches to 1 nodeposted in DevelopmentHi 
 I am having trouble combining multiple scetches into one node since the last mysensors library update.
 I have combined the DHT and RELAY scetches and they work great. I just want to add an interrupt sensor (door, motion, whatever) to pin 3.
 I think the problem is the sleep function. it is different in all 3 scetches, i am an absolute NOOB with programming, but simply cut/paste is not working anymore.Can somebody please be of any assistance? You would save the day! thanks! #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_REPEATER_FEATURE #include <SPI.h> #include <MySensors.h> #include <DHT.h> static const uint64_t UPDATE_INTERVAL = 60000; static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 3 #define CHILD_ID_TEMP 4 #define DHT_DATA_PIN 8 #define SENSOR_TEMP_OFFSET 0 #define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 2 // Total number of attached relays #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 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; void before() { for (int sensor = 1, pin = RELAY_PIN; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) { // Then set relay pins in output mode pinMode(pin, OUTPUT); // Set relay to last known state (using eeprom storage) digitalWrite(pin, loadState(sensor) ? RELAY_ON : RELAY_OFF); } } void presentation() { // Send the sketch version information to the gateway sendSketchInfo("DHT & Relays", "2.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); for (int sensor = 1, pin = RELAY_PIN; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); metric = getControllerConfig().isMetric; } } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; // apply the offset before converting to something different than Celsius degrees temperature += SENSOR_TEMP_OFFSET; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.type == V_STATUS) { // Change relay state digitalWrite(message.sensor - 1 + RELAY_PIN, message.getBool() ? RELAY_ON : RELAY_OFF); // Store state in eeprom 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()); } }
- 
    RE: RGB LED stripposted in My Projectwhat DID happen the day before, was that when i added more WHITE, at around 60% white the whole unit stopped responding to any inputs, it would just freeze in that color, until i removed the 12v power supply. Also strange!  
- 
    RE: RGB LED stripposted in My Project@maghac The stupid thing, is that the day before, same setup, no red lights stayed on. It happened overnight!!! Maybe the mice did it! :') 
- 
    RE: RGB LED stripposted in My Project@maghac said in RGB LED strip: your connections, perhaps you're connecting to the wrong pin on the arduino Then green keeps on, so it should be a pin 6 problem, but i can't find it. Maybe I try a 10kohm resistor between gate and ground... Or IRFZ instead of IRLZ transistors. BTW, bought a LD362A ufo which works great with my controller, but i still want to win this battle! 
- 
    RE: RGB LED stripposted in My ProjectI dont know what went wrong, but RED is just always on. Yesterday in the breadboard it was ok. Today in the breadboard red was on. So i thought lets just solder it... Now I soldered it to a pcb, RED on all the time. This must be a ground issue, but where do i look? It is even red when just all the connections are off, 12v to raw and strip, then connect ground to arduino, BOOM red comes on... 
- 
    RE: 💬 Parking Sensorposted in AnnouncementsHey David, 
 Could you share the working code (with the SHARP sensor integrated) with us?
- 
    RE: 💬 Power Meter Pulse Sensorposted in AnnouncementsFhem tells me this all the time: 
 MYSENSORS: ignoring presentation-msg from unknown radioId 0, childId 255, sensorType 18
- 
    RE: 💬 Power Meter Pulse Sensorposted in AnnouncementsHey guys, I have a strange problem using excact this scetch and the new 2.0 serial gateway scetch using FHEM. 
 I do get KWH values, but no Power values, and sometimes all of a sudden it gives me a power value, like twice a day.
 It didn't do that before and I am a complete copy-pase N00B, so maybe somebody already sovled this issue? HELP
- 
    RE: Help with scetch relaywithbuttonposted in TroubleshootingWow, thank you so much, it works like a charm!