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 ADC_AREF 3.3f
|
||||||
#define BATVOLT_R1 2.0f
|
#define BATVOLT_R1 2.0f
|
||||||
#define BATVOLT_R2 2.0f
|
#define BATVOLT_R2 2.0f
|
||||||
#define BATVOLT_PIN BAT_VOLT
|
#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));
|
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 */
|
/* battery.ino */
|
||||||
uint16_t getBatteryVoltage();
|
// uint16_t getBatteryVoltage();
|
||||||
|
int getB();
|
||||||
|
|
||||||
void blink(int length);
|
void blink(int length);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <Sodaq_UBlox_GPS.h>
|
||||||
#include "nsarduino.h"
|
#include "nsarduino.h"
|
||||||
|
|
||||||
#define debugSerial SerialUSB
|
#define debugSerial SerialUSB
|
||||||
|
@ -33,7 +34,7 @@ void setup() {
|
||||||
// setupWater(WATER_SENSOR_PIN);
|
// setupWater(WATER_SENSOR_PIN);
|
||||||
// setupBuzzer(BUZZER_PIN);
|
// setupBuzzer(BUZZER_PIN);
|
||||||
|
|
||||||
gpsSetup();
|
// gpsSetup();
|
||||||
|
|
||||||
// setupBuzzer();
|
// setupBuzzer();
|
||||||
|
|
||||||
|
@ -47,12 +48,12 @@ void setup() {
|
||||||
String tmps;
|
String tmps;
|
||||||
float tmp;
|
float tmp;
|
||||||
|
|
||||||
|
|
||||||
#define SLEEPTIME 10000
|
#define SLEEPTIME 10000
|
||||||
|
|
||||||
#define LOUDNESS_AVG 60
|
#define LOUDNESS_AVG 60
|
||||||
int loudnesses[LOUDNESS_AVG];
|
int loudnesses[LOUDNESS_AVG];
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// signal_loop_start();
|
// signal_loop_start();
|
||||||
|
|
||||||
|
@ -70,29 +71,34 @@ void loop() {
|
||||||
// loraSend(getTempHumidHDC1000());
|
// loraSend(getTempHumidHDC1000());
|
||||||
// loraSend(getCompass());
|
// loraSend(getCompass());
|
||||||
|
|
||||||
sendIntAsString("battery=", getBatteryVoltage());
|
|
||||||
|
|
||||||
if((tmps = gpsGetPostion(120)) != "") {
|
// sendIntAsString("battery=", getBatteryVoltage());
|
||||||
loraSend(tmps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if(cnt < LOUDNESS_AVG) { */
|
getB();
|
||||||
/* 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()); */
|
/* Tracker code */
|
||||||
/* sendFloatAsString("loudness=", tmp); */
|
/* if((tmps = gpsGetPostion(120)) != "") { */
|
||||||
/* sendFloatAsString("temperature=", getTemperature(TEMP_PIN)); */
|
/* loraSend(tmps); */
|
||||||
/* cnt = 0; */
|
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
|
/* 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);
|
delay(SLEEPTIME);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue