sandeepmistry / arduino-nRF5

Arduino Core for Nordic Semiconductor nRF5 based boards
Other
873 stars 278 forks source link

setPins undeclared ? #440

Open Entretoize opened 3 years ago

Entretoize commented 3 years ago

I read that it is possible to set the pins for I2C with the setPins method however when I try to do Wire.setPins(1,2) the compiler returns an error because it's not defined. I don't see how to know which version is used nor how to update.

pvonmoradi commented 3 years ago

Similar issue for Serial:

src/main.cpp: In function 'void setup()':
src/main.cpp:6:12: error: 'class Uart' has no member named 'setPins'
     Serial.setPins(PIN_SERIAL_RX, PIN_SERIAL_TX);
#include "Arduino.h"
/* #include "Uart.h" */
#include "variant.h"

void setup() {
    Serial.setPins(PIN_SERIAL_RX, PIN_SERIAL_TX);
    Serial.begin(115200);
    Serial.println("Hi from nRF52832!");
}

edit: seems like we need to put "-DARDUINO_GENERIC" somewhere in makefile

KEranda commented 3 years ago

I had the same question a while ago and managed to find a solution after reading another issue/merge request (#213 and #221) submitted for this core. You can read this for more info but in general:

If you're using the nRF52DK the I2C pins are 'hardcoded' by Sandeep's code to be P0.26 (SDA) and P0.27 (SCL) so all you need to do is connect you sensor to those pins and call "Wire.begin();"

If you have selected a "Generic nRF52"board in the tools menu of the Arduino IDE you can then call "Wire.setPins(SDA, SCL);" with the pins you want to use before you call "Wire.begin();"

Hopefully it helps.

Entretoize commented 3 years ago

Thank you I will check.

jLynx commented 3 years ago

This solves the issue I had with Serial. Thanks @KEranda