<?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[Help modifying sketch for rf-nano]]></title><description><![CDATA[<p dir="auto">I have set all my sensors up using a nano and nrf24l01 wireless modules. Just received some rf-nanos I ordered but they are not working with my current sketches. I could use some advice on what to change in my moisture sensor sketch to get it to send data to my gateway. I verified the new rf-nanos work with the following 2 sketches.</p>
<p dir="auto">rf-nano send sketch:</p>
<pre><code>/*
    
   RF Nano Send Example
   
   Hey guys! This example code is designed to send one random 
   integer from one RF Nano to a second RF Nano, to show just how 
   simple the code can be. This code is also compatible with an RF Nano 
   (Arduino Nano with integrated NRF24L01)

   - Matt (ACBR 2020)
   
   Pins for Radio
   1 - GND 
   2 - VCC 5v
   3 - CE - Arduino pin 9
   4 - CSN - Arduino pin 10
   5 - SCK - Arduino pin 13
   6 - MOSI - Arduino pin 11
   7 - MISO - Arduino pin 12
   8 - UNUSED
 */
 
#include &lt;SPI.h&gt;
#include &lt;nRF24L01.h&gt;
#include &lt;RF24.h&gt;
#define CE_PIN   10
#define CSN_PIN 9

const uint64_t pipe = 0x1; // This is the transmit pipeline
int sendData[1];  // One element array holding our random number

RF24 radio(CE_PIN, CSN_PIN); // Activate the Radio

void setup()   
{
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(pipe);
  randomSeed(analogRead(A0));
}


void loop()   
{
  radio.write( sendData, sizeof(sendData));
  sendData[0] = random(10);
  Serial.println(sendData[0]);
}
</code></pre>
<p dir="auto">rf-nano receive sketch:</p>
<pre><code>/* 
  
   RF Nano Receive Example
 
   Hey guys! This example code is designed to send one random integer 
   from one RF Nano to a second RF Nano, to show just how simple the 
   code can be. This code is also compatible with an RF Nano (Arduino 
   Nano with integrated NRF24L01)

   - Matt (ACBR 2020)
   
   1 - GND 
   2 - VCC 3.3V 
   3 - CE - Arduino pin 9
   4 - CSN - Arduino pin 10
   5 - SCK - Arduino pin 13
   6 - MOSI - Arduino pin 11
   7 - MISO - Arduino pin 12
   8 - UNUSED 
*/

#include &lt;SPI.h&gt;
#include &lt;nRF24L01.h&gt;
#include &lt;RF24.h&gt;
#define CE_PIN   10
#define CSN_PIN 9

const uint64_t pipe = 0x1;  // This is the transmit pipe
int sendData[1];  // One element array holding our random number

RF24 radio(CE_PIN, CSN_PIN);

void setup()  
{
  Serial.begin(9600); 
  delay(1000);
  Serial.println("Nrf24L01 Receiver Starting");
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}


void loop()   
{
  if ( radio.available() )
  {
    bool done = false;
    while (!done)
    {
      radio.read(sendData, sizeof(sendData));
      Serial.print("Random Number: ");
      Serial.println(sendData[0]);
      delay(50);
    }
  }
  else
  {    
      Serial.println("Darn, not working yet!");
  }
}
</code></pre>
<p dir="auto">sensor sketch needing modification:</p>
<pre><code>/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools &gt; Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
#define MY_NODE_ID 35
// Enable debug prints
 #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#define CHILD_ID_A0 0
//#define CHILD_ID_A1 1
//#define CHILD_ID_A2 2
#include &lt;MySensors.h&gt;
#include #include &lt;RF24.h&gt;
MyMessage msg(CHILD_ID_A0, V_LEVEL);
//MyMessage msg2(CHILD_ID_A1, V_LEVEL);
//MyMessage msg3(CHILD_ID_A2, V_LEVEL);
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
void presentation()
{
  sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
  present(CHILD_ID_A0, S_MOISTURE);
 // present(CHILD_ID_A1, S_MOISTURE);
 // present(CHILD_ID_A2, S_MOISTURE);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
 int sensorValue = analogRead(A0);
 //int sensorValueA1 = analogRead(A1);
 //int sensorValueA2 = analogRead(A2);
  // print out the value you read:
  Serial.println(sensorValue);
  // Serial.println(sensorValueA1);
  //Serial.println(sensorValueA2);
  send(msg.set(sensorValue));
  // send(msg2.set(sensorValueA1));
 // send(msg3.set(sensorValueA2));
  delay(10000);        // delay in between reads for stability
}
</code></pre>
]]></description><link>https://forum.mysensors.org/topic/11338/help-modifying-sketch-for-rf-nano</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 11:32:33 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/11338.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Aug 2020 15:47:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Help modifying sketch for rf-nano on Tue, 25 Aug 2020 17:18:18 GMT]]></title><description><![CDATA[<p dir="auto">That worked for me. Thank you!</p>
]]></description><link>https://forum.mysensors.org/post/107337</link><guid isPermaLink="true">https://forum.mysensors.org/post/107337</guid><dc:creator><![CDATA[mrhutchinsonmn]]></dc:creator><pubDate>Tue, 25 Aug 2020 17:18:18 GMT</pubDate></item><item><title><![CDATA[Reply to Help modifying sketch for rf-nano on Sun, 23 Aug 2020 16:55:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrhutchinsonmn" aria-label="Profile: mrhutchinsonmn">@<bdi>mrhutchinsonmn</bdi></a></p>
<p dir="auto">In my sketches I had to define the below for the built in radio to even work:<br />
#define MY_RF24_CE_PIN 10<br />
#define MY_RF24_CS_PIN 9</p>
<p dir="auto">Also, I have rf-nano's from 2 sources, the one I got from the first source (don't recall where it was from) doesn't send anything at all, according to the RasPi gateway*), the other 4 (from the 2nd source) just worked™</p>
<p dir="auto">*) the radio initializes just fine, the gateway doesn't see <em>any</em> messages from it at all!...</p>
]]></description><link>https://forum.mysensors.org/post/107290</link><guid isPermaLink="true">https://forum.mysensors.org/post/107290</guid><dc:creator><![CDATA[Fear na Boinne]]></dc:creator><pubDate>Sun, 23 Aug 2020 16:55:53 GMT</pubDate></item><item><title><![CDATA[Reply to Help modifying sketch for rf-nano on Thu, 20 Aug 2020 14:22:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/michiel-van-der-wulp" aria-label="Profile: Michiel-van-der-Wulp">@<bdi>Michiel-van-der-Wulp</bdi></a></p>
<p dir="auto">The sketch looks like this now but does not work with gateway sketch (below). Is that related to code in the mysensors.h library, or do I need to make a change in the serial gateway sketch?</p>
<pre><code>/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools &gt; Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
#define MY_NODE_ID 35
// Enable debug prints
 #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#define CE_PIN   10
