find parent [solution found]
Troubleshooting
6
Posts
3
Posters
2.8k
Views
2
Watching
-
Hi all,
i just built a motion, lux and dimmer sensor. The sketch is working perfeclty on a UNO+breadboard but does not seem to work on a pro mini+hardwired, i check the wiring already twice...
The error i get in serial consol is:" find parent"
what could be the trigger for this?
thanks -
this is my sketch:
#include <SPI.h> #include <MySensor.h> #include <BH1750.h> #include <Wire.h> #define NODE_ID 136 unsigned long SLEEP_TIME = 10000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway) #define LED_PIN 5 // Arduino pin attached to MOSFET Gate pin #define FADE_DELAY 25 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim) #define PIR_ID 0 // Id of the sensor child #define DIM_ID 1 // Id of the sensor child #define CHILD_ID_LIGHT 2 boolean lasttripped = false; BH1750 lightSensor; MySensor gw; MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL); // MyMessage msg(CHILD_ID_LIGHT, V_LEVEL); uint16_t lastlux; MyMessage pirMsg(PIR_ID, V_TRIPPED); // Initialize Dimmer static int currentLevel = 0; // Current dim level... MyMessage dimmerMsg(DIM_ID, V_DIMMER); MyMessage lightMsg(DIM_ID, V_LIGHT); void setup() { gw.begin(incomingMessage, NODE_ID, false); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("PIR & DIM & LUX", "1.0"); // Register all sensors to gateway (they will be created as child devices) gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); gw.present(DIM_ID, S_DIMMER ); gw.request(DIM_ID, V_DIMMER ); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input // Register all sensors to gw (they will be created as child devices) gw.present(PIR_ID, S_MOTION); lightSensor.begin(); } void loop() { gw.process(); boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; if (lasttripped != tripped) { lasttripped = tripped; Serial.print("PIR "); Serial.println(tripped); gw.send(pirMsg.set(tripped?"1":"0")); // Send tripped value to gw } uint16_t lux = lightSensor.readLightLevel();// Get Lux value if ((round(lux/25))*25 != lastlux) { Serial.print("LUX "); Serial.println(lux); gw.send(msg.set(lux)); lastlux = (round(lux/25))*25; } } void incomingMessage(const MyMessage &message) { if (message.type == V_LIGHT || message.type == V_DIMMER) { // Retrieve the power or dim level from the incoming request message int requestedLevel = atoi( message.data ); // Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on] requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 ); // Clip incoming level to valid range of 0 to 100 requestedLevel = requestedLevel > 100 ? 100 : requestedLevel; requestedLevel = requestedLevel < 0 ? 0 : requestedLevel; Serial.print( "Changing level to " ); Serial.print( requestedLevel ); Serial.print( ", from " ); Serial.println( currentLevel ); fadeToLevel( requestedLevel ); // Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value... gw.send(lightMsg.set(currentLevel > 0 ? 1 : 0)); // hek comment: Is this really nessesary? gw.send( dimmerMsg.set(currentLevel) ); } } /*** * This method provides a graceful fade up/down effect */ void fadeToLevel( int toLevel ) { int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1; while ( currentLevel != toLevel ) { currentLevel += delta; analogWrite( LED_PIN, (int)(currentLevel / 100. * 255) ); delay( FADE_DELAY ); } } -
found it, it was a not stable 3.3V for the radio... :( added a cap now everything works!
topic can be closed@jeti said:
found it, it was a not stable 3.3V for the radio... :( added a cap now everything works!
topic can be closedThanks...you pushed me in the right direction! Same issue with the same solution here!