MyController 1.2.0.Final version released
-
I replaced custom and var1 with S_DUST and V_LEVEL. but still the same issue.
The node has 2 sensors, both send name with presentation. Only one name shows, the other never seems to work, not as custom or dust.
Hmmmmm........
-
@skywatch can you post your sketch?
-
Of course I can.... here it is.....;)
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 #define MY_RF24_PA_LEVEL RF24_PA_HIGH #define MY_NODE_ID 15 #define MY_RF24_CHANNEL (97) //#define MY_REPEATER_FEATURE //#define MY_SIGNING_ATSHA204 //#define MY_SIGNING_REQUEST_SIGNATURES #include <Wire.h> #include <MySensors.h> #include <AS3935.h> // AS3935 MOD-1016 by Embedded Adventures volatile bool detected = false; //-----------------IMPORTANT-------------------- //---------------CHANGE SETTINGS HERE----------- #define IRQ_pin 2 #define AS3935_TUNE_CAPS 5 // <-- SET THIS VALUE TO THE NUMBER LISTED ON YOUR BOARD #define AS3935_INDOORS 1 // AS3935_INDOORS=1 indoors, AS3935_INDOORS=0 outdoors #define AS3935_NOISE_FLOOR 6 #define AS3935_ENABLE_DISTURBERS 1 // 0 or 1 #define CHILD_ID_DISTANCE 1 #define CHILD_ID_INTENSITY 2 MyMessage msgDist(CHILD_ID_DISTANCE, V_DISTANCE); MyMessage msgInt(CHILD_ID_INTENSITY, S_DUST); unsigned long heartbeat_time = 60000*10; //every 10 mins. unsigned long last_heartbeat_time = 0; void setup() { Serial.begin(115200); while (!Serial) {} Serial.println("MOD-1016 (AS3935) Lightning Sensor"); Serial.println("beginning boot procedure...."); Wire.begin(); mod1016.init(IRQ_pin); //-----------------IMPORTANT-------------------- //---------------CHANGE SETTINGS HERE----------- //Tune Caps, Set AFE, Set Noise Floor //autoTuneCaps(IRQ_pin); mod1016.setTuneCaps(AS3935_TUNE_CAPS); wait(2); #if AS3935_INDOORS == 1 mod1016.setIndoors(); #else mod1016.setOutdoors(); #endif wait(2); mod1016.setNoiseFloor(AS3935_NOISE_FLOOR); wait(2); #if AS3935_ENABLE_DISTURBERS == 1 mod1016.enableDisturbers(); #else mod1016.disableDisturbers(); #endif //mod1016.calibrateRCO(); wait(2); Serial.println("TUNE\tIN/OUT\tNOISEFLOOR"); Serial.print(mod1016.getTuneCaps(), HEX); Serial.print("\t"); Serial.print(mod1016.getAFE(), BIN); Serial.print("\t"); Serial.println(mod1016.getNoiseFloor(), HEX); Serial.print("\n"); pinMode(IRQ_pin, INPUT); attachInterrupt(digitalPinToInterrupt(IRQ_pin), alert, RISING); Serial.println("after interrupt"); // delay execution to allow chip to stabilize. wait(1000); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Lightning2 MOD-1016", "0.3"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_DISTANCE, S_DISTANCE, "Distance"); wait(100); present(CHILD_ID_INTENSITY, V_LEVEL), "Intensity"; } void loop() { if (detected) { translateIRQ(mod1016.getIRQ()); detected = false; } // Send heartbeat if ((millis() - last_heartbeat_time) > heartbeat_time) { sendHeartbeat(); last_heartbeat_time = millis(); } } void alert() { detected = true; } void translateIRQ(uns8 irq) { switch (irq) { case 1: Serial.println("Noise detected"); break; case 4: Serial.println("Disturber detected"); break; case 8: Serial.println("Lightning detected!"); printandsendToGW(); break; } } void printandsendToGW() { int distance = mod1016.calculateDistance(); unsigned int lightning_intensity = mod1016.getIntensity(); if (distance == -1) Serial.println("Lightning out of range"); else if (distance == 1) Serial.println("Distance not in table"); else if (distance == 0) Serial.println("Lightning overhead"); else { Serial.print("Lightning ~"); Serial.print(distance); Serial.println("km away\n"); Serial.print("Lightning Intensity: "); Serial.println(lightning_intensity); send(msgDist.set(distance)); send(msgInt.set(lightning_intensity)); } }
I hope you can see if I went wrong somewhere! But I have checked it and one works (distance) and one does not (intensity).
-
Ah, I see it ... missing bracket (well in the wrong place anyway) - will retry this now! - sorry for confusion.
Update - of course it works when you do it right! Problem solved!
-
But after testing this suddenly all nodes showed as down!!!!
A reboot of the pi didn't solve it, only a full poweroff and then power on again a few minutes later did the trick.
Below is what is in the myslog for this event...
[Wed Jul 18 17:07:10 BST 2018] IO error: java.net.SocketException: Connection reset in processing a request from /192.168.1.6:8443 / sun.security.ssl.SSLSocketImpl [Wed Jul 18 17:07:11 BST 2018] IO error: java.net.SocketException: Connection reset in processing a request from /192.168.1.6:8443 / sun.security.ssl.SSLSocketImpl [Wed Jul 18 17:07:12 BST 2018] IO error: java.net.SocketException: Connection reset in processing a request from /192.168.1.6:8443 / sun.security.ssl.SSLSocketImpl [Wed Jul 18 17:07:18 BST 2018] IO error: java.net.SocketException: Connection reset in processing a request from /192.168.1.6:8443 / sun.security.ssl.SSLSocketImpl [Wed Jul 18 17:07:18 BST 2018] IO error: java.net.SocketException: Connection reset in processing a request from /192.168.1.6:8443 / sun.security.ssl.SSLSocketImpl [Wed Jul 18 19:20:43 BST 2018] Accept: java.net.SocketException: Socket closed 2018-07-18 19:20:46,412 INFO [MyController.org Shutdown-Hook] [org.mycontroller.standalone.mqttbroker.MoquetteMqttBroker:72] MQTT Broker has been stopped successfully 2018-07-18 19:20:46,617 INFO [MyController.org Shutdown-Hook] [org.mycontroller.standalone.AppShutdownHook:36] Bye, Have a nice day! See you soon 2018-07-18 19:20:54,022 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:117] Checking migration... 2018-07-18 19:21:00,881 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:168] Application information: [Version:1.3.0-SNAPSHOT, Database(type:H2 database embedded, version:1.4.194 (2017-03-10), schema version:1.04.01 - 2017 Oct 25), Built on:2018-05-04T09:09:24+0530, Git commit:d111efac6d9ee68aaf862ff8de5c4b677534e16f:development] 2018-07-18 19:21:02,122 WARN [main] [io.moquette.persistence.mapdb.MapDBPersistentStore:78] Using fresh MapDB store file. Path=../conf/persistent_stores/moquette/moquette_store.mapdb 2018-07-18 19:21:02,876 WARN [main] [io.moquette.server.Server:186] Using default SSL context creator 2018-07-18 19:21:03,488 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0x763c35ee]' 2018-07-18 19:21:03,594 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0xe7f26a36]' 2018-07-18 19:21:03,602 INFO [main] [org.mycontroller.standalone.mqttbroker.MoquetteMqttBroker:54] MQTT Broker started successfully. MqttBrokerSettings(enabled=true, sslEnabled=false, bindAddress=0.0.0.0, mqttPort=1883, mqttsPort=8883, websocketPort=7080, allowAnonymous=true, enabledOnBackend=true, sslKeystoreFile=null) 2018-07-18 19:21:04,412 INFO [mc-th-pool-1] [org.mycontroller.standalone.gateway.mqtt.MQTTDriver:86] MQTT Gateway[name:Raspberry Pi, URI:tcp://localhost:1883, NetworkType:MyController] connected successfully.. 2018-07-18 19:21:07,664 INFO [main] [org.mycontroller.standalone.StartApp:215] TJWS server started successfully, HTTPS Enabled?:true, HTTP(S) Port: [8443] 2018-07-18 19:21:07,665 INFO [main] [org.mycontroller.standalone.StartApp:113] MyController.org server started in [14250] ms [Wed Jul 18 19:31:59 BST 2018] Accept: java.net.SocketException: Socket closed 2018-07-18 19:32:02,160 INFO [MyController.org Shutdown-Hook] [org.mycontroller.standalone.mqttbroker.MoquetteMqttBroker:72] MQTT Broker has been stopped successfully 2018-07-18 19:32:02,660 INFO [MyController.org Shutdown-Hook] [org.mycontroller.standalone.AppShutdownHook:36] Bye, Have a nice day! See you soon 2018-07-18 19:32:09,898 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:117] Checking migration... 2018-07-18 19:32:16,897 INFO [main] [org.mycontroller.standalone.db.DataBaseUtils:168] Application information: [Version:1.3.0-SNAPSHOT, Database(type:H2 database embedded, version:1.4.194 (2017-03-10), schema version:1.04.01 - 2017 Oct 25), Built on:2018-05-04T09:09:24+0530, Git commit:d111efac6d9ee68aaf862ff8de5c4b677534e16f:development] 2018-07-18 19:32:18,139 WARN [main] [io.moquette.persistence.mapdb.MapDBPersistentStore:78] Using fresh MapDB store file. Path=../conf/persistent_stores/moquette/moquette_store.mapdb 2018-07-18 19:32:18,878 WARN [main] [io.moquette.server.Server:186] Using default SSL context creator 2018-07-18 19:32:19,500 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0x2f64c36d]' 2018-07-18 19:32:19,591 WARN [main] [io.netty.bootstrap.ServerBootstrap:146] Unknown channel option 'TCP_NODELAY' for channel '[id: 0xa33f8004]' 2018-07-18 19:32:19,595 INFO [main] [org.mycontroller.standalone.mqttbroker.MoquetteMqttBroker:54] MQTT Broker started successfully. MqttBrokerSettings(enabled=true, sslEnabled=false, bindAddress=0.0.0.0, mqttPort=1883, mqttsPort=8883, websocketPort=7080, allowAnonymous=true, enabledOnBackend=true, sslKeystoreFile=null) 2018-07-18 19:32:20,388 INFO [mc-th-pool-1] [org.mycontroller.standalone.gateway.mqtt.MQTTDriver:86] MQTT Gateway[name:Raspberry Pi, URI:tcp://localhost:1883, NetworkType:MyController] connected successfully.. 2018-07-18 19:32:23,567 INFO [main] [org.mycontroller.standalone.StartApp:215] TJWS server started successfully, HTTPS Enabled?:true, HTTP(S) Port: [8443] 2018-07-18 19:32:23,569 INFO [main] [org.mycontroller.standalone.StartApp:113] MyController.org server started in [14111] ms 2018-07-18 19:33:40,533 ERROR [Thread-8] [org.mycontroller.standalone.gateway.serial.SerialDataListenerjSerialComm:176] Exception, java.lang.NumberFormatException: For input string: "0```
-
@skywatch I hope you might have some issue with your serial gateway. Next time when you face this issue, can you unplug your serial gateway and plug it again to check the status?
-
@skywatch This morning I have fixed an issue with a serial port. Can you test again with SNAPSHOT version?
https://github.com/mycontroller-org/mycontroller/commit/c44c84061a64eb93bd98ea329cc3acc6bd93f107
-
Latest snapshot installed and testing.......Thank you!
Will see how it goes this week, I'll let you know the results but it all seems to be happy so far........
-
@skywatch Great! let's see for some time.
-
Hmmmmm....something is not right, see log below.....
Argh, can't post the log in code tags or plain text, will email it to you....
It seems to be the strange characters in the log that prevent it from being copied and pasted, so sent you a screenshot instead.