Error compiling
hello all
i relatively new arduino , have completed lot of tutorials, since have worked on own project includes load cell, relay board, temp, , humidity. had working out flaw until wanted add grams got "error compiling" error. must of fat fingered not sure what.
i have 3 tabs in project main program in tab 1 hx711.cpp in tab 2 , hx711.h in tab 3 hx711.cpp , hx711.h found on chinese website load cell work, , functioned well.
first tab dht11_serial_file_works
// author: vernon brown
// co author kristian blåsol tutorial
// kristian's youtube channel https://www.youtube.com/watch?v=tdg0ajy4qla
// version: 0.1.00
// purpose: hive monitoring temps , humidity
#include <dht.h>
#include "hx711.h"
#include <spi.h>
dht dht;
#define dht11_pin 10
int fan = 6;
int heater = 7;
int ledgreen = 14;
int ledred = 13;
int weight = 0;
int grams;
int ounces;
int lbs;
int cal;
void setup()
{
serial.begin(115200);
serial.println("beehive climate control");
pinmode(fan, output);
pinmode(heater, output);
pinmode(ledgreen, output);
pinmode(ledred, output);
}
void loop()
{
// read data
int chk = dht.read11(dht11_pin);
weight = get_weight(); //get weight
cal = (weight - 9102.05);
ounces = (cal * 0.038);
lbs = (ounces / 16);
// convert fahrenheit
float temperaturef = (dht.temperature * 9.0 / 5.0) + 32.0;
// convert humidity
float humidity = (dht.humidity, 1);
// display data
serial.print(temperaturef); serial.println(" degrees f");
serial.print(dht.humidity, 1); serial.println("%");
serial.print(grams); //serial display
serial.print(ounces); serial.println(" ounces");
serial.print(lbs); serial.println(" pounds");
delay(1000);
//script below turns on , off heater , fan
//if (dht.humidity>55) {
if (dht.humidity>40) {
digitalwrite(fan,high);
} else {
digitalwrite(fan,low);
}
//if (dht.humidity>55) {
if (dht.humidity>40) {
digitalwrite(ledgreen,high);
} else {
digitalwrite(ledgreen,low);
}
//if (dht.temperature<18) {
if (dht.temperature<26) {
digitalwrite(heater,high);
} else {
digitalwrite(heater,low);
}
//if (dht.temperature<18) {
if (dht.temperature<26) {
digitalwrite(ledred,high);
} else {
digitalwrite(ledred,low);
}
}
//
// end of file
//
second tab hx711.cpp
#include "hx711.h"
long hx711_buffer = 0;
long weight_maopi = 0,weight_shiwu = 0;
//****************************************************
//初始化hx711
//****************************************************
void init_hx711()
{
pinmode(hx711_sck, output);
pinmode(hx711_dt, input);
}
//****************************************************
//获取毛皮重量
//****************************************************
void get_maopi()
{
hx711_buffer = hx711_read();
weight_maopi = hx711_buffer/100;
}
//****************************************************
//称重
//****************************************************
unsigned int get_weight()
{
hx711_buffer = hx711_read();
hx711_buffer = hx711_buffer/100;
weight_shiwu = hx711_buffer;
weight_shiwu = weight_shiwu - weight_maopi; //获取实物的ad采样数值。
weight_shiwu = (unsigned int)((float)weight_shiwu/7.35+0.05);
//计算实物的实际重量
//因为不同的传感器特性曲线不一样,因此,每一个传感器需要矫正这里的4.30这个除数。
//当发现测试出来的重量偏大时,增加该数值。
//如果测试出来的重量偏小时,减小改数值。
//该数值一般在7.16左右。因传感器不同而定。
//+0.05是为了四舍五入百分位
return weight_shiwu;
}
//****************************************************
//读取hx711
//****************************************************
unsigned long hx711_read(void) //增益128
{
unsigned long count;
unsigned char i;
bool flag = 0;
digitalwrite(hx711_dt, high);
delaymicroseconds(1);
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
count=0;
while(digitalread(hx711_dt));
for(i=0;i<24;i++)
{
digitalwrite(hx711_sck, high);
delaymicroseconds(1);
count=count<<1;
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
if(digitalread(hx711_dt))
count++;
}
digitalwrite(hx711_sck, high);
count ^= 0x800000;
delaymicroseconds(1);
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
return(count);
}
third tab hx711.h
#ifndef __hx711__h__
#define __hx711__h__
#include <arduino.h>
#define hx711_sck 2
#define hx711_dt 3
extern void init_hx711();
extern unsigned long hx711_read(void);
extern unsigned int get_weight();
extern void get_maopi();
#endif
error
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `hx711_read()'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `get_weight()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:30: multiple definition of `get_weight()'
hx711.cpp.o:hx711.cpp:30: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `hx711_buffer'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `weight_maopi'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `weight_shiwu'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `get_maopi()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:21: multiple definition of `get_maopi()'
hx711.cpp.o:hx711.cpp:21: first defined here
hx711_3kg/hx711.cpp.o: in function `init_hx711()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:11: multiple definition of `init_hx711()'
hx711.cpp.o:hx711.cpp:11: first defined here
i relatively new arduino , have completed lot of tutorials, since have worked on own project includes load cell, relay board, temp, , humidity. had working out flaw until wanted add grams got "error compiling" error. must of fat fingered not sure what.
i have 3 tabs in project main program in tab 1 hx711.cpp in tab 2 , hx711.h in tab 3 hx711.cpp , hx711.h found on chinese website load cell work, , functioned well.
first tab dht11_serial_file_works
// author: vernon brown
// co author kristian blåsol tutorial
// kristian's youtube channel https://www.youtube.com/watch?v=tdg0ajy4qla
// version: 0.1.00
// purpose: hive monitoring temps , humidity
#include <dht.h>
#include "hx711.h"
#include <spi.h>
dht dht;
#define dht11_pin 10
int fan = 6;
int heater = 7;
int ledgreen = 14;
int ledred = 13;
int weight = 0;
int grams;
int ounces;
int lbs;
int cal;
void setup()
{
serial.begin(115200);
serial.println("beehive climate control");
pinmode(fan, output);
pinmode(heater, output);
pinmode(ledgreen, output);
pinmode(ledred, output);
}
void loop()
{
// read data
int chk = dht.read11(dht11_pin);
weight = get_weight(); //get weight
cal = (weight - 9102.05);
ounces = (cal * 0.038);
lbs = (ounces / 16);
// convert fahrenheit
float temperaturef = (dht.temperature * 9.0 / 5.0) + 32.0;
// convert humidity
float humidity = (dht.humidity, 1);
// display data
serial.print(temperaturef); serial.println(" degrees f");
serial.print(dht.humidity, 1); serial.println("%");
serial.print(grams); //serial display
serial.print(ounces); serial.println(" ounces");
serial.print(lbs); serial.println(" pounds");
delay(1000);
//script below turns on , off heater , fan
//if (dht.humidity>55) {
if (dht.humidity>40) {
digitalwrite(fan,high);
} else {
digitalwrite(fan,low);
}
//if (dht.humidity>55) {
if (dht.humidity>40) {
digitalwrite(ledgreen,high);
} else {
digitalwrite(ledgreen,low);
}
//if (dht.temperature<18) {
if (dht.temperature<26) {
digitalwrite(heater,high);
} else {
digitalwrite(heater,low);
}
//if (dht.temperature<18) {
if (dht.temperature<26) {
digitalwrite(ledred,high);
} else {
digitalwrite(ledred,low);
}
}
//
// end of file
//
second tab hx711.cpp
#include "hx711.h"
long hx711_buffer = 0;
long weight_maopi = 0,weight_shiwu = 0;
//****************************************************
//初始化hx711
//****************************************************
void init_hx711()
{
pinmode(hx711_sck, output);
pinmode(hx711_dt, input);
}
//****************************************************
//获取毛皮重量
//****************************************************
void get_maopi()
{
hx711_buffer = hx711_read();
weight_maopi = hx711_buffer/100;
}
//****************************************************
//称重
//****************************************************
unsigned int get_weight()
{
hx711_buffer = hx711_read();
hx711_buffer = hx711_buffer/100;
weight_shiwu = hx711_buffer;
weight_shiwu = weight_shiwu - weight_maopi; //获取实物的ad采样数值。
weight_shiwu = (unsigned int)((float)weight_shiwu/7.35+0.05);
//计算实物的实际重量
//因为不同的传感器特性曲线不一样,因此,每一个传感器需要矫正这里的4.30这个除数。
//当发现测试出来的重量偏大时,增加该数值。
//如果测试出来的重量偏小时,减小改数值。
//该数值一般在7.16左右。因传感器不同而定。
//+0.05是为了四舍五入百分位
return weight_shiwu;
}
//****************************************************
//读取hx711
//****************************************************
unsigned long hx711_read(void) //增益128
{
unsigned long count;
unsigned char i;
bool flag = 0;
digitalwrite(hx711_dt, high);
delaymicroseconds(1);
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
count=0;
while(digitalread(hx711_dt));
for(i=0;i<24;i++)
{
digitalwrite(hx711_sck, high);
delaymicroseconds(1);
count=count<<1;
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
if(digitalread(hx711_dt))
count++;
}
digitalwrite(hx711_sck, high);
count ^= 0x800000;
delaymicroseconds(1);
digitalwrite(hx711_sck, low);
delaymicroseconds(1);
return(count);
}
third tab hx711.h
#ifndef __hx711__h__
#define __hx711__h__
#include <arduino.h>
#define hx711_sck 2
#define hx711_dt 3
extern void init_hx711();
extern unsigned long hx711_read(void);
extern unsigned int get_weight();
extern void get_maopi();
#endif
error
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `hx711_read()'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `get_weight()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:30: multiple definition of `get_weight()'
hx711.cpp.o:hx711.cpp:30: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `hx711_buffer'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `weight_maopi'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `hx711_read()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:50: multiple definition of `weight_shiwu'
hx711.cpp.o:hx711.cpp:50: first defined here
hx711_3kg/hx711.cpp.o: in function `get_maopi()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:21: multiple definition of `get_maopi()'
hx711.cpp.o:hx711.cpp:21: first defined here
hx711_3kg/hx711.cpp.o: in function `init_hx711()':
/users/vernonbrown/dropbox/arduino/arduino/libraries/hx711_3kg/hx711.cpp:11: multiple definition of `init_hx711()'
hx711.cpp.o:hx711.cpp:11: first defined here
the hx711.ccp , hx711.h files library -
create folder called hx711 in libraries sub-folder of sketchbook
directory (that's personal libraries live), , put them their, not inside
your sketch folder.
i'm not sure why you're seeing twice - perhaps installed as
a library too?
create folder called hx711 in libraries sub-folder of sketchbook
directory (that's personal libraries live), , put them their, not inside
your sketch folder.
i'm not sure why you're seeing twice - perhaps installed as
a library too?
Arduino Forum > Using Arduino > Programming Questions > Error compiling
arduino
Comments
Post a Comment