Begin fixing the battery problem
This commit is contained in:
parent
ddf7bb7003
commit
65d77059a3
5 changed files with 42 additions and 1596 deletions
1574
sodaq_one/Arduino.mk
1574
sodaq_one/Arduino.mk
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,13 @@
|
|||
#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));
|
||||
|
||||
|
|
8
sodaq_one/nico.ino
Normal file
8
sodaq_one/nico.ino
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
|
||||
|
||||
int getB()
|
||||
{
|
||||
return (float)analogRead(BAT_VOLT);
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
/* battery.ino */
|
||||
uint16_t getBatteryVoltage();
|
||||
// uint16_t getBatteryVoltage();
|
||||
int getB();
|
||||
|
||||
void blink(int length);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#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,28 +71,33 @@ void loop() {
|
|||
// loraSend(getTempHumidHDC1000());
|
||||
// loraSend(getCompass());
|
||||
|
||||
sendIntAsString("battery=", getBatteryVoltage());
|
||||
|
||||
if((tmps = gpsGetPostion(120)) != "") {
|
||||
loraSend(tmps);
|
||||
// sendIntAsString("battery=", getBatteryVoltage());
|
||||
|
||||
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);
|
||||
|
||||
/* 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; */
|
||||
/* } */
|
||||
// sendIntAsString("battery=", getBatteryVoltage());
|
||||
sendFloatAsString("loudness=", tmp);
|
||||
sendFloatAsString("temperature=", getTemperature(TEMP_PIN));
|
||||
cnt = 0;
|
||||
}
|
||||
|
||||
|
||||
delay(SLEEPTIME);
|
||||
|
|
Loading…
Reference in a new issue