Skip to content

Troubleshooting

Help! Everything just falls apart
2.7k Topics 21.5k Posts
  • Node / sketch with Dallas and Relay starts behaving weird after one day

    5
    0 Votes
    5 Posts
    1k Views
    karl261K
    How would you do this?Like this? I tried to move it to the setup function. This is also a version I found using non blocking (millis()) code. // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool. //#define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 // A 2.4Ghz transmitter and receiver, often used with MySensors. // #define MY_RF24_PA_LEVEL RF24_PA_MIN // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio. // #define MY_RADIO_RFM69 // 433Mhz transmitter and reveiver. // Choose if you want this sensor to also be a repeater. // #define MY_REPEATER_FEATURE // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this. // Are you using this sensor on battery power? // #define BATTERY_POWERED // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater! //#define MY_RF24_PA_LEVEL RF24_PA_LOW #define MY_PARENT_NODE_ID 99 #define MY_PARENT_NODE_IS_STATIC #define MY_NODE_ID 8 #define MY_BAUD_RATE 9600 // LIBRARIES (in the Arduino IDE go to Sketch -> Include Library -> Manage Libraries to add these if you don't have them installed yet.) #include <SPI.h> #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #define RELAY_1 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define NUMBER_OF_RELAYS 1 // 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 //Added this nteger to avoid stupid collect2.exe: error: ld returned 5 exit status. //It seems adding one or removing one (or plenty) solves the error. //int stupidinteger=0; //int stupidintegertwo=0; //int stupidintegerthree=0; // VARIABLES YOU CAN CHANGE #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No. Can save battery. #define ONE_WIRE_BUS 7 // Digital pin where Dallas sensor(s) is/are connected. #define maxAttachedDS18B20 16 // Maximum amount of teperature sensors you can connect to this arduino (16). const long measurementInterval = 10000; // Time to wait between reads (in milliseconds). float tempThreshold = 0.1; // How big a temperature difference has to be before an update is sent. Makes the sensor less precise, but also less jittery, and can save battery. //VARIABLES YOU PROBABLY SHOULDN'T CHANGE #define TEMP_CHILD_ID 0 // for MySensors. Within this node each sensortype should have its own ID number. OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperature[maxAttachedDS18B20]; // creates an array to hold the previous temperature measurements for each possible sensor. int numSensors = 0; // variable to contain the number of found attached sensors. unsigned long measurementSleepTime = 0; // variable to store the calculated Sleep time if the node is battery powered. bool metric = true; // Variable that stores if the sensor will output the temperature in Fahrenheit of Celsius. The gateway sends this preference to the node. bool receivedConfig = false; // This is not used in the code, but perhaps MySensors requires this? // Mysensors settings MyMessage msg(TEMP_CHILD_ID,V_TEMP); // Sets up the message format that we'l be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect. void before() { sensors.begin(); // Startup up the OneWire library. It allows multiple sensors to talk over one wire (one pin). for (int sensor=1, pin=RELAY_1; 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 setup() { metric = getControllerConfig().isMetric; for(int i=0; i<maxAttachedDS18B20; i++) { lastTemperature[i] = 0; //Pre-filling array with 0's. } sensors.setWaitForConversion(false); // requestTemperatures() will not block current thread #ifdef BATTERY_POWERED // If the node is batter ypowered, we'll let Sleep take over the scheduling. measurementSleepTime = measurementInterval; measurementInterval = 0; // When the Arduino is asleep, millis doesn't increment anymore (time stops as it were). To fix this, we'll set the measurement interval time to 1, so that when the arduino wakes up it will immediately try to measure again. #endif //Serial.begin(115200); // for serial debugging. //Serial.println("Hello world, I am a sensor node."); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Maischen relay and Dallas non blocking", "1.0"); for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) { // Register all sensors to gw (they will be created as child devices) present(sensor, S_BINARY); } numSensors = sensors.getDeviceCount(); // Fetch the number of attached temperature sensors for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++) { present(i, S_TEMP); } } void loop() { // You should not change these variables: static boolean dallasIsMeasuring = true; // Used to indicate when the time is right for a new measurement to be made. static boolean dallasIsCalculating = false; // Used to bridge the time that is needed to calculate the temperature values by the Dallas library. unsigned long currentMillis = 0; // The millisecond clock in the main loop. static unsigned long previousMeasurementMillis = 0; // Used to remember the time of the last temperature measurement. static int16_t conversionTime = 0; // Used to store the time needed to calculate the temperature from measurements. currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater. // Let's measure the temperature if(dallasIsMeasuring == true && currentMillis - previousMeasurementMillis >= measurementInterval) { // If we're not calculating, and enough time has passed, we'll start again. dallasIsMeasuring = false; // We're measuring, so let's take it off our to-do list. //Serial.println("Starting new measurement(s)"); previousMeasurementMillis = currentMillis; // Mark the time of the initialiation of this measurement. // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time. Apparently it takes a while to calculate. //conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); conversionTime = millisToWaitForConversion(sensors.getResolution()); // This is a modified version of the line above, to deal with the problem in the current Dallas library. dallasIsCalculating = true; //Next step is to re-calculate the temperature again. } // Next, let's calculate and send the temperature if(dallasIsCalculating == true && currentMillis - conversionTime > previousMeasurementMillis) { dallasIsCalculating = false; // We're doing this now, so check calculating off the to-do list too. for (int i=0; i<numSensors && i<maxAttachedDS18B20; i++){ // Loop through all the attached temperature sensors. //float temperature = getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i); // Fetch the temperature form the current sensor float temperature = static_cast<float>(static_cast<int>((metric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; //Serial.print("Sensor #"); //Serial.print(i); //Serial.print(" says it is "); //Serial.print(temperature); //Serial.println(" degrees"); if(temperature != -127.00 && temperature != 85.00) { // Avoids working with measurement errors. if (COMPARE_TEMP == 1 && abs(temperature - lastTemperature[i]) < tempThreshold) { // is the temperature difference bigger than the threshold? //Serial.print(temperature - lastTemperature[i]); //Serial.print("- difference too small, so not sending the new measurement to the gateway.\n"); } else { //Serial.print(temperature - lastTemperature[i]); //Serial.print("Sending the new temperature to the gateway.\n"); send(msg.setSensor(i).set(temperature,1)); lastTemperature[i] = temperature; // Save new temperatures to be able to compare in the next round. } } } // Both tasks are done. Time to wait until we should measure again. //Serial.print("zzzzZZZZzzzzZZZZzzzz\n"); #ifdef BATTERY_POWERED unsigned long quicktimecheck = millis(); // check how much time has passed during the measurement (can be up to 750 milliseconds), and then calculate from that how long to sleep until the next intended measuring time. unsigned long sleeptime = measurementSleepTime - (quicktimecheck - previousMeasurementMillis); //How much time has passed already during the calculating? Subtract that from the intended interval time. sleep (sleeptime); #endif dallasIsMeasuring = true; } } // This function helps to avoid a problem with the latest Dallas temperature library. int16_t millisToWaitForConversion(uint8_t bitResolution) { switch (bitResolution) { case 9: return 94; case 10: return 188; case 11: return 375; default: return 750; } } 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_1, 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()); } }
  • Dallas18B20 begin causes reset [solved]

    4
    0 Votes
    4 Posts
    1k Views
    mfalkviddM
    Thanks @robosensor I decided to re-do all wiring to make a clear photo. When I did that I realized that I had connected GND on the DS18B20 to the reset pin on the Pro Mini. No wonder the mcu was reset when communication occurred on the onewire bus.
  • No Battery Level from RFM69 Nodes

    4
    0 Votes
    4 Posts
    952 Views
    nagelcN
    Switched to Version 2.2 and now it works. Thanks.
  • [SOLVED] Sensebender Micro Baud Rate Issue.

    13
    0 Votes
    13 Posts
    2k Views
    R
    Thanks for the explanation. Makes perfect sense. In the past if there was a processor mismatch the programs would not download.
  • HC-SR04 (Distance) only sends data with connected serial converter?

    3
    0 Votes
    3 Posts
    924 Views
    edsteveE
    Thanks for your reply. I was dealing with it for 3 hours now. Grml. But as usual i figured it out right after this post. The trigger pin was connected to the wrong Arduino pin (4 instead of 6). Of course i didin't check it, because it still worked with connected serial converter. How strange. So i guess this post can be deleted due to waste of space. Cheeers ED
  • [SOLVED] ESP8266 Inclusion Issue

    4
    0 Votes
    4 Posts
    963 Views
    R
    Let me start by saying I made some incorrect assumptions. If you look I assigned an IP address to the device and to the MY_CONTROLLER_IP_ADDRESS which I thought was necessary so it could find my Vera. It talks about the fact that by assigning an IP address to it it changed it from Server to Client mode which I couldn't find much info on. You have to know I'm a hardware guy. I know just enough software to be dangerous. I think it was this change that kept it from working. The way I had it configured wireshark showed the ESP8266 only sent out one packet after being powered up, after that nothing. I was able to telnet to it on port 5003 but basically got nothing. After commenting out the MY_CONTOLLER_IP_ADDRESS when I telneted to it I saw a stream of sensor data. It seems a bit counterintuitive but in this mode it looks like my Vera was connecting to the GW and watching the data stream. That's a WAG on my part but it seems logical at this point. Now I hope someone can give me some help on my Senesebender Micro issue.
  • Can't change Node ID

    6
    0 Votes
    6 Posts
    2k Views
    N
    Thanks, that worked.
  • Serial GW on RaspberryPI 3 doesn't start

    9
    0 Votes
    9 Posts
    2k Views
    wimdW
    I got a similar issue. Installed 2.2.0 beta and the gateway worked fine for some hours and then it stopped. When I check the gateway function with : sudo ./bin/mysgw -d I only get these messages : pi@raspberrypi:~/MySensors $ sudo ./bin/mysgw -d mysgw: Starting gateway... mysgw: Protocol version - 2.2.0-rc.1 mysgw: MCO:BGN:INIT GW,CP=RNNGL-Q-,VER=2.2.0-rc.1 mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0
  • Unable to send message from gw to sensor(!TSF:MSG:SEND)

    5
    1 Votes
    5 Posts
    3k Views
    mfalkviddM
    I've updated the example. Hopefully it is more clear now.
  • RPi3 Gateway and Uno R3 node cannot communicate

    7
    0 Votes
    7 Posts
    1k Views
    mfalkviddM
    @Huỳnh-Minh-Khải great work. Thanks for reporting back!
  • Mega 2560 as Serial Gateway

    5
    0 Votes
    5 Posts
    2k Views
    M
    Hi, I found the failure. I haven't seen the Pin changeing to : #define MY_RF24_CE_PIN 49 #define MY_RF24_CS_PIN 53 Now, the debug looks good. Thank U!
  • GatewayESP8266 Compile problem.

    3
    0 Votes
    3 Posts
    1k Views
    R
    Thanks that seems to have worked. This is what is needed. In the file MyGatewayTransportEthernet.cpp around line 301 the following changes need to be made. All the [0]'s need to be removed. Old: #if defined(MY_GATEWAY_ESP8266) _ethernetServer.read(inputString[0].string, MY_GATEWAY_MAX_RECEIVE_LENGTH); inputString[0].string[packet_size] = 0; debug(PSTR("UDP packet received: %s\n"), inputString[0].string); const bool ok = protocolParse(_ethernetMsg, inputString[0].string); #else New: #if defined(MY_GATEWAY_ESP8266) _ethernetServer.read(inputString.string, MY_GATEWAY_MAX_RECEIVE_LENGTH); inputString.string[packet_size] = 0; debug(PSTR("UDP packet received: %s\n"), inputString.string); const bool ok = protocolParse(_ethernetMsg, inputString.string); #else
  • Resolved - 18650 battery powered temperature sensors

    14
    0 Votes
    14 Posts
    4k Views
    gohanG
    Yes, but there could be also other combinations that will allow you to detect higher voltage but with an higher total resistance
  • Relay control - bistable switch instead of monostable.

    8
    0 Votes
    8 Posts
    3k Views
    PlantexP
    Thank You. Works perfect and reporting to Domoticz/Imperi Home.
  • "loosing" sensors over time

    9
    0 Votes
    9 Posts
    2k Views
    gohanG
    I got those modules from cdebyte and I am very happy
  • EasyPCB and RFM69 Issues

    15
    0 Votes
    15 Posts
    3k Views
    sundberg84S
    @Ryanmt - so, do I understand you correctly? Exactly the same hardware/hardware-setup (incl antenna) & software works on the breadboard with that gateway - but when you solder them to the PCB it stops working? If so there are these options: You have made some soldering mistake (created a short.) (The solder-job looks really good on the images though...) The PCB you are using has some sort of manufacturing error. The antenna (length) needs to be changed on the PCB vs the breadboard setup. I would set my multimeter into continuity and measure all lines, ie from radio -> mcu. Also measure continuity between all solder points next to each other on the radio(to make sure you dont have any shorts). Next thing would be to test different length on the antenna. You can also compare the PCB traces to the images on openhardware.io The sketch is just the example battery sketch with the RFM69 module enabled Could you also post the sketch you are using? (The standard sketch does not include the H def but i guess you added that)
  • RPi ethernet gateway doesn't send messages to the acuator

    6
    0 Votes
    6 Posts
    1k Views
    S
    It's been some time but I tried to pick up this project again, now with some fresh ordered LD1117V33 regulators for my 3.3v needs. I setup a "power supply bread bord" where the LD1117V33 has a parallel 100uF capacitor on the Vin and Vout connected to the common ground. The multimeter agrees on the 3.3v Vout, so far so good. I've tried hooking up the nrf24 chip with the bread bord on the Arduino and on the PI and the results are identical... Everything works as expected until I actively try to send something from the controller throught the gateway to my actuator. In both cases the init goes well; pi@raspberrypi:/usr/src/MySensors $ sudo /usr/local/bin/mysgw -d mysgw: Starting gateway... mysgw: Protocol version - 2.1.1 mysgw: MCO:BGN:INIT GW,CP=RNNG---,VER=2.1.1 mysgw: TSF:LRT:OK mysgw: TSM:INIT mysgw: TSF:WUR:MS=0 mysgw: TSM:INIT:TSP OK mysgw: TSM:INIT:GW MODE mysgw: TSM:READY:ID=0,PAR=0,DIS=0 mysgw: MCO:REG:NOT NEEDED mysgw: Listening for connections on 0.0.0.0:5003 mysgw: MCO:BGN:STP mysgw: MCO:BGN:INIT OK,TSP=1 I start the Arduino which starts sending data as seen on the raspberry pi gateway; mysgw: TSF:MSG:READ,1-1-255,s=255,c=3,t=7,pt=0,l=0,sg=0: mysgw: TSF:MSG:BC mysgw: TSF:MSG:FPAR REQ,ID=1 mysgw: TSF:PNG:SEND,TO=0 mysgw: TSF:CKU:OK mysgw: TSF:MSG:GWL OK mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0 mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 mysgw: TSF:MSG:PINGED,ID=1,HP=1 mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1 mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 mysgw: !TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100 mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=11,pt=0,l=22,sg=0:TemperatureAndHumidity mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.1 mysgw: TSF:MSG:READ,1-1-0,s=0,c=0,t=7,pt=0,l=0,sg=0: mysgw: TSF:MSG:READ,1-1-0,s=1,c=0,t=6,pt=0,l=0,sg=0: mysgw: TSF:MSG:READ,1-1-0,s=2,c=0,t=3,pt=0,l=0,sg=0: mysgw: TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 mysgw: TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1 mysgw: TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.0 mysgw: TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:54.0 In the above output I see multiple TSF:MSG:SEND commands passing by without issues and receive data from the Arduino as well. This leads me to the conclusion that there is no power issue on either side and bidirectional communication is established (just like before). As soon as I try to toggle a light switch in OpenHAB the following lines show in the gateway log: mysgw: !TSF:MSG:SEND,0-0-1-1,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0 mysgw: Client 0: mysgw: Client 0: 1;2;1;1;2;0 mysgw: !TSF:MSG:SEND,0-0-1-1,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0 mysgw: Client 0: mysgw: Client 0: 1;2;1;1;2;0 mysgw: !TSF:MSG:SEND,0-0-1-1,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0 mysgw: Client 0: mysgw: Client 0: 1;2;1;1;2;0 mysgw: !TSF:MSG:SEND,0-0-1-1,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0 mysgw: Client 0: mysgw: Client 0: 1;2;1;1;2;0 mysgw: !TSF:MSG:SEND,0-0-1-1,s=2,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=NACK:0 mysgw: Client 0:
  • ESP gateway flashed but it doesn't start

    10
    0 Votes
    10 Posts
    2k Views
    M
    @sundberg84 sure, unstable or noisy or insufficient power causes all kinds of problems, not just to esp8266 but to any device, and it should be the first check to run when things don't work correctly.
  • Connect NodeMCU to its own created network

    4
    0 Votes
    4 Posts
    776 Views
    mfalkviddM
    @sabiha-patan it is always connected to its own created network. There is no way to disconnect.
  • Esp8266Gateway compiling problem

    3
    0 Votes
    3 Posts
    1k Views
    F
    ok, thanks...

21

Online

11.7k

Users

11.2k

Topics

113.1k

Posts