Forum: Mikrocontroller und Digitale Elektronik Arduino Nano stürzt ab ohne Serial Monitor


von filth (Gast)


Lesenswert?

Hallo,

ich habe ein Problem mit meinem Projekt:

An einem Arduino Nano habe ich den DHT22 Sensor und versende die Werte 
über die RF24Networking lib.

Beides funktioniert an sich, aber ich habe folgendes seltsames 
Verhalten: wenn kein Serial Monitor aus der Arduino GUI an ist, stürzt 
das Programm auf dem Arduino scheinbar ab - ich kann es an einem Zähler 
nachverfolgen, der zurückgesetzt wird.

Ist der Serial Monitor an, funktioniert alles tadellos. Womit könnte das 
zusammenhängen?

Danke

von kalle (Gast)


Lesenswert?

...vielleicht ein Flankenwechsel des DTR-Signals der VirtualCOM? Das 
geht doch an den RESET vom Arduino nano....

von filth (Gast)


Lesenswert?

Wäre es dann nicht genau andersrum: mit Serial Monitor instabil und ohne 
stabil? Bei mir ist es ja so, dass ohne Serial Monitor der Sketch 
abstürzt (nach einigen Durchläufen)

von Ulrich F. (Gast)


Lesenswert?

Kann schon sein, dass Windows an den Leitungen zappelt, wenn kein 
Prozess den COM Port belegt.

von Thomas E. (thomase)


Lesenswert?

filth schrieb:
> Wäre es dann nicht genau andersrum: mit Serial Monitor instabil und ohne
> stabil? Bei mir ist es ja so, dass ohne Serial Monitor der Sketch
> abstürzt (nach einigen Durchläufen)
Nicht wenn dein Arduino eine Rückmeldung vom Monitor erwartet. Dann wird 
er vielleicht sauer, wenn er sie nicht bekommt und geht mit einem 
Timeout in Reset oder bleibt irgendwo hängen. Kann man das nicht 
abschalten?

mfg.

von filth (Gast)


Lesenswert?

Vom sketch her erwartet er eigentlich nichts vom Serial:
1
#include <RF24Network.h>
2
#include <RF24.h>
3
#include <SPI.h>
4
#include <dht.h>
5
#include "MyTypes.h"
6
#include <Narcoleptic.h>
7
8
#define DHTPIN 3     // what pin we're connected to
9
#define DHTTYPE DHT22   // DHT 22  (AM2302)
10
11
DHT dht(DHTPIN, DHTTYPE);
12
13
// nRF24L01(+) radio attached 
14
RF24 radio(9,10);
15
16
// Network uses that radio
17
RF24Network network(radio);
18
19
// Address of our node
20
const uint16_t this_node = 1;
21
22
// Address of the other node (by default send it to the base)
23
const uint16_t other_node = 0;
24
25
// How often to send 'hello world to the other unit
26
unsigned long interval = 5000; //ms
27
28
// When did we last send?
29
unsigned long last_sent;
30
31
// How many have we sent already
32
unsigned long packets_sent;
33
34
payload_t myData;
35
36
// Number of packets we've failed to send since we last sent one
37
// successfully
38
uint16_t lost_packets = 0;
39
40
void setup(void)
41
{
42
  Serial.begin(57600);
43
  Serial.println("RF24Network/examples/helloworld_tx/");
44
 
45
  SPI.begin();
46
  radio.begin();
47
  network.begin(/*channel*/ 90, /*node address*/ this_node);
48
  dht.begin();
49
      
50
  RF24NetworkHeader header(network.parent(), 'k');
51
  Serial.print("APP Sending type: k to node:");
52
  Serial.println(header.to_node);
53
  if ( ! network.write(header, NULL, 0) )
54
     Serial.println("failed.");
55
   
56
}
57
58
void loop(void)
59
{
60
  delay(1000);
61
  
62
  // Pump the network regularly
63
  network.update();
64
  
65
   // If so, grab it and print it out
66
  //  RF24NetworkHeader header;
67
  //  network.peek(header);
68
     
69
  
70
  if ( this_node > 0 )
71
  {        
72
    
73
    float h = dht.readHumidity();
74
    float t = dht.readTemperature();
75
    if (isnan(h) || isnan(t)) {
76
      Serial.println("Failed to read from DHT");
77
    } 
78
    else{
79
       myData.value = h;
80
       myData.unity[0] = '%';
81
       myData.lost_packets = lost_packets;
82
        
83
       sendData(&myData);      
84
     
85
       delay(1000);    
86
     
87
       myData.value = t;
88
       myData.unity[0] = 'C';
89
       myData.lost_packets = lost_packets;
90
        
91
       sendData(&myData);   
92
    }  
93
94
    
95
    //radio.powerDown();
96
    
97
    //radio.powerDown();    
98
  
99
  }            
100
}
101
102
boolean sendData(payload_t* data) {
103
  unsigned long now = millis();
104
  if ( now - last_sent >= interval  )
105
  {
106
    Serial.println("Sending...");
107
    last_sent = now;
108
    
109
    boolean ok = false;
110
  
111
    RF24NetworkHeader header(other_node, 'S');
112
    ok = network.write(header, &myData, sizeof(myData));
113
    if (!ok) {
114
      ++lost_packets;
115
      Serial.println("failed.");      
116
    }
117
  
118
    return ok;
119
  }
120
  
121
}

von Ulrich F. (Gast)


Lesenswert?

Und, was passiert, wenn du die USB Leitung abziehst?
Auch dann Resets?

Wieso fragst du in 2 Foren?
http://forum.arduino.cc/index.php?topic=235319.0
KA, wie das hier gehandhabt wird, aber ich mag das nicht.

von filth (Gast)


Lesenswert?

Es scheint tatsächlich an Windows zu liegen. Wird der Arduino neutral 
mit Strom versorgt, treten die Fehler nicht auf.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.