Asset Tracker v2 + BLE

Hey guys!

I’m trying to connect my Electron + Asset Tracker v2 to BLE Grove device (http://wiki.seeedstudio.com/Grove-BLE-dual_model-v1.0/) over Grove Sensor port (A0, A1 pins).

On a software side I’ve tried to combine https://github.com/ScruffR/ParticleSoftSerial/blob/master/examples/PSS_SimpleTest/PSS_SimpleTest.ino and https://github.com/Seeed-Studio/HM_13_SW/blob/master/HM_13_SW.ino to make it work, but unfortunately connection doesn’t get through.

This is my resulting code: https://gist.github.com/maximgladkov/cbd7841377d4f17b0c92463972a556cc

The general quetion is: is it even possible to connect them via A0, A1 (Grove port) and if not, what should I do about it?

Thank you!

@mgladkov, it should be possible using @ScruffR’s software serial code though I am not sure which pins are RX and TX on the shield. You could try flipping them in your code.

I noticed that you are not “priming” the BLE board by sending an “AT” command after you set the board rate. This allows the board to auto-set it’s baud rate and ensures the device is responding.

2 Likes

The only prerequisite for ParticleSoftSerial to work correctly is that the RX pin needs to be interrupt-capable.
With A0 as RX pin this would need D2 to not use interrupts concurrently.
With A1 as RX pin this would need A3 to not use interrupts concurrently.

1 Like

Thank you, guys @peekay123 and @ScruffR!

I’m pretty new to electronics and might not understand that correctly.

What I’m trying to do is connect BLE Grove Device to Electron Asset Tracker v2 device with Grove sensor port that exposes A0 and A1 pins.

Documentation says that Asset Tracker itself uses RX/TX pins to connect to Electron. I’m not using any other pins only those Electron uses to communicate with Asset Tracker.

Am I doing something wrong?

I’ve not tried to connect to SCL, SDA on Asset Tracker v2 because I’d like to connect an NCD 1 Channel relay board to that port that support I2C.

Have you tried swapping the RX/TX pins around as @peekay123 has suggested?

The Grove BLE v1 Wiki suggests that you need to connect RX on the board to TX on the controller and vice versa.

Notice TX->D2/RX->D3 and in code

    #define RxD 2
    #define TxD 3

So D2 is the RxD pin on the controller and D3 the TxD which makes the wring TX -> RxD and RX -> TxD.
Consequently I'd think your code would need to be

#define PSS_RX A0 // not A1 as in your original code
#define PSS_TX A1 // not A0 as in your original code
ParticleSoftSerial SoftSer(PSS_RX, PSS_TX); 
1 Like

I think I’ve tried everything already:

  1. Tried sending “AT” command right after setting rate.
  2. Tried swapping the RX/TX pins in the code.
  3. Tried using SCL/SDA pins with SoftSerial.
  4. Tried to use C2/C3 pins with Serial4 (Electron’s additional serial pins).

And I’m getting nothing back. BUT, if I wire RX to TX on the same board, I get the command I’m sending back, so it looks like Electron has these pins working correctly.

Do you have any other suggestions? Maybe some direction I could be taking in debugging this?

Seems the default baudrate is 115Kbaud so you can’t use the software serial library. You will need to connect to a hardware serial port on the Electron directly and modify your software accordingly.

Not sure about 115200 baud rate tho'

And you can also set the startup baudrate to be stored permanently for next bootup.

But since we don't even know wheter or not the board works at all, I'd suggest you start with Serial1 on the default RX/TX pins on the Electron without the AssetTracker Shield.
Once you got the BLE board working with that you can move to ParticleSoftSerial, and after that re-introduce the AssetTracker Shield.

1 Like

@ScruffR thank you very very much! Your suggestion helped me a lot.

I disconnected Asset Tracker from Electron, connected BLE device to RX/TX pins and used Serial1. Everything worked great!

Then I connected BLE device to C2/C3 and used Serial4 and everything was still working.

So I connected Asset Tracker back and got a working device.

So thank you very much for your help!

2 Likes