Nothing on serial monitor on MySensor sketches



  • Hello,

    I am trying to setup a sensor network connected by MQTT Gateway to Open Hab.

    I started with codebender and was unsuccessful so now I am using the Ardiuno IDE. I have been testing the soil moisture and light level sensors thus far. If I upload the LED Blinking sketch, the LED on my Pro Mini blinks. If I upload the basic Arduino Serial Analog output sketch then on serial monitor I get values that fluctuate depending on light level. If I upload the MySensors light sensor sketch (and change baud rate to 115200) I get nothing on the serial monitor. Similarly if I upload the soil moisture sketch I get no response on the serial monitor. Myconfig.h has #define DEBUG in it.

    I think my MQTT Gateway is working because I can connect to it from MyMQTT on my Android. OpenHab isn't really giving me any indication it can or cannot connect to the broker.

    Any thoughts? Right now I am assuming my sensors are the issue but without any output on the serial monitor, I'm unsure.



  • Small update.
    Plugged the MQTT Controller with MQTT Gateway sketch into the serial monitor and I am getting some information on the monitor. It looks like gibberish which I thought would normally be fized by adjusting the baud rate (started with it on 115200) but trying all the settings gives similar results. However I can publish a message with MyMQTT on android and it does seem to react. So I am still thinking it is my sensors with the issue.



  • Further update:
    When connecting the monitoring gateway to the serial monitor I see "Started" and if I send a message from MyMQTT on Android I see the message. So the gateway portion and the ethernet portion are working. Cannot confirm radio is working yet.

    On my light sensor I can build a sketch that doesn't use MySensors and I can read the light level on the serial monitor. When I use MySensors, I get nothing on the serial monitor. Debug is enabled on myconfig. I'm not sure at which point in the process the failure occurs since nothing prints to the serial monitor.

    I haven't added any capacitors to the radios. I saw that this could help with signal but I'm not sure this is the issue since the two device are 2-4 feet from each other.

    Is it safe to assume that if the radio connection was the problem, that I would received some kind of feedback about not being able to connect on the serial monitor?

    Thanks


  • Admin

    Which light sketch are you using? BH1750FVI or LM393?

    Have you confirmed communication with just a serial gateway/IDE serial monitor?



  • The sensor is like the LM 393 and it is the analog output sketch.

    When using the Arduino IDE serial monitor:
    If I make my own sketch from scratch or use the Arduino example sketch to read analog output, I get a reading from the sensor. If I use the example MySensors sketch and disable all the commands with gw in them, I can get a reading as well. However, when I use the MySensors related commands including gw.begin, I get nothing on the serial monitor.

    I am having similar issue with a soil moisture monitor.


  • Admin

    @hooraysimpsons

    Strange.. IDE version?
    Serial should be set to 115200 by default.
    Maybe you could try to lower it in gw.setup() if your USB cable is junk.



  • Ardunio 1.0.6

    This code works:
    #include <SPI.h>
    #include <MySensor.h>

    #define CHILD_ID_LIGHT 0
    #define LIGHT_SENSOR_ANALOG_PIN 0

    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)

    MySensor gw;
    MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    int lastLightLevel;

    void setup()
    {
    Serial.begin(9600);
    // gw.begin();

    // Send the sketch version information to the gateway and Controller
    // gw.sendSketchInfo("Light Sensor", "1.0");

    // Register all sensors to gateway (they will be created as child devices)
    // gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }

    void loop()
    {
    int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
    Serial.println(lightLevel);
    if (lightLevel != lastLightLevel) {
    // gw.send(msg.set(lightLevel));
    lastLightLevel = lightLevel;
    }
    delay(1000);
    // gw.sleep(SLEEP_TIME);
    }



  • with gw.setup I get:
    LightSensor:18: error: 'class MySensor' has no member named 'setup'



  • If the issue was a bad radio would there still be some kind of output on the serial monitor or would the failure to connect to the gateway cause an issue that prevents the remainder of the code from executing and giving an output?



  • If I replace gw.begin() with the below line of code and continue to comment out the remainder of the gw lines I can get the light output on the serial monitor.

    void begin(void (* msgCallback)(const MyMessage &)=NULL, uint8_t nodeId=AUTO, boolean repeaterMode=false, uint8_t parentNodeId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_LEVEL, uint8_t channel=RF24_CHANNEL, rf24_datarate_e dataRate=RF24_DATARATE);

    My understanding is the gw.begin() and that line of code should be equivalent. I've coded in the past with Fortran but not for years so I may be missing something obvious here.


  • Admin

    Sorry meant you could edit begin() (not setup) in MySensor.cpp to lower the serial baudrate above if you have problem with the serial line at high speeds.

    You should at least get a startup message if you have DEBUG enabled in MyConfig.h.

    Remve Serial.begin(9600); from your sketch and use the baudrate you use /set in begin().



  • #define BAUD_RATE 9600 is already placed in mysensors.h.

    I don't see any reference to baud rate or starting the serial output in the begin function in mysensors.h

    That is why I added serial.begin(9600) to the sketch to see if that helped. It didn't but I left it in so that it would be started when I commented out the gw.begin


  • Admin



  • I forgot about the .cpp files. Did I tell you I was new to this?

    So by placing serial.println commands in my mysensors.cpp file I have identified where things seem to get stuck:

    Within the findparentnode routine:

    Serial.println("FPN1");
    sendWrite(BROADCAST_ADDRESS, msg, true);
    Serial.println("FPN1");

    I'll keep investigating when I get time. Thanks for your help



  • I turned on failure_handling within the rf24 config. Now I get the following messageon my serial output:

    send: 255-255-255-0 s=255,c=3,t=3,pt=0,l=0,st=fail:

    as well as:

    sensor started, id 255
    req node id

    This happens three times before it appears to give up and runs the rest of the parent sketch which starts a serial output of A0.


  • Hero Member

    send: 255-255-255-0 s=255,c=3,t=3,pt=0,l=0,st=fail:

    Seems like your node is requesting a id from a controller, see for example http://forum.mysensors.org/topic/531/using-an-uno-for-sensor-with-negative-results



  • I added capacitors to my radios to see if that would help. I'm also testing with a serial gateway without much difference. I tried assigning a node id of 1. Didn't seem to change much.

    The debug output goes to the serial monitor correct? I'm wondering why I'm not getting any debug messages.



  • Ok. My primary problem was the radios I purchased form Ebay weren't the correct type. I've purchased new ones. Still got some problems to work through but I'll put in a seperate thread.

    For others reading later:

    Other references to these radios:
    http://forum.mysensors.org/topic/878/no-debug-data-from-sensors-or-gateway-bad-radios
    http://forum.mysensors.org/topic/728/radio-setup-give-check-wires/17
    And specifically mentioned on the troubleshooting page as well.


Log in to reply
 

Suggested Topics

  • 3
  • 2
  • 6
  • 5
  • 1

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts