separate files created for AVR and ESP8266 settings
This commit is contained in:
parent
2eab71461c
commit
9b5afc68c7
45
CG_scale.ino
45
CG_scale.ino
@ -52,16 +52,19 @@
|
||||
#include <EEPROM.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// libraries for ESP8266 (NodeMCU 1.0 )
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
// libraries for ESP8266
|
||||
#if defined(ESP8266)
|
||||
#include <FS.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include "settings_ESP8266.h"
|
||||
#endif
|
||||
|
||||
// Settings in separate file
|
||||
#include "settings.h"
|
||||
// settings for AVR
|
||||
#if defined(__AVR__)
|
||||
#include "settings_AVR.h"
|
||||
#endif
|
||||
|
||||
// HX711 constructor (dout pin, sck pint):
|
||||
HX711_ADC LoadCell_1(PIN_LOADCELL1_DOUT, PIN_LOADCELL1_PD_SCK);
|
||||
@ -69,7 +72,7 @@ HX711_ADC LoadCell_2(PIN_LOADCELL2_DOUT, PIN_LOADCELL2_PD_SCK);
|
||||
HX711_ADC LoadCell_3(PIN_LOADCELL3_DOUT, PIN_LOADCELL3_PD_SCK);
|
||||
|
||||
// webserver constructor
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
ESP8266WebServer server(80);
|
||||
IPAddress apIP(ip[0], ip[1], ip[2], ip[3]);
|
||||
#endif
|
||||
@ -186,7 +189,7 @@ void(* resetCPU) (void) = 0;
|
||||
// save values to eeprom
|
||||
void saveLoadcells() {
|
||||
EEPROM.put(P_NUMBER_LOADCELLS, nLoadcells);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -194,7 +197,7 @@ void saveLoadcells() {
|
||||
|
||||
void saveDistanceX1() {
|
||||
EEPROM.put(P_DISTANCE_X1, distanceX1);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -202,7 +205,7 @@ void saveDistanceX1() {
|
||||
|
||||
void saveDistanceX2() {
|
||||
EEPROM.put(P_DISTANCE_X2, distanceX2);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -210,7 +213,7 @@ void saveDistanceX2() {
|
||||
|
||||
void saveDistanceX3() {
|
||||
EEPROM.put(P_DISTANCE_X3, distanceX3);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -218,7 +221,7 @@ void saveDistanceX3() {
|
||||
|
||||
void saveRefWeight() {
|
||||
EEPROM.put(P_REF_WEIGHT, refWeight);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -226,7 +229,7 @@ void saveRefWeight() {
|
||||
|
||||
void saveRefCG() {
|
||||
EEPROM.put(P_REF_CG, refCG);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -235,7 +238,7 @@ void saveRefCG() {
|
||||
void saveCalFactor1() {
|
||||
LoadCell_1.setCalFactor(calFactorLoadcell1);
|
||||
EEPROM.put(P_LOADCELL1_CALIBRATION_FACTOR, calFactorLoadcell1);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -244,7 +247,7 @@ void saveCalFactor1() {
|
||||
void saveCalFactor2() {
|
||||
LoadCell_2.setCalFactor(calFactorLoadcell2);
|
||||
EEPROM.put(P_LOADCELL2_CALIBRATION_FACTOR, calFactorLoadcell2);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -253,7 +256,7 @@ void saveCalFactor2() {
|
||||
void saveCalFactor3() {
|
||||
LoadCell_3.setCalFactor(calFactorLoadcell3);
|
||||
EEPROM.put(P_LOADCELL3_CALIBRATION_FACTOR, calFactorLoadcell3);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -261,7 +264,7 @@ void saveCalFactor3() {
|
||||
|
||||
void saveResistorR1() {
|
||||
EEPROM.put(P_RESISTOR_R1, resistorR1);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -269,14 +272,14 @@ void saveResistorR1() {
|
||||
|
||||
void saveResistorR2() {
|
||||
EEPROM.put(P_RESISTOR_R2, resistorR2);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void saveEnableBatVolt() {
|
||||
EEPROM.put(P_ENABLE_BATVOLT, enableBatVolt);
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
}
|
||||
@ -311,7 +314,7 @@ void auto_calibrate() {
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
// init webserver
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||
@ -660,7 +663,7 @@ void loop() {
|
||||
EEPROM.write(i, 0xFF);
|
||||
}
|
||||
Serial.end();
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
resetCPU();
|
||||
@ -828,14 +831,14 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
server.handleClient();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU
|
||||
#if defined(ESP8266)
|
||||
void main_page()
|
||||
{
|
||||
char buff[8];
|
||||
|
122
settings_AVR.h
Normal file
122
settings_AVR.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
-----------------------------------------------------------
|
||||
Settings for AVR based MCUs
|
||||
-----------------------------------------------------------
|
||||
General settings for the CG scale.
|
||||
*/
|
||||
|
||||
// **** Loadcell hardware settings ****
|
||||
|
||||
#define NUMBER_LOADCELLS 3 // if set to 2, the parameters of loadcell 3 are ignored
|
||||
|
||||
#define DISTANCE_X1 30 // mm
|
||||
#define DISTANCE_X2 350 // mm
|
||||
#define DISTANCE_X3 220 // mm
|
||||
|
||||
#define LOADCELL1_CALIBRATION_FACTOR 900 // user set calibration factor
|
||||
#define LOADCELL2_CALIBRATION_FACTOR 900 // user set calibration factor
|
||||
#define LOADCELL3_CALIBRATION_FACTOR 900 // user set calibration factor
|
||||
|
||||
/*
|
||||
CG scale with 2 Loadcells:
|
||||
|
||||
|
||||
<- ||=== Loadcell 1 ========== Loadcell 2
|
||||
|
||||
| | |
|
||||
|---X1---|---------X2----------|
|
||||
|
||||
|
||||
|
||||
CG scale with 3 Loadcells:
|
||||
|
||||
-- || Loadcell 1
|
||||
| || ||
|
||||
| || ||
|
||||
| || ||
|
||||
<- X3 || ||================ Loadcell 2
|
||||
| || ||
|
||||
| || ||
|
||||
| || ||
|
||||
-- || Loadcell 3
|
||||
|
||||
| | |
|
||||
|---X1---|---------X2----------|
|
||||
*/
|
||||
|
||||
|
||||
#define PIN_LOADCELL1_DOUT A2
|
||||
#define PIN_LOADCELL1_PD_SCK A3
|
||||
|
||||
#define PIN_LOADCELL2_DOUT A0
|
||||
#define PIN_LOADCELL2_PD_SCK A1
|
||||
|
||||
#define PIN_LOADCELL3_DOUT A9
|
||||
#define PIN_LOADCELL3_PD_SCK A10
|
||||
|
||||
|
||||
|
||||
// **** Measurement settings ****
|
||||
|
||||
#define STABILISINGTIME 3000 // ms
|
||||
|
||||
#define UPDATE_INTERVAL_OLED_MENU 500 // ms
|
||||
#define UPDATE_INTERVAL_LOADCELL 100 // ms
|
||||
|
||||
#define SMOOTHING_LOADCELL1 0.4 // IIR filter: smoothing value from 0.00-1.00
|
||||
#define SMOOTHING_LOADCELL2 0.4 // IIR filter: smoothing value from 0.00-1.00
|
||||
#define SMOOTHING_LOADCELL3 0.4 // IIR filter: smoothing value from 0.00-1.00
|
||||
|
||||
#define MINIMAL_CG_WEIGHT 10 // g if lower, no CG is displayed (0mm)
|
||||
#define MINIMAL_TOTAL_WEIGHT 1 // g if lower, weight = 0 is displayed
|
||||
|
||||
|
||||
|
||||
// **** Calibration settings ****
|
||||
|
||||
#define REF_WEIGHT 1500 // g
|
||||
#define REF_CG 100 // mm
|
||||
|
||||
|
||||
|
||||
// **** Display settings ****
|
||||
|
||||
// Please UNCOMMENT the display used
|
||||
|
||||
U8G2_SH1106_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
||||
|
||||
|
||||
|
||||
// **** Voltage measurement settings ****
|
||||
|
||||
// Enable voltage measurement
|
||||
#define ENABLE_VOLTAGE true
|
||||
|
||||
// analog input pin
|
||||
#define VOLTAGE_PIN A7
|
||||
|
||||
// supply voltage
|
||||
#define V_REF 5000 // set supply voltage from 1800 to 5500mV
|
||||
|
||||
// voltage divider
|
||||
#define RESISTOR_R1 10000 // ohm
|
||||
#define RESISTOR_R2 10000 // ohm
|
||||
|
||||
/*
|
||||
voltage input
|
||||
|
|
||||
|
|
||||
| |
|
||||
| | R1
|
||||
| |
|
||||
|
|
||||
analog Pin <------+
|
||||
|
|
||||
| |
|
||||
| | R2
|
||||
| |
|
||||
|
|
||||
|
|
||||
GND
|
||||
*/
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
-----------------------------------------------------------
|
||||
Settings
|
||||
Settings for ESP8266 based MCUs
|
||||
-----------------------------------------------------------
|
||||
General settings for the CG scale.
|
||||
*/
|
||||
@ -45,18 +45,6 @@ CG scale with 3 Loadcells:
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __AVR__ // if CPU is ATmega32u4 or Atmega328, use this pins
|
||||
#define PIN_LOADCELL1_DOUT A2
|
||||
#define PIN_LOADCELL1_PD_SCK A3
|
||||
|
||||
#define PIN_LOADCELL2_DOUT A0
|
||||
#define PIN_LOADCELL2_PD_SCK A1
|
||||
|
||||
#define PIN_LOADCELL3_DOUT A9
|
||||
#define PIN_LOADCELL3_PD_SCK A10
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU // if CPU is ESP8266, use this pins
|
||||
#define PIN_LOADCELL1_DOUT D6
|
||||
#define PIN_LOADCELL1_PD_SCK D5
|
||||
|
||||
@ -65,7 +53,6 @@ CG scale with 3 Loadcells:
|
||||
|
||||
#define PIN_LOADCELL3_DOUT D8
|
||||
#define PIN_LOADCELL3_PD_SCK D7
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -96,15 +83,9 @@ CG scale with 3 Loadcells:
|
||||
|
||||
// Please UNCOMMENT the display used
|
||||
|
||||
#ifdef __AVR__ // if CPU is ATmega32u4 or Atmega328, use this display
|
||||
U8G2_SH1106_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU // if CPU is ESP8266, use this display
|
||||
U8G2_SH1106_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ D3, /* data=*/ D4);
|
||||
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ D3, /* data=*/ D4);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// **** Voltage measurement settings ****
|
||||
@ -113,20 +94,14 @@ U8G2_SH1106_128X64_NONAME_1_HW_I2C oledDisplay(U8G2_R0, /* reset=*/ U8X8_PIN_NON
|
||||
#define ENABLE_VOLTAGE true
|
||||
|
||||
// analog input pin
|
||||
#ifdef __AVR__ // if CPU is ATmega32u4 or Atmega328, use this pin
|
||||
#define VOLTAGE_PIN A7
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ESP8266_NODEMCU // if CPU is ESP8266, use this pin
|
||||
#define VOLTAGE_PIN A0
|
||||
#endif
|
||||
|
||||
// supply voltage
|
||||
#define V_REF 5000 // set supply voltage from 1800 to 5500mV
|
||||
#define V_REF 3300 // set supply voltage from 1800 to 5500mV
|
||||
|
||||
// voltage divider
|
||||
#define RESISTOR_R1 10000 // ohm
|
||||
#define RESISTOR_R2 10000 // ohm
|
||||
#define RESISTOR_R2 20000 // ohm
|
||||
|
||||
/*
|
||||
voltage input
|
Loading…
x
Reference in New Issue
Block a user