#define CSN_PIN 9
#define CHILD_ID_A0 0
//#define CHILD_ID_A1 1
//#define CHILD_ID_A2 2
#include &lt;MySensors.h&gt;
MyMessage msg(CHILD_ID_A0, V_LEVEL);
//MyMessage msg2(CHILD_ID_A1, V_LEVEL);
//MyMessage msg3(CHILD_ID_A2, V_LEVEL);
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
void presentation()
{
  sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
  present(CHILD_ID_A0, S_MOISTURE);
 // present(CHILD_ID_A1, S_MOISTURE);
 // present(CHILD_ID_A2, S_MOISTURE);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
 int sensorValue = analogRead(A0);
 //int sensorValueA1 = analogRead(A1);
 //int sensorValueA2 = analogRead(A2);
  // print out the value you read:
  Serial.println(sensorValue);
  // Serial.println(sensorValueA1);
  //Serial.println(sensorValueA2);
  send(msg.set(sensorValue));
  // send(msg2.set(sensorValueA1));
 // send(msg3.set(sensorValueA2));
  delay(10000);        // delay in between reads for stability
}
</code></pre>
<p dir="auto">Gateway Sketch:</p>
<pre><code>/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools &gt; Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
#define MY_NODE_ID 35
// Enable debug prints
 #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_RF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#define CE_PIN   10
#define CSN_PIN 9
#define CHILD_ID_A0 0
//#define CHILD_ID_A1 1
//#define CHILD_ID_A2 2
#include &lt;MySensors.h&gt;
MyMessage msg(CHILD_ID_A0, V_LEVEL);
//MyMessage msg2(CHILD_ID_A1, V_LEVEL);
//MyMessage msg3(CHILD_ID_A2, V_LEVEL);
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
void presentation()
{
  sendSketchInfo("Analog Soil Moisture Sensorx3", "1c.0");
  present(CHILD_ID_A0, S_MOISTURE);
 // present(CHILD_ID_A1, S_MOISTURE);
 // present(CHILD_ID_A2, S_MOISTURE);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
 int sensorValue = analogRead(A0);
 //int sensorValueA1 = analogRead(A1);
 //int sensorValueA2 = analogRead(A2);
  // print out the value you read:
  Serial.println(sensorValue);
  // Serial.println(sensorValueA1);
  //Serial.println(sensorValueA2);
  send(msg.set(sensorValue));
  // send(msg2.set(sensorValueA1));
 // send(msg3.set(sensorValueA2));
  delay(10000);        // delay in between reads for stability
}
</code></pre>
]]></description><link>https://forum.mysensors.org/post/107219</link><guid isPermaLink="true">https://forum.mysensors.org/post/107219</guid><dc:creator><![CDATA[mrhutchinsonmn]]></dc:creator><pubDate>Thu, 20 Aug 2020 14:22:47 GMT</pubDate></item><item><title><![CDATA[Reply to Help modifying sketch for rf-nano on Thu, 20 Aug 2020 13:55:50 GMT]]></title><description><![CDATA[<p dir="auto">The comments at the top in the first two sketches mention the pin numbers of the CE and CS pins reversed, the code itself is correct.<br />
The third sketch lacks these definitions, so it won't work.</p>
]]></description><link>https://forum.mysensors.org/post/107217</link><guid isPermaLink="true">https://forum.mysensors.org/post/107217</guid><dc:creator><![CDATA[Michiel van der Wulp]]></dc:creator><pubDate>Thu, 20 Aug 2020 13:55:50 GMT</pubDate></item></channel></rss>