Commit 65d77059 authored by Nico Schottelius's avatar Nico Schottelius

Begin fixing the battery problem

parent ddf7bb70
This diff is collapsed.
#include <Arduino.h>
#define ADC_AREF 3.3f
#define BATVOLT_R1 2.0f
#define BATVOLT_R2 2.0f
#define BATVOLT_PIN BAT_VOLT
uint16_t getBatteryVoltage()
// uint16_t getBatteryVoltage()
int getB()
{
uint16_t voltage = (uint16_t)((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));
......
#include <Arduino.h>
int getB()
{
return (float)analogRead(BAT_VOLT);
}
#include <Arduino.h>
/* battery.ino */
uint16_t getBatteryVoltage();
// uint16_t getBatteryVoltage();
int getB();
void blink(int length);
......
#include <Arduino.h>
#include <Wire.h>
#include <math.h>
#include <Sodaq_UBlox_GPS.h>
#include "nsarduino.h"
#define debugSerial SerialUSB
......@@ -33,7 +34,7 @@ void setup() {
// setupWater(WATER_SENSOR_PIN);
// setupBuzzer(BUZZER_PIN);
gpsSetup();
// gpsSetup();
// setupBuzzer();
......@@ -47,12 +48,12 @@ void setup() {
String tmps;
float tmp;
#define SLEEPTIME 10000
#define LOUDNESS_AVG 60
int loudnesses[LOUDNESS_AVG];
void loop() {
// signal_loop_start();
......@@ -70,29 +71,34 @@ void loop() {
// loraSend(getTempHumidHDC1000());
// loraSend(getCompass());
sendIntAsString("battery=", getBatteryVoltage());
if((tmps = gpsGetPostion(120)) != "") {
loraSend(tmps);
}
// sendIntAsString("battery=", getBatteryVoltage());
/* if(cnt < LOUDNESS_AVG) { */
/* loudnesses[cnt] = readLoudness(LOUDNESS_PIN); */
/* debugSerial.println("temploudness=" + String(loudnesses[cnt])); */
/* cnt++; */
/* } else { */
/* tmp = 0; */
/* for(cnt = 0; cnt < LOUDNESS_AVG; cnt++) { */
/* tmp += loudnesses[cnt]; */
/* } */
/* tmp = tmp / (float) (cnt+1); */
/* sendIntAsString("battery=", getBatteryVoltage()); */
/* sendFloatAsString("loudness=", tmp); */
/* sendFloatAsString("temperature=", getTemperature(TEMP_PIN)); */
/* cnt = 0; */
getB();
/* Tracker code */
/* if((tmps = gpsGetPostion(120)) != "") { */
/* loraSend(tmps); */
/* } */
/* Temp & loudness code */
if(cnt < LOUDNESS_AVG) {
loudnesses[cnt] = readLoudness(LOUDNESS_PIN);
debugSerial.println("temploudness=" + String(loudnesses[cnt]));
cnt++;
} else {
tmp = 0;
for(cnt = 0; cnt < LOUDNESS_AVG; cnt++) {
tmp += loudnesses[cnt];
}
tmp = tmp / (float) (cnt+1);
// sendIntAsString("battery=", getBatteryVoltage());
sendFloatAsString("loudness=", tmp);
sendFloatAsString("temperature=", getTemperature(TEMP_PIN));
cnt = 0;
}
delay(SLEEPTIME);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment