Wireless Recommendations for bike communication? NRF24L01+ and Teensy LC

Hello,

Topic Sentence:
I'm trying to create a battery-powered wireless version of some of the hardware on my bike.

Project Background:
The end goal is to have a control panel on the handlebars with two buttons to actuate a dropper post and actuate the rear suspension lockout. I want to do it wirelessly, but can't decide between whether to use bluetooth , BLE, or wifi. I also need some guidance on handling the battery level.

Current Research:
Currently, I've looked into the ESP32, Sparkfun bluesmirf, and the beetle BLE. Here are the requirements of each module.

System Requirements:
Module 1 - the handlebar mount

  1. Wireless connection to multiple devices (up to 250mS delay is OK)
  2. 2 GPIO (1 mandatory, 1 optional)
  3. Small size (mandatory)
  4. Ability to drive tiny LCD or OLED (optional)

Module 2 and 3 - These drive the dropper post and suspension lockout via servo

  1. Wireless connections to module 1 (mandatory)
  2. 1 digital output for LED to indicate status (optional)
  3. 1 PWM capable pin to drive the servo (mandatory)
  4. Small size (preferred)

Additionally, for the power, I would love for each module to be USB chargeable that can charge a 1s Lipo battery, while shutting off when the battery is dead. Something like both of these modules in 1 pcb: SparkFun LiPo Charger Basic - Micro-USB - PRT-10217 - SparkFun Electronics
and
Tenergy PCB for 3.6V/3.7V 1.5A Li-ion Battery Pack - Tenergy

If you all know of any modules that would be able to accomplish these tasks, I'm all ears. I'm comfortable with the Arduino IDE and have used the bluesmirf AT command set before, but willing to learn new things.

My Research:
I have researched for existing products, and this is the only ones I found:
Wireless shifting:
https://www.kickstarter.com/projects/1598276649/xshifter-worlds-first-universal-wireless-smart-shi

Magura dropper post (seems to support a fork and damper too):

My programming experience:
I'm a mechanical engineering student with a focus in automated testing. I am comfortable with c++, arduino coding, lua, labview and matlab. I'm happy to learn python if needed.

Thanks for the help.

edit: Added topic sentences and reformatted to follow forum rules.

If you just want wireless communication from one part of your bike to another part of the same bike then I reckon a pair of nRF24L01+ modules would be simple and effective. See this Simple nRF24L01+ Tutorial.

However I would not consider a wireless solution to be as reliable as a wired solution.

...R

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .

Can you tell us your electronics, programming, arduino, hardware experience?

Why wireless if all on the same bike?
What sort of bike?
How do you aim to actuate dropper post and actuate the rear suspension lockout (what ever they are?)?

The actuators will need power as well.

Thanks.. Tom... :slight_smile:

Robin2:
If you just want wireless communication from one part of your bike to another part of the same bike then I reckon a pair of nRF24L01+ modules would be simple and effective. See this Simple nRF24L01+ Tutorial.

However I would not consider a wireless solution to be as reliable as a wired solution.

...R

Yes, although it on the same bike, the cable routing for my dropper post was not designed well for the bike. When I actuate the dropper post, the cable will bend and hit the rear tire. Thus, wireless will remove that issue for the dropper. The rear lockout is really hard to reach with a water bottle installed, especially during a race. Thankyou for the module recommendation. Would a teensy LC be able to drive that module and a teensyview SPI oled? Pins 11 and 13 are fixed for SPI and I'm not sure if I'd be able to use 2x spi devices?
https://learn.sparkfun.com/tutorials/teensyview-hookup-guide?_ga=2.162393791.202408942.1547795943-1154537582.1544491553

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .

Can you tell us your electronics, programming, arduino, hardware experience?

Why wireless if all on the same bike?
What sort of bike?
How do you aim to actuate dropper post and actuate the rear suspension lockout (what ever they are?)?

The actuators will need power as well.

Thanks.. Tom... :slight_smile:

Tom,
Thank you for the reply. I cleaned up my first post to follow the guidelines, but will be adding all new info here as specified by the guidelines.

Electronics and programming experience: I'm familiar with c++ and arduino having already done a few projects including a car backup sensor with LCD, an electric bike throttle with LCD, and airplane variometer. I'm also familiar with LabView, matlab. I've taken a circuits course at school, but am not that familiar with transistors, opamps, and mosfets.

