Please help!!! STM32F4 +RF24 library problem

Limited support for STM32F4 Discovery, Nucleo and custom F4 boards
zmemw16
Posts: 1262
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Post by zmemw16 » Sat Nov 12, 2016 12:43 pm

41300895 wrote:NOW this is getting weird now, after hours of editing, I realized the line" network.update() makes my code stuck because the pd13 led always ON. If I remove it, the PD13 led blinks normally.
when i'm using blinky, i find it useful to make high/low timing asymmetric 100/1000, 1000/100 etc
quite useful if you don't know the led is driven, it also confirms the target has been written too as well.

please post a link to the board, i have a couple of 407 boards with nrf24 connectors, more importantly i have at least partial schematics for one :-)

i'd suggest removing any dht bits, reduce it to the basics /* */ & // are your friends
use millis() to provide something as data to write to the radio.

stephen

zmemw16
Posts: 1262
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Post by zmemw16 » Sun Nov 13, 2016 7:37 am

zmemw16 wrote:
41300895 wrote:NOW this is getting weird now, after hours of editing, I realized the line" network.update() makes my code stuck because the pd13 led always ON. If I remove it, the PD13 led blinks normally.
when i'm using blinky, i find it useful to make high/low timing asymmetric 100/1000, 1000/100 etc
quite useful if you don't know <how> the led is driven, it also confirms the target has been written too as well.

please post a link to the board, i have a couple of 407 boards with nrf24 connectors, more importantly i have at least partial schematics for one :-)

i'd suggest removing any dht bits, reduce it to the basics /* */ & // are your friends
use millis() to provide something as data to write to the radio.

stephen

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by 41300895 » Sun Nov 13, 2016 9:44 am

https://www.google.com.vn/search?q=stm3 ... KflCetM%3A
This is exactly my board,I'll try your suggestion, glad that you answered me,
Thanks
EDIT: what do you mean by "use millis() to provide something as data to write to the radio."? Can you write down the specific command to implement what you said?

zmemw16
Posts: 1262
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Post by zmemw16 » Sun Nov 13, 2016 8:52 pm

well the schematic isn't going to be a problem to find. its in the user guide :D

the logic behind removing the dht aspects and using millis is building blocks is that millis is a known and easily testable function, Serial.println(millis());
removing the dht aspect temporarily is to remove a potential problem. solve that by using their example as a test of dht.

using millis you can just create a packet structure with counter and millis as long int fields.
the dht example code i think converts the values to an ascii string for printing, but you could send the raw values as a field.
there's getting started sending data example from rf24, essentially using notionally 'good' code.
combine the two sketches as a third and adapt.

a long time ago, my maths teacher was happy i was 3, 4 or 5 chapters worth ahead in the exercises, but not that everyone else got the same solutions.
mind you, he objected when i worked each side of 'prove this equals that trig equation' exercises. one forward, other backward until they met, 1==1 or 1 == 0 oops. i still don't follow why.

stephen

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by 41300895 » Mon Nov 14, 2016 2:45 pm

