Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding I2C to JHEMCU Play F4 (for Baro, Nanolongrange)
#1
Hi everyone, I have a Jhemcu play F4 which i am trying to add a barometer to (yes, the ever popular nano-longrange fad Rolleyes )
I found a few tips on how to add I2C devices, but of course nothing for this particular FC. I figured the process should be like this:

1. Determine which pins can be used for I2C on this CPU (STM32F411CEU6). According to the datasheets

I2C #1 can use PB6 or PB8 for SCL, PB7 or PB9 for SDA
I2C #2 can use PB10 for SCL, PB9 or PB3 for SDA
I2C #3 can use PA8 for SCL and PB4 for SDA

Of those available pins, only I2C #2 PB9 and PB10 were available on this board, others assigned to various functions. Is that the correct way of looking at it? (The betaflight I2C tutorial i found online just said "refer to your board's pinout")

2. Then take a deep breath, and solder some enamel wires to those pins on the FC (which i somehow managed to do).
   

3. Now, enable the pins in CLI:

Code:
resource PPM 1 NONE
resource I2C_SCL 2 B10
resource I2C_SDA 2 B09
set baro_i2c_device = 2
set baro_i2c_address = 118
set baro_hardware = BMP280

(PPM 1 was set to B10 originally)

4. Finally, solder up a 5V BMP280 (https://www.aliexpress.com/item/32817286611.html?)... Is this where i stuffed up? Should this be the 3.3v version? No Barometer detected in Betaflight, but Status CLI returns "i2c errors: 0"

Does anyone have any experience with this, can you tell me if my process was wrong here? I hope my pin selection is correct because i now have a glob of E6000 over the wires for strain relief...
Reply
Login to remove this ad | Register Here
#2
Just realised i hadnt set baro_spi_device = 0... but changing that didnt solve it. Diff All is as follows, dump is attached:

Code:


# diff all

# version
# Betaflight / STM32F411 (S411) 4.2.9 Apr 27 2021 / 19:33:23 (e097f4ab7) MSP API: 1.43
# config: manufacturer_id: AIRB, board_name: NOX, version: ce988aa0, date: 2019-10-19T07:28:43Z

# start the command batch
batch start

# reset configuration to default settings
defaults nosave

board_name NOX
manufacturer_id AIRB
mcu_id 003b004b3439511036383737
signature 

# name: Explorer F4

# resources
resource PPM 1 NONE
resource LED_STRIP 1 NONE
resource SERIAL_TX 2 A02
resource SERIAL_TX 11 A00
resource SERIAL_RX 11 NONE
resource I2C_SCL 2 B10
resource I2C_SDA 2 B09

# feature
feature -ESC_SENSOR
feature GPS
feature TELEMETRY

# beeper
beeper -GYRO_CALIBRATED
beeper -DISARMING
beeper -ARMING
beeper -ARMING_GPS_FIX
beeper -BAT_CRIT_LOW
beeper -BAT_LOW
beeper -GPS_STATUS
beeper -ACC_CALIBRATION
beeper -ACC_CALIBRATION_FAIL
beeper -DISARM_REPEAT
beeper -ARMED
beeper -ON_USB
beeper -BLACKBOX_ERASE
beeper -CRASH_FLIP

# beacon
beacon RX_LOST

# serial
serial 0 2 115200 57600 0 115200
serial 30 8192 115200 57600 0 115200

# master
set baro_spi_device = 0
set baro_i2c_device = 2
set baro_hardware = BMP280
set serialrx_provider = CRSF
set dshot_bidir = ON
set motor_pwm_protocol = DSHOT300
set motor_poles = 12
set vbat_max_cell_voltage = 440
set vbat_warning_cell_voltage = 300
set current_meter = ADC
set battery_meter = ADC
set beeper_dshot_beacon_tone = 3
set small_angle = 180
set gps_sbas_mode = MSAS
set gps_auto_config = OFF
set gps_set_home_point_once = ON
set pid_process_denom = 4
set name = Explorer F4

profile 0

profile 1

profile 2

# restore original profile selection
profile 0

rateprofile 0

rateprofile 1

rateprofile 2

rateprofile 3

rateprofile 4

rateprofile 5

# restore original rateprofile selection
rateprofile 0

# save configuration
save


Attached Files
.txt   BTFL_cli_play_f4_baroi2c.txt (Size: 35.09 KB / Downloads: 69)
Reply
#3
Try
Code:
set baro_i2c_address = 0
save
to use the default I2C address.

Are there pull-up resistors on the barometer board?
Reply
#4
Thanks, i just tried setting address to zero, no luck unfortunately.

Regarding the pull up resistors... i'm not sure!
   
There is that weird 1k resistor (4 in 1?) on the bottom, not sure if thats the pull up

I'm mainly concerned about the voltage... I just checked GND/SDA and GND/SCL and there is 5v on those pins, which seems a bit much for the MCU?
Reply
#5
I think that 4-in-1 is the pull up resistors.
From what i can make out, the underside of this module has the 3.3v LDO, and possibly a two channel mosfet?

I just checked, and PB9 and PB10 are both 5v tolerant (phew)

But it means something else is stopping this from working.

Maybe an LED on each of those pins, controlled by a Box IO to at least see if the pins are correct? Havent done that before, just clutching at straws
Reply
#6
Check the resistance between SDA/SCL and the Vcc pad on the mag. If it's not somewhere in the 1k-5k ohm range, you may need pull up resistors.

Edit: I just found two more issues, you have baro_bustype set to SPI, and there is a resource conflict with ESCSERIAL.

Try:
Code:
set baro_bustype = I2C
resource ESCSERIAL 1 none
resource PULLUP 1 B09
resource PULLUP 2 B10
save
Reply
#7
So far no luck. Adding resource PULLUP gave me an I2C error where previously i had 0. Its a step forward perhaps?

I have taken everything else off B10 (PPM, ESCSERIAL, timer, dma pin), still no luck

Adding the PULLUP resources let me measure 3.3v out of my enamel wires, so i am quite certain they are connected to the MCU pins correctly

I have tried adding physical 1k pull up resistors on SDA/SCL.


Another possibility is just a bad module. Or possibly an issue with supplying 5v on those pins (they are 5v tolerant though... Is that "we will tolerate you but we still dont accept you as our friend"? or "we can handle all that high voltage you are throwing at us, lets be friends!"?)
Reply
#8
You are lucky, I have gone through 5 of those FCs and have sworn them off due to high failure rates..
RDQ still stocks them, they said even with them failing some people like them... @25 a pop, it’s a bargain AND it’s 2s capable..I see why. I just feel REAL bad getting one, either having a bad esc, no osd, or just doa.... contacting customer service ...and they were from different suppliers..
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  RX Adding SBUS in to Frsky D16 protocol receivers Jakeofall 0 538 20-Mar-2023, 05:39 PM
Last Post: Jakeofall
  Adding rates/profiles to OSD is a good thing Rob Axel 0 651 09-Apr-2021, 01:18 PM
Last Post: Rob Axel
  Tutorial Adding Adressable RGB LEDs and Betaflight Setup Video Drone0fPrey 5 2,452 23-Jun-2018, 06:51 PM
Last Post: Drone0fPrey
  Goggles Adding a on/off button to FPV Goggles Oscar 8 3,938 30-May-2017, 02:43 PM
Last Post: Oscar
  FC X-Racer F3 FC - Adding VBAT Hack Oscar 6 7,332 07-Mar-2016, 05:29 AM
Last Post: Relic


Login to remove this ad | Register Here