Skip to content

Commit

Permalink
Send data to sheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiakiy committed Aug 16, 2020
1 parent 6038aa3 commit 07fb585
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ void powerOff()
void statusUpdate(unsigned long tick)
{
if (tick % 60 == 0) {
int8_t battery = getBattery();
// int8_t battery = getBattery();
float battery = M5.Axp.GetBatVoltage();
M5.Lcd.fillRect(0, 0, 240, 20, BLACK);
M5.Lcd.setCursor(0, 0);
M5.Lcd.printf("Battery: %4d%%", battery);
M5.Lcd.printf("Battery: %f%%", battery);
}

if (tick % 60 == 0) {
Expand All @@ -27,6 +28,7 @@ void statusUpdate(unsigned long tick)
int temp = getTemp();
M5.Lcd.setCursor(0, 40);
M5.Lcd.printf("Temp : %3dc", temp);
sendCO2Data(ppm, temp);
}

if (tick % 180 == 0) {
Expand Down Expand Up @@ -75,6 +77,6 @@ void loop()
if (M5.BtnA.isPressed())
{
toggleSwitch();
powerOff();
// powerOff();
}
}
7 changes: 7 additions & 0 deletions mhz19b.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MHZ19.h"
#include "oursettings.h"

#define RX_PIN 0 // Rx pin which the MHZ19 Tx pin is attached to
#define TX_PIN 26 // Tx pin which the MHZ19 Rx pin is attached to
Expand All @@ -22,3 +23,9 @@ int8_t getTemp()
{
return co2sensor.getTemperature();
}

void sendCO2Data(int ppm, int8_t temperature) {
char postData[16];
sprintf(postData, "[%d,%d]", ppm, temperature);
httpPost(SHEET_URL, postData);
}

0 comments on commit 07fb585

Please sign in to comment.