GreenPi

A small project for gathering information and managing garden projects.

List of the last 1000 rows of data registered

Arduino Code:

#include <SimpleDHT.h>
#include <OneWire.h>
#include <DallasTemperature.h>

int pinDHT11 = 2;
SimpleDHT11 dht11;
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
Serial.begin(9600);
sensors.begin();
Serial.println(“{\”message\”:\”Boot complete\”}”);
}

void loop() {
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print(“{\”message\”:\”Read DHT11 failed, err=”);
Serial.print(err);
Serial.println(“\”}”);
delay(1000);
return;
}
Serial.print(“{“);
Serial.print(“\”DHT11-temperature\”:\””);
Serial.print((int)temperature);
Serial.print(“\”, “);
Serial.print(“\”DHT11-humidity\”:\””);
Serial.print((int)humidity);
Serial.print(“\”, “);

sensors.requestTemperatures();
Serial.print(“\”OneWire-temperature0\”:\””);
Serial.print(sensors.getTempCByIndex(0));
Serial.print(“\”, “);
Serial.print(“\”OneWire-temperature1\”:\””);
Serial.print(sensors.getTempCByIndex(1));
Serial.print(“\”, “);
Serial.print(“\”OneWire-temperature2\”:\””);
Serial.print(sensors.getTempCByIndex(2));
Serial.print(“\””);
Serial.println(“}”);

delay(10000);
}