Cleanups in sodaq code
This commit is contained in:
parent
13d434cf47
commit
73dcd8879e
6 changed files with 39 additions and 24 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ Sodaq_UBlox_GPS/
|
|||
libraries/
|
||||
a.out
|
||||
/venv/
|
||||
/sodaq_one/internal.h
|
||||
|
|
|
@ -40,11 +40,12 @@ void blink(int length) {
|
|||
#if LORADEV == 1
|
||||
BLUE();
|
||||
#elif LORADEV == 2
|
||||
RED();
|
||||
WHITE();
|
||||
#elif LORADEV == 3
|
||||
YELLOW();
|
||||
#elif LORADEV == 4
|
||||
WHITE();
|
||||
RED();
|
||||
|
||||
#else
|
||||
GREEN();
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <Arduino.h>
|
||||
#include "Sodaq_RN2483.h"
|
||||
#include "internal.h"
|
||||
|
||||
#define loraSerial Serial1
|
||||
#define beePin ENABLE_PIN_IO
|
||||
|
@ -91,3 +92,15 @@ void loraSend(String packet){
|
|||
/* Delay some time to give avoid keeping the device busy */
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
void sendIntAsString(String prefix, int value) {
|
||||
String tmp = prefix + String(value);
|
||||
debugSerial.println(tmp);
|
||||
loraSend(tmp);
|
||||
}
|
||||
|
||||
void sendFloatAsString(String prefix, float value) {
|
||||
String tmp = prefix + String(value);
|
||||
debugSerial.println(tmp);
|
||||
loraSend(tmp);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
#define SWISSCOM 1
|
||||
#define TTN 2
|
||||
#define LORIOT 3
|
||||
|
||||
|
||||
/* battery.ino */
|
||||
uint16_t getBatteryVoltage();
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#define debugSerial SerialUSB
|
||||
|
||||
|
||||
void signal_loop_start()
|
||||
{
|
||||
blink(30); delay(50);
|
||||
|
@ -36,26 +35,12 @@ void setup() {
|
|||
cnt = 0;
|
||||
}
|
||||
|
||||
|
||||
void sendIntAsString(String prefix, int value) {
|
||||
String tmp = prefix + String(value);
|
||||
debugSerial.println(tmp);
|
||||
loraSend(tmp);
|
||||
}
|
||||
|
||||
void sendFloatAsString(String prefix, float value) {
|
||||
String tmp = prefix + String(value);
|
||||
debugSerial.println(tmp);
|
||||
loraSend(tmp);
|
||||
}
|
||||
|
||||
|
||||
String tmps;
|
||||
float tmp;
|
||||
|
||||
#define TEMP_PIN 2
|
||||
#define LOUDNESS_PIN 0
|
||||
#define BUZZER_PIN 2
|
||||
#define BUZZER_PIN 6
|
||||
|
||||
#define SLEEPTIME 10000
|
||||
|
||||
|
@ -66,7 +51,6 @@ void loop() {
|
|||
signal_loop_start();
|
||||
|
||||
|
||||
|
||||
// sendIntAsString("loudness=", readLoudness(LOUDNESS_PIN));
|
||||
// loraSend(getSunLight());
|
||||
// loraSend(getTempHumidHDC1000());
|
||||
|
@ -76,6 +60,8 @@ void loop() {
|
|||
/* loraSend(tmps); */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
if(cnt < LOUDNESS_AVG) {
|
||||
loudnesses[cnt] = readLoudness(LOUDNESS_PIN);
|
||||
debugSerial.println("temploudness=" + String(loudnesses[cnt]));
|
||||
|
@ -87,8 +73,8 @@ void loop() {
|
|||
}
|
||||
tmp = tmp / (float) (cnt+1);
|
||||
|
||||
sendIntAsString("battery=", getBatteryVoltage());
|
||||
sendFloatAsString("loudness=", tmp);
|
||||
sendIntAsString( "battery=", getBatteryVoltage());
|
||||
sendFloatAsString("temperature=", getTemperature(TEMP_PIN));
|
||||
cnt = 0;
|
||||
}
|
||||
|
|
18
sodaq_one/temp-hdc1000.ino
Normal file
18
sodaq_one/temp-hdc1000.ino
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <HDC1000.h>
|
||||
|
||||
HDC1000 hdc;
|
||||
|
||||
void setupTempHumidHDC1000() {
|
||||
hdc.begin(); delay(500);
|
||||
}
|
||||
|
||||
String getTempHumidHDC1000() {
|
||||
float temperature;
|
||||
float humidity;
|
||||
|
||||
humidity = hdc.getHumidity();
|
||||
temperature = hdc.getTemperature();
|
||||
return String("tmp=") + temperature + String(" humid=") + humidity;
|
||||
}
|
Loading…
Reference in a new issue