Why wireless? I want to go wireless because the dropper cable gets in the way of the wheel (it's not well routed because the bike was made before dropper posts were big. The rear suspension lockout is difficult to reach while riding and nearly impossible with a water bottle in the cage.

What bike? It's a 2015 Niner Jet 9 full suspension mountain bike.

How to actuate? The dropper post and suspension will each be actuated with a 12g analog servo. In my first post there is information on what a dropper post is. The rear lockout essentially sets the rear suspension to be locked from moving; it's good for climbing hills.

The servo actuators will be powered off the same lithium ion 21700 cell. It should last a few hours depending on how many times I actuate. The servos work on 1s power.

ryanf55:
What bike? It's a 2015 Niner Jet 9 full suspension mountain bike.

I suspect Robin2 was concerned about it being a bike with an engine. :grinning:

ryanf55:
Would a teensy LC be able to drive that module

You don't need anything as complex as a teensy to drive an nR24. A nano would be fine.

...R

Ok. I'll attempt to use SPI on both devices for "module 1". I didn't realize it was possible till I saw this tutorial. How to Connect Multiple SPI devices to an Arduino Microcontroller

Also, I like using teensy LC over nano because it's available from my local retailer (sparkfun) and only 61% the board area of the nano, and only $10. Why would you suggest the nano?

For more information, I've attached some pictures of the bike.

Also, for modules #2 and #3, would anyone caution against using a smaller microcontroller such as the adafruit trinket? It supports SPI for the NRF24L01+.

Also, for those curious, this tutorial includes a demo on hooking up a network of nrf24L01+ to control servos; conveniently, this is pretty much exactly what I'm doing aside from the battery power too.

Here are the pictures (as a separate post). I've highlighted some key areas of interest for your reference.

Handlebars.jpg

ryanf55:
Also, I like using teensy LC over nano because it's available from my local retailer (sparkfun) and only 61% the board area of the Nano, and only $10. Why would you suggest the Nano?

One third of the price, but otherwise the Teensy is fine.

ryanf55:
Why would you suggest the nano?

I think it is cheaper than the Teensy and because it uses the Atmega328 that is also in the Uno there will be many more people on the Fourm with relevant programming experience.

I'm sure there is nothing technically wrong with the choice of a Teensy.

If small size is important I've built this combination of nRF24 and Attiny 1634 or radio control of model trains. The Attiny84 also works (and makes the soldering easier), but it does not have as many I/O pins. Or, if you are not quite so tight for space you could use an Atmega 328.

...R

I just realized I forgot to mention that you could use a pair of ESP8266 modules using the ESP-NOW feature. I believe it works with the WemosD1 boards

I don't use them for my model trains because they consume more electricity and my batteries are very small.

...R

Robin2,

Thanks for all the insight. I didn't realize how cheap the nano had become; since I only need SPI and 1 or 2 digital outputs on modules #2 and #3, a very small board should work. I'll decide tonight.

I'm a bit concerned using the ATTiny 85 because of the USB issues attiny85 usb issues - Google Search

"Deprecation Warning: The Pro Trinket bit-bang USB technique it uses doesn't work as well as it did in 2014, many modern computers won't work well. So while we still carry the Pro Trinket so that people can maintain some older projets, we no longer recommend it. Please check out the Metro Mini (ATmega328 @ 5V 16 MHz), ItsyBitsy 32u4 5V 16MHz, ItsyBitsy 32u4 @ 3.3V 8MHz or ItsyBitsy M0 @ 3V 48MHz. All have built-in USB and are comparable in price! The ItsyBitsy's especially are about the same size and have native USB and tons of pins, so they're a very close compatible"

in the grand scheme of things, the nano has a perfectly fine form factor compared to the 21700 LiIon cells (70 mm length, 21 mm diameter).

I did also look into the ESP32 or ESP8266, but you are right about power issues. The less energy my devices use the better. I'm surprised no one has recommended anything about BLE, but I guess there's multiple ways to skin the cat. I just found 10x nRF24L01+ for $12 with 3 day shipping, so I'll go with those.

Initial mounts for the servo have been sent to the printer; I'll add to the post as the build progresses. I also just ordered some adafruit li-ion USB chargers. I will be able to put all the electronics in a very low power standby mode when the bike is idle.

PS: Not sure if you have used the Teensy but is uses arduino development environment and pins are mapped similar to an arduino pro micro,but it also has more hardware UART support for fast baud rates. I just started working with them 2 weeks ago and love it.

ryanf55:
I'm a bit concerned using the ATTiny 85 because of the USB issues

I didn't mention the 85 - I have not used it. I use ISP programming for my Attinys. I have an Atmega 328 on a breadboard set up as an ISP programmer.

Battery life will be considerably better if you run the MCU at 8MHz and that also allows you to operate at about 3v directly from the battery. Voltage regulators waste energy. A pair of AA alkaline cells work fine. I have some Attiny / nRF24s running off a 1S LiPo (3.7v) using a 1n4001 diode to drop the voltage to the nRF24.

...R

Hello Robin,

Many thanks for the recommendations. I looked around and decided upon the Teensy LC because with shipping it was cheapest and an OK size.

I have succesfully followed your guide on NRF24L01+ hookup with two Uno's, however it does not work on the Teensy LC with the same pins.

Symptom:
I am running your example code with the Teensy as the transmitter; it gets hung up in the main loop executing the send() function. I believe it's in radio.write().

I have spent a few hours troubleshooting with no luck. So far, I have tried

  1. Addinga 33uF capacitor to 3.3V supply for the NRF24L01+ module. I checked it on the scope and the supply is very smooth and at 3.35V.
  2. Running RF24 library "gettingStarted" example code with the power amplifier at its lowest setting.
  3. Setting SPI clock divider to SPI.setClockDivider( SPI_CLOCK_DIV32 );

I then ran your checkConnection program (below) with the following result:

Your Supplied Code with pins 9/10 as CE and CSN:

{
// 18 Mar 2018 - simple program to verify connection between Arduino
//      and nRF24L01+
//  This program does NOT attempt any communication with another nRF24

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#include <printf.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;


void setup() {
    Serial.begin(9600);
    printf_begin();

    Serial.println("CheckConnection Starting");
    Serial.println();
    Serial.println("FIRST WITH THE DEFAULT ADDRESSES after power on");
    Serial.println("  Note that RF24 does NOT reset when Arduino resets - only when power is removed");
    Serial.println("  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not");
    Serial.println("     communicating with the nRF24");
    Serial.println();
    radio.begin();
    radio.printDetails();
    Serial.println();
    Serial.println();
    Serial.println("AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1");
    Serial.println(" and 250KBPS data rate");
    Serial.println();
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.setDataRate( RF24_250KBPS );
    radio.printDetails();
    Serial.println();
    Serial.println();
}


void loop() {

}}

Terminal Result after running CheckConnection:

{CheckConnection Starting

FIRST WITH THE DEFAULT ADDRESSES after power on
  Note that RF24 does NOT reset when Arduino resets - only when power is removed
  If the numbers are mostly 0x00 or 0xff it means that the Arduino is not
     communicating with the nRF24

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0xe7e7e7e7e7
RX_PW_P0-6	 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
EN_RXADDR	 = 0x03
RF_CH		 = 0x4c
RF_SETUP	 = 0x07
CONFIG		 = 0x0e
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01+
CRC Length	 = 16 bits
PA Power	 = PA_MAX


AND NOW WITH ADDRESS AAAxR  0x41 41 41 78 52   ON P1
 and 250KBPS data rate

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0xe7e7e7e7e7 0x4141417852
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0xe7e7e7e7e7
RX_PW_P0-6	 = 0x00 0x20 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
EN_RXADDR	 = 0x03
RF_CH		 = 0x4c
RF_SETUP	 = 0x27
CONFIG		 = 0x0e
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 250KBPS
Model		 = nRF24L01+
CRC Length	 = 16 bits
PA Power	 = PA_MAX
}

Related Threads:

Let me know if you have any further things I can try.

Have you measured how much force it takes to operate the dropper or suspension lockout?
Not all servos are going to be able to do something that takes a lot of force.

ryanf55:
I have succesfully followed your guide on NRF24L01+ hookup with two Uno's, however it does not work on the Teensy LC with the same pins.

What microprocessor is on the Teensy LC ?

...R

Hello,

Yes Vince I have tested it with an EMAX 12g servo; it has enough power while operating on 3.7V. I put the cable on the closest position to the servo axis to maximum mechanical advantage. The servos will take a majority of the power consumption, however with a single 5000mAh Samsung lithium ion, I should get a few hours of run-time.

Robin,

The Teensy LC uses a ARM Cortex-M0+ processor at 48 MHz with 62K Flash and 8K RAM.

Here's another thread I found...

ryanf55:
The Teensy LC uses a ARM Cortex-M0+ processor at 48 MHz with 62K Flash and 8K RAM.

Then you need to figure out what are the appropriate pins for SPI using that microprocessor. I have no experience of it.

(By way of a parallel, the Arduino Mega has different SPI pins from an Uno)

...R

Robin2:
Then you need to figure out what are the appropriate pins for SPI using that microprocessor. I have no experience of it.

(By way of a parallel, the Arduino Mega has different SPI pins from an Uno)

...R

I have used a Teensy on with a SPI Nokia Display before. The pins were the same between an Uno and the Teensy LC.

I've attached a wiring diagram.

edit: Here's a link to some high resolutions pictures of the Teensy LC and NRF24L01+ soldered together if you want to check the physical connections.

https://drive.google.com/drive/folders/1S7xPdVb6d8euXrIPymdLpqYAl2xmX4i9?usp=sharing

I reflowed it once already with the iron.

Next steps:
Investigate SPI wiring error possibility
Investigate SPI speed code issue
Try swapping hardware with another teensy and another NRF module
Hook up a logic analyzer to the NRF module to see any obvious errors (I am borrowing one from a friend for a different project).

Many thanks for the help thus far; I can't wait to figure out this issue. I owe you all some beers!