hanze/muizenval

fixing baud (208f81550eca2319f5f70c7ac61f83a579cb73e7)
Repositories

commit 208f81550eca2319f5f70c7ac61f83a579cb73e7
parent fef3e0497445427eb3c300e59a48fa8ee0a30fc0
Author: Friedel <[email protected]>
Date:   Sun, 19 Jun 2022 17:27:53 +0200

fixing baud

Diffstat:
M.vscode/arduino.json2+-
M5g-client/5g-client.ino11+++++++----
M5g-client/include/config.h3++-
M5g-client/modem.ino2+-
4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/.vscode/arduino.json b/.vscode/arduino.json @@ -1,6 +1,6 @@ { "sketch": "5g-client/5g-client.ino", "board": "SODAQ:samd:sodaq_sara", - "port": "/dev/tty.usbmodem14101", + "port": "/dev/tty.usbmodem1D11101", "output": "build" } \ No newline at end of file diff --git a/5g-client/5g-client.ino b/5g-client/5g-client.ino @@ -4,13 +4,14 @@ #include <Sodaq_LSM303AGR.h> #include <Sodaq_UBlox_GPS.h> +#include <Wire.h> #define ADC_AREF 3.3f #define BATVOLT_R1 4.7f #define BATVOLT_R2 10.0f #define BATVOLT_PIN BAT_VOLT -#define statusDelay 5 // seconds +#define statusDelay 0.5 // seconds #define batteryFactor (0.978 * (BATVOLT_R1 / BATVOLT_R2 + 1) / ADC_AREF) @@ -21,11 +22,12 @@ serial_remote remote; void setup() { // -*- hardware initiation -*- - usbSerial.begin(baud); - // while (usbWait && !usbSerial) - // ; + usbSerial.begin(remoteBaud); + while (usbWait && !usbSerial) + ; pinMode(BATVOLT_PIN, INPUT); + pinMode(CHARGER_STATUS, INPUT); // modem.init(); remote.begin(); @@ -143,6 +145,7 @@ void loop() { serial_remote::http_packet req, res; req.method = "POST"; req.endpoint = "/api/update"; + req.body["charging"] = (bool) digitalRead(CHARGER_STATUS); req.body["latitude"] = lat; req.body["longitude"] = lon; req.body["accuracy"] = accuracy; diff --git a/5g-client/include/config.h b/5g-client/include/config.h @@ -8,7 +8,8 @@ #define modemVoltagePin SARA_R4XX_TOGGLE // modem voltage pin // -*- behaviour settings -*- -#define remoteBaut 115200 // baut-rate of modem-/usb-serial +#define remoteBaud 115200 // baud-rate of usb-serial +#define modemBaud 115200 // baud-rate of modem-serial #define remoteFirstTimeout 5.0 // seconds to wait for the first timeout #define remoteTimeout 1.0 // seconds to wait for remote to timeout #define lineBuffer 512 // buffer-size (bytes) to use to store lines diff --git a/5g-client/modem.ino b/5g-client/modem.ino @@ -10,7 +10,7 @@ void sara_modem::init() { digitalWrite(modemPowerPin, HIGH); digitalWrite(modemVoltagePin, LOW); digitalWrite(modemEnablePin, HIGH); - modemSerial.begin(baud); + modemSerial.begin(modemBaud); while (!modemSerial) ;