Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
I2C_IIC
电流
RTduino添加INA219软件包,使用IIC通信读取数据不正常?
发布于 2024-03-29 10:44:51 浏览:391
订阅该版
BSP路径:rt-thread-master\bsp\stm32\stm32f103-blue-pill 问题描述:  添加软件包INA219 开启IIC硬件    编译仿真程序后测试,发现以下IIC初始化断点处未执行。  list device查看是有IIC总线的  INA219返回数据一直是这个  ```c //arduino_main.cpp代码如下 #include
#include
Adafruit_INA219 ina219; void setup(void) { Serial.begin(115200); while (!Serial) { // will pause Zero, Leonardo, etc until serial console opens delay(1); } Serial.println("Hello!"); // Initialize the INA219. // By default the initialization will use the largest range (32V, 2A). However // you can call a setCalibration function to change this range (see comments). if (! ina219.begin()) { Serial.println("Failed to find INA219 chip"); while (1) { delay(10); } } // To use a slightly lower 32V, 1A range (higher precision on amps): //ina219.setCalibration_32V_1A(); // Or to use a lower 16V, 400mA range (higher precision on volts and amps): //ina219.setCalibration_16V_400mA(); Serial.println("Measuring voltage and current with INA219 ..."); } void loop(void) { float shuntvoltage = 0; float busvoltage = 0; float current_mA = 0; float loadvoltage = 0; float power_mW = 0; shuntvoltage = ina219.getShuntVoltage_mV(); busvoltage = ina219.getBusVoltage_V(); current_mA = ina219.getCurrent_mA(); power_mW = ina219.getPower_mW(); loadvoltage = busvoltage + (shuntvoltage / 1000); Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V"); Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV"); Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V"); Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA"); Serial.print("Power: "); Serial.print(power_mW); Serial.println(" mW"); Serial.println(""); delay(2000); } ```
查看更多
1
个回答
默认排序
按发布时间排序
aozima
2024-03-29
调网络不抓包,调I2C等时序不上逻辑分析仪,就像电工不用万用表!多用整理的好的文字,比截图更省流量,还能在整理过程中思考。
接上逻辑分析仪
撰写答案
登录
注册新账号
关注者
0
被浏览
391
关于作者
aeniac
这家伙很懒,什么也没写!
提问
19
回答
42
被采纳
1
关注TA
发私信
相关问题
1
NXP的I2C应该比ST的好用吧
2
Use of I2C device driver
3
关于I2C 驱动问题请教
4
我如何知道这个iic的io配置和我电路设计的是一致的?
5
I2C模拟读操作失败,不知道问什么进不去读函数
6
RTT的I2C有官方文档资料没有
7
求 STM32F103 IIC 自定义IO初始化 代码
8
报一个LPC4008代码中I2C的bug
9
RTOS IIC总线使用
10
关于在RTT中使用STM32 I2C的疑问
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
6
五分钟玩转RT-Thread新社区
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
RT-Thread BSP支持玄铁全系列RISC-V内核啦
2
ubuntu20搭建rtthead5.2.0开发环境
3
BitsButton嵌入式按键处理框架
4
art-pi2 上手记录(二)
5
VScode + EIDE + STM32cubeMX RT-Thread nano 移植教程MDK版+GCC版
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
Bootloader
AT
Hardfault
CAN总线
ART-Pi
FinSH
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
FAL
RTC
rt-smart
I2C_IIC
UART
cubemx
ESP8266
BSP
ota在线升级
WIZnet_W5500
PWM
packages_软件包
flash
freemodbus
潘多拉开发板_Pandora
GD32
ADC
keil_MDK
定时器
flashDB
编译报错
ulog
socket
rt_mq_消息队列_msg_queue
msh
中断
Debug
SFUD
C++_cpp
at_device
本月问答贡献
出出啊
1524
个答案
343
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
821
个答案
179
次被采纳
crystal266
555
个答案
162
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
1
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
1
次点赞
crystal266
2
篇文章
1
次点赞
whj467467222
2
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部