<?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[Neuling braucht Hilfe]]></title><description><![CDATA[<p>Hallo liebe Forengemeinde,<br />
ich habe angefangen mich mit C++ zu beschäftigen und habe mit einem Project begonnen das ein Temperatur und Luftfeuchtigkeit an eine vorhandene Wetterstation gesendet werden soll. Folgendes Script habe ich dafür erstellt.</p>
<pre><code>// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include &quot;DHT.h&quot;

#define DHTPIN  3     // PIN # for DHT22 Temperature Sensor
#define TXPIN   1    // PIN # for 433Mhz Transmitter
#define LEDPIN  0    // PIN # for LED Indicator

#define DHTTYPE DHT22   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

unsigned long msg_timer = 15000; // Transmits a signal every 1 minute
unsigned long msg_gap = 32; //gap between packets

char buf[11]; //message to be built

void setup() {
//  Serial.begin(9600);
  //Serial.println(&quot;Wireless Temp&quot;);
  pinMode(LEDPIN,OUTPUT);
  pinMode(TXPIN, OUTPUT);
  dht.begin();
}

// Changed int to float
// num is in Celsius. Ex) 26.30

void make_message(float num) {

  // make up a TC6U message from the integer num (-500 to 499)

  // parity table  0 1 2 3 4 5 6 7 8 9
  char   ptable[]={
    0,1,1,2,1,2,2,3,1,2  }; //number of bits set
  int p;  //parity bit
  char h,t,d;  //hundreds,tens,digits

  p=0; //clear parity

  // preamble
  buf[0] = 0;
  buf[1] = 0xa;  //message length and start bits
  buf[2] = 0xe;    //type = temperature
  buf[3] = 0xf;  //device ID
  buf[4] = 0x0;  //bottom bit is parity

    num = num * 10;

  // encode the integer
  num = num+0;
  h = num/100;

  buf[5] = h;  //save hundreds
  p += ptable[h];  //update parity calculation
  num = num - h*100;
  t = num/10;
  buf[6] = t; //save tens
  p += ptable[t];  //update parity
  d = num - t*10;
  buf[7] = d; //save digits
  p += ptable[d];
  buf[8] = h; //second copy of hundreds digit
  buf[9] = t; //second copy of tens digit

  //if value parity odd, set message parity bit
  if ( (p&amp;1) == 1) buf[4] |= 1;
  //calculate and store checksum
  buf[10] = (buf[1]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]+buf[8]+buf[9])&amp;0x0F;
}

void send_one(char s) { //s=1 for short TXPIN off. 4th bit of quartet
  digitalWrite(TXPIN,HIGH);
  delayMicroseconds(588);
  digitalWrite(TXPIN,LOW);
  if (s) delayMicroseconds(1020);
  else delayMicroseconds(1088);
}

void send_zero(char s) { //s=1 for short TX off, 4th bit of quartet
  digitalWrite(TXPIN,HIGH);
  delayMicroseconds(1400);
  digitalWrite(TXPIN,LOW);
  if (s) delayMicroseconds(1020);
  else delayMicroseconds(1088);
}

void send_burst(char *msg) {
  char i,c;

  for(i=0; i&lt;12; i++) {

    c = *msg++;  //values in lower 4 bits

    //unroll inner loop, send a quartet

    if(c&amp;8) send_one(0);
    else send_zero(0);
    if(c&amp;4) send_one(0);
    else send_zero(0);
    if(c&amp;2) send_one(0);
    else send_zero(0);
    if(c&amp;1) send_one(1); //&quot;short tx off&quot; (1020 us) for last bit
    else send_zero(1);
  }
}

// Changed int to float

void send_message(float num) {
  digitalWrite(LEDPIN,HIGH);
  make_message(num);
  send_burst(buf);
  delay(msg_gap);
  send_burst(buf);
  digitalWrite(LEDPIN,LOW);
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

//   Reading temperature or humidity takes about 250 milliseconds!
//   Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {
//    Serial.println(&quot;Failed to read from DHT sensor!&quot;);
    return;
  }

//  Serial.print(t);
  //Serial.println(&quot; *C\t&quot;);
  send_message(h);
  send_message(t); // t is in Celisius. Ex) 26.30
  delay(msg_timer);
}
</code></pre>
<p>Wenn ich nun Temp. und Luftfeuchte einzeln send funktioniert das sehr gut nur komme ich nicht drauf wie das ganze aussehen muss wenn ich beides senden möchte.</p>
<p>Brauche dringend Hilfe und danke schonmal im Vorraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/337253/neuling-braucht-hilfe</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 08:25:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/337253.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 19 Mar 2016 15:15:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Neuling braucht Hilfe on Sat, 19 Mar 2016 15:15:30 GMT]]></title><description><![CDATA[<p>Hallo liebe Forengemeinde,<br />
ich habe angefangen mich mit C++ zu beschäftigen und habe mit einem Project begonnen das ein Temperatur und Luftfeuchtigkeit an eine vorhandene Wetterstation gesendet werden soll. Folgendes Script habe ich dafür erstellt.</p>
<pre><code>// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include &quot;DHT.h&quot;

#define DHTPIN  3     // PIN # for DHT22 Temperature Sensor
#define TXPIN   1    // PIN # for 433Mhz Transmitter
#define LEDPIN  0    // PIN # for LED Indicator

#define DHTTYPE DHT22   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

unsigned long msg_timer = 15000; // Transmits a signal every 1 minute
unsigned long msg_gap = 32; //gap between packets

char buf[11]; //message to be built

void setup() {
//  Serial.begin(9600);
  //Serial.println(&quot;Wireless Temp&quot;);
  pinMode(LEDPIN,OUTPUT);
  pinMode(TXPIN, OUTPUT);
  dht.begin();
}

// Changed int to float
// num is in Celsius. Ex) 26.30

void make_message(float num) {

  // make up a TC6U message from the integer num (-500 to 499)

  // parity table  0 1 2 3 4 5 6 7 8 9
  char   ptable[]={
    0,1,1,2,1,2,2,3,1,2  }; //number of bits set
  int p;  //parity bit
  char h,t,d;  //hundreds,tens,digits

  p=0; //clear parity

  // preamble
  buf[0] = 0;
  buf[1] = 0xa;  //message length and start bits
  buf[2] = 0xe;    //type = temperature
  buf[3] = 0xf;  //device ID
  buf[4] = 0x0;  //bottom bit is parity

    num = num * 10;

  // encode the integer
  num = num+0;
  h = num/100;

  buf[5] = h;  //save hundreds
  p += ptable[h];  //update parity calculation
  num = num - h*100;
  t = num/10;
  buf[6] = t; //save tens
  p += ptable[t];  //update parity
  d = num - t*10;
  buf[7] = d; //save digits
  p += ptable[d];
  buf[8] = h; //second copy of hundreds digit
  buf[9] = t; //second copy of tens digit

  //if value parity odd, set message parity bit
  if ( (p&amp;1) == 1) buf[4] |= 1;
  //calculate and store checksum
  buf[10] = (buf[1]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]+buf[8]+buf[9])&amp;0x0F;
}

void send_one(char s) { //s=1 for short TXPIN off. 4th bit of quartet
  digitalWrite(TXPIN,HIGH);
  delayMicroseconds(588);
  digitalWrite(TXPIN,LOW);
  if (s) delayMicroseconds(1020);
  else delayMicroseconds(1088);
}

void send_zero(char s) { //s=1 for short TX off, 4th bit of quartet
  digitalWrite(TXPIN,HIGH);
  delayMicroseconds(1400);
  digitalWrite(TXPIN,LOW);
  if (s) delayMicroseconds(1020);
  else delayMicroseconds(1088);
}

void send_burst(char *msg) {
  char i,c;

  for(i=0; i&lt;12; i++) {

    c = *msg++;  //values in lower 4 bits

    //unroll inner loop, send a quartet

    if(c&amp;8) send_one(0);
    else send_zero(0);
    if(c&amp;4) send_one(0);
    else send_zero(0);
    if(c&amp;2) send_one(0);
    else send_zero(0);
    if(c&amp;1) send_one(1); //&quot;short tx off&quot; (1020 us) for last bit
    else send_zero(1);
  }
}

// Changed int to float

void send_message(float num) {
  digitalWrite(LEDPIN,HIGH);
  make_message(num);
  send_burst(buf);
  delay(msg_gap);
  send_burst(buf);
  digitalWrite(LEDPIN,LOW);
}

void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

//   Reading temperature or humidity takes about 250 milliseconds!
//   Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float t = dht.readTemperature();
  float h = dht.readHumidity();
  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {
//    Serial.println(&quot;Failed to read from DHT sensor!&quot;);
    return;
  }

//  Serial.print(t);
  //Serial.println(&quot; *C\t&quot;);
  send_message(h);
  send_message(t); // t is in Celisius. Ex) 26.30
  delay(msg_timer);
}
</code></pre>
<p>Wenn ich nun Temp. und Luftfeuchte einzeln send funktioniert das sehr gut nur komme ich nicht drauf wie das ganze aussehen muss wenn ich beides senden möchte.</p>
<p>Brauche dringend Hilfe und danke schonmal im Vorraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2490868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2490868</guid><dc:creator><![CDATA[celika]]></dc:creator><pubDate>Sat, 19 Mar 2016 15:15:30 GMT</pubDate></item><item><title><![CDATA[Reply to Neuling braucht Hilfe on Sat, 19 Mar 2016 15:18:39 GMT]]></title><description><![CDATA[<p>So wird das nichts, sorry. <a href="https://www.c-plusplus.net/forum/200753">Du brauchst Hilfe?</a> Reduziere deine Frage auf etwas direktes. Wir machen hier nicht deine Arbeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2490869</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2490869</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 19 Mar 2016 15:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Neuling braucht Hilfe on Sat, 19 Mar 2016 16:34:27 GMT]]></title><description><![CDATA[<p>Sorryy ich wollte die Arbeit schon selbst machen ich brauchte nur einen Denkanstoss. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2490876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2490876</guid><dc:creator><![CDATA[celika]]></dc:creator><pubDate>Sat, 19 Mar 2016 16:34:27 GMT</pubDate></item><item><title><![CDATA[Reply to Neuling braucht Hilfe on Sat, 19 Mar 2016 16:58:10 GMT]]></title><description><![CDATA[<p>Wenn du beides senden möchtest, dann sende zuerst das eine und danach eben das andere <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Oder möchtest du beides auf einmal senden? Da wir nichts vom verwendeten Protokoll wissen, musst du selber in die Spezifikationen schauen.</p>
<p>Ausßerdem: Der Code ist kein C++, sondern grauenhaft. Globale Variablen, #define und Makros, char-Buffer statt container wie std::string, nichtssagende Variablen, fehlendes const.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2490878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2490878</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 19 Mar 2016 16:58:10 GMT</pubDate></item><item><title><![CDATA[Reply to Neuling braucht Hilfe on Mon, 21 Mar 2016 15:03:48 GMT]]></title><description><![CDATA[<p>ich würde roflo zustimmen,</p>
<p>iwie scheint das für Arduino oder ähnlichen Mikrocontroller zu sein, welche allerdings i C programmiert werden, nicht in C++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2491026</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2491026</guid><dc:creator><![CDATA[Atomic]]></dc:creator><pubDate>Mon, 21 Mar 2016 15:03:48 GMT</pubDate></item><item><title><![CDATA[Reply to Neuling braucht Hilfe on Mon, 21 Mar 2016 16:05:10 GMT]]></title><description><![CDATA[<p>Hallo und danke für die Antworten.<br />
Ja das ist für Arduino allerdings läuft das auf einem Attiny 85</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2491032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2491032</guid><dc:creator><![CDATA[celika]]></dc:creator><pubDate>Mon, 21 Mar 2016 16:05:10 GMT</pubDate></item></channel></rss>