Added T,H,V measurment ExSens
This commit is contained in:
@@ -12,3 +12,5 @@
|
|||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = pro8MHzatmega328
|
board = pro8MHzatmega328
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
lib_deps = enjoyneering/AHT10@^1.1.0
|
||||||
|
|||||||
@@ -1,10 +1,68 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#define MY_DEBUG
|
||||||
|
#define MY_RADIO_RF24
|
||||||
|
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
|
||||||
|
#include <MySensors.h>
|
||||||
|
#include <AHT10.h>
|
||||||
|
|
||||||
|
uint32_t cRun;
|
||||||
|
int BATTERY_SENSE_PIN = A0;
|
||||||
|
int sensorValue, batteryPcnt;
|
||||||
|
float v;
|
||||||
|
int oldBatteryPcnt = 0;
|
||||||
|
|
||||||
|
void presentation();
|
||||||
|
MyMessage msgTemp(0, V_TEMP);
|
||||||
|
MyMessage msgHum(1, V_HUM);
|
||||||
|
MyMessage msgMillis(2, V_VAR1);
|
||||||
|
MyMessage msgVolts(2, V_VAR2);
|
||||||
|
|
||||||
|
AHT10 myAHT10(AHT10_ADDRESS_0X38);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// put your setup code here, to run once:
|
analogReference(INTERNAL);
|
||||||
|
sensorValue = analogRead(BATTERY_SENSE_PIN);
|
||||||
|
v = sensorValue * 0.004659498;
|
||||||
|
batteryPcnt = (v * 100) / 4.2;
|
||||||
|
while (myAHT10.begin() != true)
|
||||||
|
{
|
||||||
|
Serial.println(F("AHT10 not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
|
Serial.println(F("AHT10 OK"));
|
||||||
|
Serial.print(F("Temperature: ")); Serial.print(myAHT10.readTemperature(AHT10_FORCE_READ_DATA)); Serial.println(F(" +-0.3C"));
|
||||||
|
Serial.print(F("Humidity...: ")); Serial.print(myAHT10.readHumidity(AHT10_USE_READ_DATA)); Serial.println(F(" +-2%"));
|
||||||
|
|
||||||
|
cRun = millis();
|
||||||
|
send(msgMillis.set(cRun));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
float temp, hum;
|
||||||
}
|
if((cRun + 29999) < millis()){
|
||||||
|
cRun = millis();
|
||||||
|
temp = myAHT10.readTemperature(AHT10_FORCE_READ_DATA);
|
||||||
|
hum = myAHT10.readHumidity(AHT10_USE_READ_DATA);
|
||||||
|
Serial.print(F("Temperature: ")); Serial.print(temp); Serial.println(F(" +-0.3C"));
|
||||||
|
Serial.print(F("Humidity...: ")); Serial.print(hum); Serial.println(F(" +-2%"));
|
||||||
|
if (temp < 200){
|
||||||
|
send(msgTemp.set(temp, 1));
|
||||||
|
send(msgHum.set(hum, 1));
|
||||||
|
}
|
||||||
|
send(msgMillis.set(cRun));
|
||||||
|
sensorValue = analogRead(BATTERY_SENSE_PIN);
|
||||||
|
v = sensorValue * 0.004659498;
|
||||||
|
batteryPcnt = (v * 100) / 4.2;
|
||||||
|
sendBatteryLevel(batteryPcnt);
|
||||||
|
send(msgVolts.set(v, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void presentation()
|
||||||
|
{
|
||||||
|
sendSketchInfo("ExtSens", "1.2");
|
||||||
|
present(0, S_TEMP, "Temp");
|
||||||
|
present(1, S_HUM, "Humid");
|
||||||
|
present(2, S_CUSTOM, "ESMillis");
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user