[SOLVED] STM32F4 +RF24 library problem
41300895 Sun Nov 06, 2016 11:31 am
http://www.stm32duino.com/viewtopic.php … 7&start=30
I think this library also worked well with STM32F4 discovery board, but as soon as I declare
RF24 radio(PA3,PA4)41300895 Sun Nov 06, 2016 11:31 am
RF24 radio(PA3,PA4)Manny Fri Nov 25, 2016 7:02 am
Sorry don’t have a F4 to try out.
41300895 Fri Nov 25, 2016 6:31 pm
zmemw16 Fri Nov 25, 2016 11:35 pm
it shouldn’t be looking there at all, is there a quirk with f4 spi?
stephen
41300895 Sat Nov 26, 2016 3:49 am
zmemw16 Sat Nov 26, 2016 5:41 am
then it gave up with
In file included from /home/stephen/sketchbook/Blinki2c/Blinki2c.ino:19:0:
/home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/libraries/SPI/src/SPI.h:362:17: error: conflicting declaration 'SPIClass SPI'
extern SPIClass SPI;//(1);// dummy params
^
In file included from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/wirish.h:49:0,
from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/WProgram.h:27,
from /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/Arduino.h:3,
from /tmp/arduino_build_22323/sketch/Blinki2c.ino.cpp:1:
/home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/HardwareSPI.h:276:20: error: 'SPI' has a previous declaration as 'HardwareSPI SPI'
extern HardwareSPI SPI;
^
Using library SPI at version 1.0 in folder: /home/stephen/sketchbook/hardware/Arduino_STM32/STM32F4/libraries/SPI
exit status 1
Error compiling for board STM32 Discovery F407.
41300895 Sat Nov 26, 2016 9:56 am
Just simply comment out the line extern HardwareSPI … in your HardwareSPI.h file. If I recall correctly, this file is under …\STM32F4\cores\maple\libmaple
stevestrong Sat Nov 26, 2016 12:04 pm
41300895 Sun Nov 27, 2016 2:36 am
Manny Sun Nov 27, 2016 11:57 am
Comment out all the SPI code in your sketch you just need to #include <SPI.h> and SPI.begin() in set up.
Another thing I noticed is you’re using SPIClass(3) which on the STM32F1 that I’m using shares the pins with JTAG debug, to get round this you will need to put disableDebugPorts() in setup. Not sure if this effects the F4 but it wouldn’t hurt to try it.
disableDebugPorts();
41300895 Sun Nov 27, 2016 1:45 pm
#include<C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\RF24_STM32\RF24_STM32.h>
#include<C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\RF24Network-master\RF24Network.h>
#include <C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\SPI\src\SPI.h>
#include <C:\Users\ASUS\Documents\Arduino\hardware\Arduino_STM32-7985f25fbcb06f7a38f55d84cdf4b0b58e72da11\STM32F4\libraries\DHT-sensor-library-master\DHT.h>;
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
HardwareSerial Myboard(USART1,PB6,PB7);
SPIClass MySPI(1);
// Radio with CE & CSN connected to pins 7 & 8
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;
struct message_1 {
float temperature;
float humidity;
};
message_1 message;
// 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);
// Initialize the DHT library
dht.begin();
// Initialize all radio related modules
MySPI.begin();
radio.setRetries(15,15);
radio.setChannel(0x4c);
radio.setAutoAck(false);
radio.setPayloadSize(sizeof(message));
radio.setCRCLength(RF24_CRC_16);
radio.setPALevel(RF24_PA_MAX);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1,pipes[0]);
radio.begin();
delay(5);
network.begin(90, this_node);
radio.printDetails();
}
void loop() {
// Update network data
network.update();
// Read humidity (percent)
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
// Headers will always be type 1 for this node
// We set it again each loop iteration because fragmentation of the messages might change this between loops
header.type = '1';
// Construct the message we'll send
message = (message_1){ t, h };
digitalWrite(PD13, HIGH);
Myboard.println("HIGH");
delay(1000);
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);
}klerone Tue Mar 28, 2017 2:04 am
Comment out all the SPI code in your sketch you just need to #include <SPI.h> and SPI.begin() in set up.
Another thing I noticed is you’re using SPIClass(3) which on the STM32F1 that I’m using shares the pins with JTAG debug, to get round this you will need to put disableDebugPorts() in setup. Not sure if this effects the F4 but it wouldn’t hurt to try it.
disableDebugPorts();
acronis Thu Jul 27, 2017 8:17 am
How to assign this library to SPI3 ?
A special socket for the nRF24L01 on the Board STM32F407VET6 BLACK
stevestrong Thu Jul 27, 2017 8:27 am
[acronis – Thu Jul 27, 2017 8:17 am] –
How to assign this library to SPI3 ?
SPIClass mSPI(3);
acronis Thu Jul 27, 2017 8:32 am
Please tell me how to fix the following example for SPI3 STM32F407VET6 to work on SPI3
/*
Sensor Receiver.
Each sensor modue has a unique ID.
TMRh20 2014 - Updates to the library allow sleeping both in TX and RX modes:
TX Mode: The radio can be powered down (.9uA current) and the Arduino slept using the watchdog timer
RX Mode: The radio can be left in standby mode (22uA current) and the Arduino slept using an interrupt pin
*/
#include <SPI.h>
#include "nRF24L01_STM32.h"
#include "RF24_STM32.h"
// Set up nRF24L01 radio on SPI-1 bus (MOSI-PA7, MISO-PA6, SCLK-PA5) ... IRQ not used?
RF24 radio(PB0,PB1);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL }; // Radio pipe addresses for the 2 nodes to communicate.
struct payload_t { // Structure of our payload
unsigned long node;
unsigned long counter;
float DHT11temp;
float DHT11hum;
int batteryLevel;
};
void setup(){
Serial.begin(9600);
delay(1000);
Serial.println("\n\rRF24 Sensor Receiver");
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
// Setup and configure rf radio
radio.begin();
// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);
radio.setChannel(0x4c);
radio.setPALevel(RF24_PA_LOW);
// Open pipes to other nodes for communication
// This simple sketch opens two pipes for these two nodes to communicate
// back and forth.
// Open 'our' pipe for writing
// Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1,pipes[0]);
// Start listening
radio.startListening();
// Dump the configuration of the rf unit for debugging
radio.printDetails();
}
void loop(){
payload_t packet;
// Receive each packet, dump it out
if ( radio.available() ) { // if there is data ready
radio.read( &packet, sizeof(packet) ); // Get the payload, and see if this was the last one.
Serial.print("Received from Sensor: "); Serial.print(packet.node);
Serial.print(" #:"); Serial.println(packet.counter);
Serial.print("DHT11 Temp = "); Serial.print(packet.DHT11temp);
Serial.print(" DHT11 Humidity = "); Serial.print(packet.DHT11hum);
Serial.print(" Batt = "); Serial.println((float)packet.batteryLevel/(float)266.7);
}
}
stevestrong Thu Jul 27, 2017 8:48 am
acronis Thu Jul 27, 2017 9:02 am
RF24 radio(PB0,PB1);
In the examples written by different pins .
What should I specify ?
RF24 radio(CE_PIN, CSN_PIN); ???
RF24 radio(PB6, PB7 );
So right ?
stevestrong Thu Jul 27, 2017 9:50 am
[acronis – Thu Jul 27, 2017 9:02 am] –
RF24 radio(CE_PIN, CSN_PIN); ???
RF24 radio(PB6, PB7 );
So right ?
It seems so.
Btw, have you seen this lib? https://github.com/jaretburkett/RF24-STM
acronis Sat Jul 29, 2017 1:47 pm
This library works on STM32F407VET6.
Thank you all.
the question is closed
RogerClark Sat Jul 29, 2017 10:03 pm
acronis Sun Jul 30, 2017 2:04 am
It’s not my topic and not my first post,
I don’t know how to add a message.
Tell me what you need and how to do it.