Still no luck :(
Now things are totally a mess, I hope anyone could help me write a code to transmit/receive data using nrf24l01 with stm32f4 discovery . Because there are so many conflicts in using the libraries provided by previous authors in this forum

zmemw16
Posts: 1262
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Please help!!! STM32F4 +RF24 library problem

Post by zmemw16 » Mon Nov 14, 2016 3:10 pm

pretty sure i've a 407 discovery somewhere .. ..
i'll go looking for it

stephen

User avatar
Manny
Posts: 29
Joined: Wed Dec 09, 2015 3:15 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by Manny » Mon Nov 14, 2016 6:03 pm

I use this RF24 library that was attached to this post RF24_STM32 with RF24Network from Here I think it needed some minor commenting out to get it to compile.

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by 41300895 » Wed Nov 23, 2016 5:44 am

thanks for your both dedication!
Hey Manny, can you show me specifically how can I get it work?

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by 41300895 » Wed Nov 23, 2016 3:42 pm

I've managed to get things better a little bit!
Here's what I did:
+ Commented out network.update(), because this line makes my code stuck!
+ I used the SPI library from here : https://github.com/rogerclarkmelbourne/Arduino_STM32 (in STM32F4/libraries/SPI) - I cut and paste it in the path: C:\Users\ASUS\Documents\Arduino\libraries\
+ I used the DHT library from here: https://github.com/markruys/arduino-DHT
+ And the RF24Network library from here: https://github.com/maniacbug/RF24Network
+ The RF24 library from here: http://www.stm32duino.com/viewtopic.php ... =30#p11251 (the last comment of this link)
My code now:

Code: Select all

#include "nRF24L01.h"
#include <RF24Network.h>
#include <RF24.h>
#include <C:\Users\ASUS\Documents\Arduino\libraries\SPI\src\SPI.h>
#include "DHT.h";
DHT dht;
HardwareSerial Myboard(USART1,PB6,PB7);
// Set up nRF24L01 radio on SPI-1 bus (MOSI-PA7, MISO-PA6, SCLK-PA5) ... IRQ not used?
RF24 radio(PB0,PB1);
RF24Network network(radio);
const uint64_t pipes[2] = {0xCCCCCCCC3C, 0xCCCCCCCCC3};   // Radio pipe addresses for the 2 nodes to communicate.
// Constants that identify this node and the node to send data to
const uint16_t this_node = 1;
const uint16_t parent_node = 0;
// The network header initialized for this node
RF24NetworkHeader header(parent_node);
void setup() {
  // put your setup code here, to run once:
  pinMode(PD13, OUTPUT);
  Myboard.begin(115200);
  dht.setup(PC0); 
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  radio.begin();
  network.begin(90, this_node);
  radio.setRetries(15,15);
  radio.setChannel(0x4c);
  radio.setAutoAck(false);
  radio.setDataRate(RF24_1MBPS);
  radio.setCRCLength(RF24_CRC_16);
  radio.setPALevel(RF24_PA_MAX);
  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1,pipes[0]);
  radio.printDetails();   

}
void loop() {
 // Update network data
   //network.update();
  delay(dht.getMinimumSamplingPeriod());
  float h = dht.getHumidity();
  float t = dht.getTemperature();
  header.type = '1';
 // Construct the message we'll send
struct message_1 {
  float temperature;
  float humidity;
};
message_1 message;
   radio.setPayloadSize(sizeof(message)); 
   message = (message_1){ t, h };
    digitalWrite(PD13, HIGH);
    Myboard.println("HIGH");
    delay(1000);
    radio.powerUp();
    delay(1);
    radio.stopListening();
    delay(1);
    bool ok = network.write(header,&message,sizeof(message));
        if (ok)
      Myboard.println("Send Ok.");
    else
      Myboard.println("Send Failed.");
    digitalWrite(PD13, LOW);
    Myboard.println("LOW");
    delay(1000);
}
Here is the result of radio.printDetails:

Code: Select all

RF_SETUP= 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
CONFIG= 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
DYNPD/FEATURE= 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN
HIGH
Send Failed.
LOW
HIGH
Send Failed.
LOW
It seems that my module didn't response correctly, any help? Please :cry:
EDIT: My led is blinking really fine now !

User avatar
Manny
Posts: 29
Joined: Wed Dec 09, 2015 3:15 pm

Re: Please help!!! STM32F4 +RF24 library problem

Post by Manny » Thu Nov 24, 2016 5:18 pm

This is what radio.printdetails outputs on my STM32F1

Code: Select all

STATUS = 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	= 0xCC 0xCC 0xCC 0x3C 0xCC 0xCC 0xCC 0xCC 0x3C 0x3C 
RX_ADDR_P2-5	= 0x33 0xCE 0x3E 0xE3 
TX_ADDR		= 0xE7 0xE7 0xE7 0xE7 0xE7 
RX_PW_P0-6	= 0x20 0x20 0x20 0x20 0x20 0x20 
EN_AA		= 0x3E 
EN_RXADDR	= 0x3F 
RF_CH		= 0x3C 
RF_SETUP	= 0x27 
CONFIG		= 0x0F 
DYNPD/FEATURE	= 0x3F 0x04 
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

Post Reply

Who is online

Users browsing this forum: Lennyz1988 and 1 guest