Sending data to Domoticz issue



  • Hello guys,

    So the last couple of days I've been struggling to get my Arduino working with Domoticz. My setup:

    • Arduino Uno
    • Moist sensor (using analog)
    • Serial gateway to a raspberry pi with Domoticz

    When I'm monitoring my arduino using the serial monitor, I can see data every 2000ms. I assume that this works, although just in case, here are some of the lines:

    Mositure : 75%
    0;0;1;0;37;75
    0;255;3;0;9;53238 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
    0;255;3;0;9;53340 MCO:SLP:WUP=-1
    Mositure : 75%
    0;0;1;0;37;75
    0;255;3;0;9;53376 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
    0;255;3;0;9;53477 MCO:SLP:WUP=-1
    Mositure : 75%
    0;0;1;0;37;75
    0;255;3;0;9;53513 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
    0;255;3;0;9;53614 MCO:SLP:WUP=-1
    

    Ok so let's move to the problem:

    I've added the device on Domoticz, seems to work (I've gotten data and I can present it).
    The problem is that I only get data once (just after plugging the USB from Arduino into the pi).
    So in other words, data is being read in Domoticz, although only at initiatialisation(although that's my conclusion I can be wrong in this).

    I've tried several things (hence the comments in the code).
    The Arduino code:

    #define MY_DEBUG
    
    
    // Enable and select radio type attached
    //#define MY_RADIO_NRF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level.
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enable serial gateway
    #define MY_GATEWAY_SERIAL
    
    // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 115200
    #endif
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    
    // Inverses behavior of inclusion button (if using external pullup)
    //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
    
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
    
    #include <MySensors.h>
    #include <MyConfig.h>
    //#include <MySensors.h>
    
    // Setting up format for reading 3 soil sensors
    //#define NUM_READS (int)10    // Number of sensor reads for filtering
    #define CHILD_ID 0
    
    MyMessage msg(CHILD_ID, V_LEVEL);
    //uint32_t SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    
    //long buffer[NUM_READS];
    //int idx;
    //values valueOf[NUM_READS];        // Calculated moisture percentages and resistances to be sorted and filtered
    //int i;                            // Simple index variable
    int sensor_pin = A0; 
    int output_value ;
    
    void setup() {
      Serial.begin(9600);
      Serial.println("Reading From the Sensor ...");
      }
      
    void presentation()
    {
      present(CHILD_ID, S_MOISTURE);
    }
    
    void loop() {
      output_value= analogRead(sensor_pin);
      output_value = map(output_value,1023,0,0,100);
      Serial.print("Mositure : ");
      Serial.print(output_value);
      Serial.println("%");
    
      send(msg.set(output_value)); 
      sleep(2000);
      //delay(2000);
      }
    

    Usually I never have problems with these things, and I really hope I did something stupid. I see a lot of potential for MySensors and I hope someone can help me out.

    Thank you in advance!

    Greetings,
    Edi


  • Mod

    Hi @edi, welcome to the forum!
    What does the Domoticz log say?



  • Hi @mfalkvidd, Thank you 😃

    Ah yeah the Domoticz log, the ''last seen status'' dates to 17:07:10.
    Here it is:

    2018-08-11 17:07:10.275 MySensors: Gateway Ready...
    2018-08-11 17:46:15.498 Status: Incoming connection from:
    2018-08-11 18:14:29.385 Status: Incoming connection from:

    I've unplugged it after 18:14
    Replugged it just now:

    2018-08-12 12:25:06.952 Status: MySensors: Using serial port: /dev/ttyACM0
    2018-08-12 12:25:08.529 MySensors: Gateway Ready...

    0_1534069810466_Knipsel.PNG



  • Bump bump


  • Mod

    Comment the my_debug and try again


Log in to reply
 

Suggested Topics

  • 5
  • 2
  • 1
  • 4
  • 2
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts