user43573: In this tutorial, it sends a string from a node to the other node. But if I want to send an integer instead of a string, how should I change the code?
Serial.println("Sending to rf95_server");
// Send a message to rf95_server

String radiopacket = "Hello World #";
radiopacket += String(packetnum++);
radiopacket += " from ";
radiopacket += node_id;

Serial.print("Sending "); Serial.println(radiopacket); delay(10);
rf95.send((uint8_t*)radiopacket.c_str(), radiopacket.length()+1);

Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent();


user4143: The simplest way is to just cast the integer into an array of 2 bytes and send that.  Assuming int temperature:
rf95.send((uint8_t *)&temperature, 2);

To make it more portable you can use the size of an integer instead of 2:
rf95.send((uint8_t *)&temperature, sizeof(int));

Reading back, you just cast the buffer you have received as an integer, or combine the data manually (which may be safer since the buffer may be misaligned on a more powerful system than an 8 bit Arduino):
int temperature = buf[0] | (buf[1] << 8);

(Assuming it was sent from a little-endian 8-bit system).
If you want to send the number as plain text, so it can be easily read by a human, you want to print it to a string:
char temp[6];
sprintf(temp, "%d", temperature);
rf95.send((uint8_t *)temp, strlen(temp));


43573: <p>In <a href="https://cytrontechnologies.github.io/RFM-LoRa-Shield-Examples/Arduino-Sketches-Overview/" rel="nofollow noreferrer">this tutorial</a>, it sends a string from a node to the other node. But if I want to send an integer instead of a string, how should I change the code?</p>

<pre><code>Serial.println("Sending to rf95_server");
// Send a message to rf95_server

String radiopacket = "Hello World #";
radiopacket += String(packetnum++);
radiopacket += " from ";
radiopacket += node_id;

Serial.print("Sending "); Serial.println(radiopacket); delay(10);
rf95.send((uint8_t*)radiopacket.c_str(), radiopacket.length()+1);

Serial.println("Waiting for packet to complete..."); delay(10);
rf95.waitPacketSent();
</code></pre>
 4143: <p>The simplest way is to just cast the integer into an array of 2 bytes and send that.  Assuming <code>int temperature</code>:</p>

<pre><code>rf95.send((uint8_t *)&amp;temperature, 2);
</code></pre>

<p>To make it more portable you can use the size of an integer instead of 2:</p>

<pre><code>rf95.send((uint8_t *)&amp;temperature, sizeof(int));
</code></pre>

<p>Reading back, you just cast the buffer you have received as an integer, or combine the data manually (which may be safer since the buffer may be misaligned on a more powerful system than an 8 bit Arduino):</p>

<pre><code>int temperature = buf[0] | (buf[1] &lt;&lt; 8);
</code></pre>

<p>(Assuming it was sent from a <em>little-endian</em> 8-bit system).</p>

<p>If you want to send the number as plain text, so it can be easily read by a human, you want to print it to a string:</p>

<pre><code>char temp[6];
sprintf(temp, "%d", temperature);
rf95.send((uint8_t *)temp, strlen(temp));
</code></pre>
