<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Question about RS485 and MY_DEBUG]]></title><description><![CDATA[<p dir="auto">Hey guys,</p>
<p dir="auto">I gues i have an simple question ,<br />
Is it normal that RS485 on Hardware Serial only works with MY_DEBUG enabled?</p>
<p dir="auto">If i exclude the MY_DEBUG, communication stops to the gateway</p>
<p dir="auto">Here an example sketch:</p>
<pre><code>#define MY_DEBUG
#define MY_RS485
#define MY_RS485_DE_PIN 2
#define MY_RS485_BAUD_RATE 19200
#define MY_RS485_HWSERIAL Serial
#define MY_NODE_ID 5


#include &lt;MySensors.h&gt;  
#include &lt;DallasTemperature.h&gt;
#include &lt;OneWire.h&gt;

#define COMPARE_TEMP 0 // Send temperature only if changed? 1 = Yes 0 = No

#define ONE_WIRE_BUS A1 // Pin where dallase sensor is connected 
#define MAX_ATTACHED_DS18B20 2
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(&amp;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 msga(0,V_TEMP);





#define CHILD_ID_LIGHT 25
#define LIGHT_SENSOR_ANALOG_PIN 0


MyMessage msg(CHILD_ID_LIGHT, V_TEXT);
int lastLightLevel;


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("Node 5", "1.0");

    // Register all sensors to gateway (they will be created as child devices)
    present(CHILD_ID_LIGHT, S_BINARY);


  numSensors = sensors.getDeviceCount();

  // Present all sensors to controller
  for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {   
     present(i, S_TEMP);
  }

    
}

void loop()
{

  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)
  wait(conversionTime);

  // Read temperatures and send them to controller 
  for (int i=0; i&lt;numSensors &amp;&amp; i&lt;MAX_ATTACHED_DS18B20; i++) {

    // Fetch and round temperature to one decimal
    float temperature = static_cast&lt;float&gt;(static_cast&lt;int&gt;((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 &amp;&amp; temperature != -127.00 &amp;&amp; temperature != 85.00) {
    #else
    if (temperature != -127.00 &amp;&amp; temperature != 85.00) {
    #endif


    int16_t lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
        send(msg.set(lightLevel));
        
      // Send in the new temperature
      send(msga.setSensor(i).set(temperature,1));
      // Save new temperatures for next compare
      lastTemperature[i]=temperature;
    }
  }
  wait(SLEEP_TIME);
}

</code></pre>
]]></description><link>https://forum.mysensors.org/topic/10776/question-about-rs485-and-my_debug</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 14:57:22 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/10776.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Nov 2019 18:20:13 GMT</pubDate><ttl>60</ttl></channel></rss>