Took 10 minutes
This commit is contained in:
Tobias Hopp 2023-01-17 22:57:51 +01:00
parent cb72920611
commit 2fe26ef34b
6 changed files with 76 additions and 14 deletions

View File

@ -0,0 +1,8 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
]
}

View File

View File

@ -2,13 +2,25 @@
* Official proxy code for iTender GPIO Communication * Official proxy code for iTender GPIO Communication
**/ **/
#include "HX711.h"
#include <ArduinoJson.h>
DynamicJsonDocument<200> doc;
void setup() { void setup() {
// put your setup code here, to run once:
Serial.begin(9600); Serial.begin(9600);
while (!Serial) continue;
} }
void loop() { void loop() {
// put your main code here, to run repeatedly: if( Serial.available() > 0 )
{
String data = Serial.readString();
}
} }

43
arduino/itender/tare.ino Normal file
View File

@ -0,0 +1,43 @@
/**
#include "HX711.h"
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
HX711 scale;
int minus = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000);
Serial.println("TARE");
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(429.6159259259259);
scale.tare();
delay(1000);
minus=abs(scale.get_units(5));
// scale.set_scale();
// scale.tare();
// Serial.println("TARE OK - PLACE WEIGHT");
//delay(5000);
}
int len = 0;
long sum = 0;
void loop() {
if (scale.is_ready()) {
long data = scale.get_units(5) + minus;
Serial.println(data);
}
}
**/

View File

@ -58,6 +58,10 @@ sudo -u itender mkdir -p /home/itender/bin
sudo -u itender sh -c 'curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/home/itender/bin/ sh' sudo -u itender sh -c 'curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/home/itender/bin/ sh'
sudo -u itender /home/itender/bin/arduino-cli config init sudo -u itender /home/itender/bin/arduino-cli config init
sudo -u itender /home/itender/bin/arduino-cli core update-index || true sudo -u itender /home/itender/bin/arduino-cli core update-index || true
sudo -u itender /home/itender/bin/arduino-cli lib search ArduinoJson || true
sudo -u itender /home/itender/bin/arduino-cli lib install ArduinoJson || true
echo "Installing autostart..." echo "Installing autostart..."
# Autostart # Autostart

View File

@ -4,30 +4,25 @@ import Ingredient from "./Ingredient";
import Drink from "./Drink"; import Drink from "./Drink";
import Container from "./Container"; import Container from "./Container";
// create a namespace for logging
const log = debug("itender:server"); const log = debug("itender:server");
export class Database { export class Database {
// method to connect to the database
public static connect(): Promise<void> { public static connect(): Promise<void> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
//connect to mongodb using mongoose
await Mongoose.connect("mongodb://127.0.0.1:27017/iTender?retryWrites=true"); await Mongoose.connect("mongodb://127.0.0.1:27017/iTender?retryWrites=true");
log("Connected to Database"); log("Connected to Database");
/*if (Mongoose.connection.readyState == Mongoose.ConnectionStates.connected) { // Preload the schema for Ingredient, Drink and Container
resolve();
} else {
reject("Can't connect to database");
}*/
// Preload schemes
Ingredient.find(); Ingredient.find();
Drink.find(); Drink.find();
Container.find(); Container.find();
resolve(); resolve();
} catch (e) { } catch (e) {
reject("Exception whilst connecting to Database " + e); reject("Exception whilst connecting to Database " + e);
} }
}); });
} }
} }