• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
MKT-porter
博客园    首页    新随笔    联系   管理    订阅  订阅
(5)STM32开发例程 体重秤

 

 

https://www.cnblogs.com/gooutlook/p/12516821.html

使用Arduino开发板连接HX711称重传感器模块制作数字体重秤 [复制链接]

https://item.taobao.com/item.htm?spm=a1z09.2.0.0.4c992e8deJNp96&id=575012000301&_u=i1qf7bf58a90

 

 

 

 

 

 

 

 

 

安装库

 

 

 修改引脚

 

/**
 *
 * HX711 library for Arduino - example file
 * https://github.com/bogde/HX711
 *
 * MIT License
 * (c) 2018 Bogdan Necula
 *
**/
#include "HX711.h"


// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = PB1;
const int LOADCELL_SCK_PIN = PB10;


HX711 scale;

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


  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  scale.set_scale(2280.f);                      // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();				        // reset the scale to 0


}

void loop() {
  Serial.print("one reading:\t");
  Serial.print(scale.get_units(), 1); //1次数值
  Serial.print("\t| average:\t");
  Serial.println(scale.get_units(10), 1);//10次平均

  scale.power_down();			        // put the ADC in sleep mode
  delay(1000);
  scale.power_up();
}

  

 

posted on 2022-03-12 19:59  MKT-porter  阅读(363)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3