Openhab and Mysensors connecting sensors (I need Help)



  • Ok so I'll try to explain the problem.

    I have Openhab running on a raspberry pi I have a gateway wired to the Gpio of said Pi and I've configured it in the paper UI as an Ethernet gateway as per the instructions here
    On the paper UI it is showing as online.

    I've created a battery powered Temp sensor using a breadboard however I've
    had some problems trying to program the Arduino.

    using a FTDI to TTL serial adaptor I tried to program the Arduino using the Arduino IDE version 1.8.5.

    This gave me errors about the programmer not being in sync and so following advice from an Arduino forum it was suggested that the arduino clones I've got might not have a bootloader and so I bought a USBasp programmer to burn a bootloader to the Arduino and then program the Arduino using the FDTI this still produced the programmer out of sync error. After further research I discovered that I could program the Arduino using the USBasp and doing so seems to not show any errors.

    I though I would just start with the basic dallasTemperature sketch and just add My node Id and child ID

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * DESCRIPTION
     *
     * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
     * http://www.mysensors.org/build/temp
     */
    
    
    // Enable debug prints to serial monitor
    //#define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
    #define MY_NODE_ID 101
    #define CHILD_ID 1
    #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
    #define MAX_ATTACHED_DS18B20 16
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    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[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    bool receivedConfig = false;
    bool metric = true;
    // Initialize temperature message
    MyMessage msg(0,V_TEMP);
    
    void before()
    {
      // Startup up the OneWire library
      sensors.begin();
    }
    
    void setup()  
    { 
      // requestTemperatures() will not block current thread
      sensors.setWaitForConversion(false);
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Temperature Sensor", "1.1");
    
      // Fetch the number of attached temperature sensors  
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
         present(i, S_TEMP);
      }
    }
    
    void loop()     
    {     
      // Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // query conversion time and sleep until conversion completed
      int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
      // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
      sleep(conversionTime);
    
      // Read temperatures and send them to controller 
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
     
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
     
        // Only send data if temperature has changed and no error
        #if COMPARE_TEMP == 1
        if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
        #else
        if (temperature != -127.00 && temperature != 85.00) {
        #endif
     
          // Send in the new temperature
          send(msg.setSensor(i).set(temperature,1));
          // Save new temperatures for next compare
          lastTemperature[i]=temperature;
        }
      }
      sleep(SLEEP_TIME);
    }
    

    I'm not sure if this right but I'll continue
    I've then created a thing in the paper UI with node id 101 and child id 1 and assigned it the Ethernet gateway.

    the items file

    Number temp01	  "Temperature" { channel="mysensors:temperature:gateway:temp01:temp" }
    

    Ive then linked the Thing to the above item and switched the sensor on in the paper ui it shows the sensor as initializing.

    what am I doing Wrong? its been such a struggle so far

    0_1507567407663_image



  • So I managed to get it working if I program the arduino using the sketch but not try and power it via the battery (but power it via the USB to TTL )I can auto detect the sensor in openhab but when I then disconnect the USB and connect the battery to the breadboard it lights up the power LED but the in built led on pin 13 doesn't do anything and nothing shows in the log on the controller. I thought the pro mini could be powered via a coin cell ?


  • Hero Member

    @Greymarvel Did you connect the coin cell to vcc? If you're using the raw input it won't work.



  • Well at first I had the coin cell plugged into the + and - rails of the breadboard and I was using a 3.3v power booster with Vo going to vcc but I though maybe it was something to do with the booster so I then removed the booster and put a jumper between the +rail and vcc and it still won't work it just seems to illuminate the power led and nothing else. I should mention the radio was being powered from the rails and not from the booster


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.