Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. jjk
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    jjk

    @jjk

    9
    Reputation
    51
    Posts
    603
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    jjk Follow

    Best posts made by jjk

    • simple BBQ node

      Not sure this is of use for anyone, but I thought I post a little project I implemented recently and that's pretty straight forward to implement.

      When we were at our friends' place he showed off his cool new wifi-enabled BBQ-thermometer with the corresponding app. Nice gadget, that he got from his wife as a birthday present. When I looked it up online and saw the price tag of well above 150,- EUR I thought there must be a much cheaper way of getting this... And there is: a simple, mysensorized BBQ-node!

      Next time they came over to our place we were standing in the kitchen and when it was time to check on the meat, all I did was ask Alexa - the effect was phenomenal 😉

      There are many good tutorials on the web on how to connect a thermistor and read the temperature, I've used this as the basis: https://learn.adafruit.com/thermistor/using-a-thermistor

      Here's my simple setup:
      I'm using a Nano powered with an external 5V supply, two Maverick temperature probes and 2 extra resistors for the voltage dividers. Turns out the two Mavericks are the biggest price items with around 20,- EUR each. There are much cheaper probes available, but I wanted to make sure they are durable and avoid having to re-calibrate the whole thing every time I have to get a new thermistor probe.

      Please note, this project is not meant to actively control the smoker temperature! There are many projects to follow online that go down that road. I'm a bit of an old-fashioned BBQ-fan, I feel controlling the smoker temp and adjusting it when needed is part of the fun. So all this does is to read smoker and meat temperature...

      Mainly to be able to check the temperature while developing the BBQ-node, I also added a 4-line LCD display (https://www.mysensors.org/build/display). It actually turned out to be quite handy, as it allows to check the temp while in the yard and without a handheld or Alexa.

      Wiring everything up is pretty straight forward following the steps in the above two links for thermistor and display. It took me a bit to figure out the right settings for the thermistor as I didn't get data sheets or resistance curves. There's still some improvement potential to get the temperature readings more accurate, but for now precision is good enough.

      0_1500822611672_bbq_node.jpg
      (note: in ths pic, the smoker room temp probe was not attached, yielding a wrong value in the display!)

      // -----------------------
      // myBBQ-Node
      // -----------------------
      
      // Enable debug prints
      #define MY_DEBUG
      //#define MY_DEBUG_VERBOSE
      #define MY_TRANSPORT_WAIT_READY_MS 1
      
      // define node specific configuration
      // ***********************************
      // BBQ Thermometer
      // ***********************************
      #define MY_NODE_ID 13
      char MY_BBQ_NODE_VERSION = "0.4";
      char MY_BBQ_NODE_DATE    = "02.07.2017";
      
      #define HEARTBEAT_INTERVAL 6000 // send heartbeat every 2 min
      
      // which analog pin to connect
      #define THERMISTORPIN_A A0
      #define THERMISTORPIN_B A1
      // temp. for nominal resistance (almost always 25 C)
      #define TEMPERATURENOMINAL 25
      // resistance at this nominal temperature
      #define THERMISTORNOMINAL_A 1000000
      #define THERMISTORNOMINAL_B 1000000
      // the value of the 'other' resistor
      #define SERIESRESISTOR_A 920000
      #define SERIESRESISTOR_B 1000000
      // how many samples to take and average, more takes longer
      // but is more 'smooth'
      #define NUMSAMPLES 20
      // The beta coefficient of the thermistor (usually 3000-4000)
      #define BCOEFFICIENT_A 3950
      #define BCOEFFICIENT_B 3950
      
       
      // Enable and select radio type attached 
      #define MY_RADIO_NRF24
      //#define MY_RF24_CHANNEL  77
      //#define MY_RADIO_RFM69
      //#define MY_RS485
       
      #include <SPI.h>
      // Enabled repeater feature for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MySensors.h>  
      #include <Wire.h>
      #include <LiquidCrystal_I2C.h>
      
      // Initialize display. Google the correct settings for your display. 
      // The follwoing setting should work for the recommended display in the MySensors "shop".
      //LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
      LiquidCrystal_I2C lcd(0x27, 20, 4);
      
      // Sleep time between sensor updates (in milliseconds)
      // Must be >1000ms for DHT22 and >2000ms for DHT11
      //static const uint64_t UPDATE_INTERVAL = 60000;
      static const uint64_t UPDATE_INTERVAL = 300000;
      
      
      #define CHILD_ID_TEMP_SMOKER 0
      #define CHILD_ID_TEMP_MEAT 1
      bool metric = true;
      
      
      MyMessage msgTempSmoker(CHILD_ID_TEMP_SMOKER, V_TEMP);
      MyMessage msgTempMeat(CHILD_ID_TEMP_MEAT, V_TEMP);
      
      
      void presentation()  
      { 
        // Send the sketch version information to the gateway
        sendSketchInfo("BBQ Temp", "0.2");
        
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID_TEMP_SMOKER, S_TEMP);
        present(CHILD_ID_TEMP_MEAT, S_TEMP);
        
        metric = getControllerConfig().isMetric;
      }
      
      
      void setup() {
      
        float temp_smoker;
        float temp_meat;
      
        // connect AREF to 3.3V and use that as VCC, less noisy!
        analogReference(EXTERNAL);
      
        temp_meat   = analogRead(THERMISTORPIN_A);
        temp_smoker = analogRead(THERMISTORPIN_B);
        float meat   = calc_steinhart(temp_meat, SERIESRESISTOR_A, THERMISTORNOMINAL_A, BCOEFFICIENT_A);
        float smoker = calc_steinhart(temp_smoker, SERIESRESISTOR_B, THERMISTORNOMINAL_B, BCOEFFICIENT_B);
      
        // initialize the lcd for 16 chars 2 lines and turn on backlight
        //lcd.begin(16,2); 
        lcd.init();
        lcd.clear();
        lcd.home();
        lcd.setCursor (0,0);
        lcd.backlight();
        lcd.print("myBBQ Thermometer");
        lcd.setCursor (10,2);
        lcd.print("Vers. " + MY_BBQ_NODE_VERSION);
        lcd.setCursor (10,3);
        lcd.print(MY_BBQ_NODE_DATE);
        delay(5000);
        lcd.clear();
        lcd_update(smoker,meat);
      }
      
      
      void loop(void) {
        uint8_t i;
        float av_smoker;
        float av_meat;
        
        // take NUMSAMPLES samples in a row, with a slight delay
        av_meat   = 0;
        av_smoker = 0;
        for (i=0; i< NUMSAMPLES; i++) {
         av_meat += analogRead(THERMISTORPIN_A);
         delay(50);
         av_smoker = analogRead(THERMISTORPIN_B);
         delay(50);
         lcd.setCursor (0+i,1);
         lcd.print("_");
        }
       
        // average all the samples out
        av_meat /= NUMSAMPLES;
        av_smoker /= NUMSAMPLES;
       
        Serial.print("Average analog reading 1: "); 
        Serial.println(av_meat);
        Serial.print("Average analog reading 2: "); 
        Serial.println(av_smoker);
      
        float temp_meat   = calc_steinhart(av_meat, SERIESRESISTOR_A, THERMISTORNOMINAL_A, BCOEFFICIENT_A);
        float temp_smoker = calc_steinhart(av_smoker, SERIESRESISTOR_B, THERMISTORNOMINAL_B, BCOEFFICIENT_B);
       
        Serial.print("Temp Meat "); 
        Serial.print(temp_meat);
        Serial.println(" *C");
        Serial.print("Temp Smoker "); 
        Serial.print(temp_smoker);
        Serial.println(" *C");
      
        lcd_update(temp_smoker,temp_meat);
      
        send(msgTempSmoker.set(temp_smoker, 1));
        send(msgTempMeat.set(temp_meat, 1));
      
        delay(1000);
      }
      
      
      float calc_steinhart(float reading, float RSER, float RNOM, float BCOEFF) {
        uint8_t i;
       
        // convert the value to resistance
        reading = 1023 / reading - 1;
        reading = RSER / reading;
        Serial.print("RSER "); 
        Serial.println(RSER);
        Serial.print("RNOM "); 
        Serial.println(RNOM);
        Serial.print("BCOEFF "); 
        Serial.println(BCOEFF);
        Serial.print("Thermistor resistance "); 
        Serial.println(reading);
       
        float steinhart;
        steinhart = reading / RNOM;                  // (R/Ro)
        steinhart = log(steinhart);                  // ln(R/Ro)
        steinhart /= BCOEFF;                         // 1/B * ln(R/Ro)
        steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
        steinhart = 1.0 / steinhart;                 // Invert
        steinhart -= 273.15;                         // convert to C
       
        Serial.print("cal_steinhart Temp: "); 
        Serial.print(steinhart);
        Serial.println(" *C");
      
        return steinhart;
      
      }
      
      
      void lcd_update(float smoker, float meat) {
        lcd.clear();
        lcd.home();
        // print information to lcd display
        lcd.setCursor (0,0);
        lcd.print("BBQ: ");
        lcd.print("Pulled Pork");
      
        lcd.setCursor (0,2);
        lcd.print("Smoker:");
        lcd.setCursor (0,3);
        if (smoker <= 0) {
          lcd.print("- n.a. -");
        } else if (smoker <= 10) {
          lcd.print("- low -");
        } else if (smoker > 200) {
          lcd.print("+ high +");
        } else {
          lcd.print(smoker);
          lcd.print(" *C");
        }
      
        lcd.setCursor (11,2);
        lcd.print("Fleisch:");
        lcd.setCursor (11,3);
        if (meat <= 0) {
          lcd.print("- n.a. -");
        } else if (meat <= 10) {
          lcd.print("- low -");
        } else if (meat > 120) {
          lcd.print("+ high +");
        } else {
          lcd.print(meat);
          lcd.print(" *C");
        }
      }
      
      
      posted in My Project
      jjk
      jjk
    • RE: JSON payload in MQTT message

      no intention to reinvent anything that is proven and works 😉 If you could kindly point me in the right direction for an example, I am more than happy to rely on what's available!

      posted in Development
      jjk
      jjk
    • RE: openHAB 2.2 binding MQTT support

      Hi @TimO ,

      after doing clean install of OH and the ESH mqtt binding per the original post above, the mqqt service ran properly (no errors in the debug log). After installing the mysensors binding, I start seing mysensors topics come in, but then following exception is thrown

      2018-02-06 20:01:10.676 [DEBUG] [o.client.mqttv3.internal.ClientState] - paho167001634703924: received key=1 message=PUBLISH qos:1 msgId:1 retained:true dup:false topic:"mysgw-out/1/0/1/0/97" payload:[hex:33392e38 utf8:"39.8" length:4]
      2018-02-06 20:01:10.676 [DEBUG] [o.client.mqttv3.internal.ClientState] - paho167001634703924: received key=1 token=org.eclipse.paho.client.mqttv3.MqttToken@e71260 message=SUBACK msgId 1 granted Qos 1
      2018-02-06 20:01:10.677 [DEBUG] [client.mqttv3.internal.CommsCallback] - paho167001634703924: new msg avail, notify workAvailable
      2018-02-06 20:01:10.678 [DEBUG] [o.client.mqttv3.internal.ClientState] - paho167001634703924: wait for new work or for space in the inflight window
      2018-02-06 20:01:10.679 [DEBUG] [client.mqttv3.internal.CommsReceiver] - paho167001634703924: network read message
      2018-02-06 20:01:10.679 [DEBUG] [client.mqttv3.internal.CommsCallback] - paho167001634703924: call messageArrived key=1 topic=mysgw-out/1/0/1/0/97
      2018-02-06 20:01:10.680 [DEBUG] [o.client.mqttv3.internal.ClientState] - paho167001634703924: received bytes count=1
      2018-02-06 20:01:10.681 [DEBUG] [o.client.mqttv3.internal.ClientState] - paho167001634703924: received bytes count=28
      2018-02-06 20:01:10.681 [DEBUG] [client.mqttv3.internal.CommsCallback] - paho167001634703924: callback threw exception
              at org.openhab.binding.mysensors.internal.protocol.mqtt.MySensorsMqttConnection$MySensorsMqttSubscriber.processMessage(MySensorsMqttConnection.java:140) [233:org.openhab.binding.mysensors:2.2.0.201712141227]
              at org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection$ClientCallbacks.messageArrived(MqttBrokerConnection.java:121) [232:org.eclipse.smarthome.io.transport.mqtt:0.10.0.b1]
              at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:354) [231:org.eclipse.paho.client.mqttv3:1.0.2]
              at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:162) [231:org.eclipse.paho.client.mqttv3:1.0.2]
      2018-02-06 20:01:10.683 [DEBUG] [o.client.mqttv3.internal.ClientComms] - paho167001634703924: state=DISCONNECTING
      

      Any idea what I'm doing wrong?

      UPDATE:
      For what it's worth, I found the trigger for the error. In fact, the mqtt messages the binding received were (for whatever reason) retained messages of the mosquitto broker. After removing the mosquitto presistence file

      sudo service mosquitto stop
      sudo rm /var/lib/mosquitto/mosquitto.db
      sudo service mosquitto start
      

      it now seems to work o.k. - Hope this might help others who come across this thread.

      posted in OpenHAB
      jjk
      jjk
    • RE: ESP8266 MQTT Gateway and setting NODE_ID

      I found this topic by chance and there might be new info - if so, I'm sorry.
      However, I was thinking how the "forced" node-id 0 will work if more than one ESP8266 gateway is installed within possible radio range of the sensor nodes. Wouldn't that be leading to unpredictable behavior, like messages sent more than one?

      posted in Troubleshooting
      jjk
      jjk
    • RE: ESP8266 MQTT Gateway and setting NODE_ID

      @mfalkvidd thanks for the swift reply - sometimes the obvious is hard to see 😉

      posted in Troubleshooting
      jjk
      jjk

    Latest posts made by jjk

    • RE: 💬 Serial Protocol - 2.x

      @gohan yes, have done that. Thanks for your time and support!

      posted in Announcements
      jjk
      jjk
    • RE: openHAB 2.2 binding MQTT support

      @TimO after installing a (simple) sketch on a new node with the mysensors 2.2 library, I noticed frequent exceptions in the openhab logfile. It took me a while to figure out why, but it seems the issue is linked to new messages the ne mysensors library is sending in relation to smartsleep (type 32 and 33). I was able to reproduce the exceptions with manually generated mqtt messages. Below is the openhab log filtered for MySensorsMQTT

      2018-02-21 13:43:23.232 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:43:23.478 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - MQTT message received. Topic: mysgw-out/151/4/1/0/0, Message: 2.4
      2018-02-21 13:43:23.480 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Message topic part: 151/4/1/0/0
      2018-02-21 13:43:23.481 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Converted MQTT message to MySensors Serial format. Sending on to bridge: 151;4;1;0;0;2.4
      2018-02-21 13:43:23.665 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - MQTT message received. Topic: mysgw-out/151/3/1/0/4, Message: 1013
      2018-02-21 13:43:23.666 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Message topic part: 151/3/1/0/4
      2018-02-21 13:43:23.668 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Converted MQTT message to MySensors Serial format. Sending on to bridge: 151;3;1;0;4;1013
      2018-02-21 13:43:28.499 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - MQTT message received. Topic: mysgw-out/151/255/3/0/22, Message: 13830390
      2018-02-21 13:43:28.501 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Message topic part: 151/255/3/0/22
      2018-02-21 13:43:28.503 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Converted MQTT message to MySensors Serial format. Sending on to bridge: 151;255;3;0;22;13830390
      2018-02-21 13:43:33.234 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:43:43.236 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:43:53.238 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:44:03.240 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:44:13.242 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:44:23.244 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      2018-02-21 13:44:23.579 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - MQTT message received. Topic: mysgw-out/43/255/3/0/33, Message: 300000
      2018-02-21 13:44:23.581 [DEBUG] [rotocol.mqtt.MySensorsMqttConnection] - Message topic part: 43/255/3/0/33
      2018-02-21 13:44:23.589 [ERROR] [rotocol.mqtt.MySensorsMqttConnection] - MQTT connection offline - {}
      	at org.openhab.binding.mysensors.internal.protocol.mqtt.MySensorsMqttConnection$MySensorsMqttSubscriber.processMessage(MySensorsMqttConnection.java:140) ~[?:?]
      2018-02-21 13:44:33.247 [TRACE] [rotocol.mqtt.MySensorsMqttConnection] - Bridge is connected, connection skipped
      

      Currently, the only workaround seems to be to avoid smartsleep or compile the nodes with the 2.1.1 library.

      posted in OpenHAB
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      yes, I am sure now: https://forum.mysensors.org/topic/8933/mysensors-2-2-0-released/27

      Looks like the only way to eliminate the messages is to not use smartsleep 😉

      posted in Announcements
      jjk
      jjk
    • RE: MySensors 2.2.0 released

      @anticimex said in MySensors 2.2.0 released:

      @maghac Hi,
      documentation is best found here: https://www.mysensors.org/apidocs/
      It is always covering the latest release. Specifically, for message types: https://www.mysensors.org/apidocs/group__MyMessagegrp.html

      Is there a way to disable these messages?

      posted in Announcements
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      @gohan fair question, I don't need it, it's just still in the code and besides, the 5 min message from smartsleep seems to show up every two mins (the heartbeaat rate)
      And yes, I did indeed update the library, so maybe that's why. Turns out, the bigger problem is that these message seem to cause an exception in the openhab mysensor binding, so at best I'd like to figure out how to stop the node from sending them... Will do some digging

      posted in Announcements
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      o.k., fair enough, that's a great explanation! - I'm still struggling, though, with why this node is sending this (but no heartbeat), but none of the previous ones I did...

      posted in Announcements
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      hm, you might be right on the 300000 as that#s indeed the smartsleep wait time I'm setting. Not sure about the 500, but certainly possible (is that documented somewhere?) I'm wondering, though, why this node is sending this info, but not the other ones?! I don't think I have changed anything t the sketch other than the node-id and node name...

      posted in Announcements
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      yes, I do - like on every other DHT node as well, but never had that...?! Plus, I can't seem to figure out what the messages mean.

      posted in Announcements
      jjk
      jjk
    • RE: 💬 Serial Protocol - 2.x

      Hi there,
      do you know that, you've built a node like a 100 times and I think it's all routine and then something that completely bluffs you? I happened to me with a simple Temp/Hum node (DHT22) that keeps sending me messages that I can't seem to figure out: 43;255;3;0;33;300000 and 43;255;3;0;32;500 - They seem to show up in the frequency that other nodes send a heartbeat signal, but no heartbeat is sent from this node. The regular DHT22 datapoints are sent as normal. Anyone knows what this means?

      posted in Announcements
      jjk
      jjk
    • RE: openHAB 2.2 binding MQTT support

      @timo, another effect I noticed is that the mysensor binding seems a bit sensitive to updates in the things and item files. I got new errors every time I added a thing to the things file or modified the items file. After rebooting OH those erros were gone and the things properly included. Stopping the mysensors binding (bundle:stop) before adding/changing things or items and restarting it afterwards works without a problem.

      posted in OpenHAB
      jjk
      jjk