Hi all!
I'm trying to write a continuous flow of temperature data + timestamp from my DS1820 sensor and serialize it in JSON format to eventually be read and deserialized by another computer. However, as I'm new to Arduino JSON I am unsure of what is needed and what are the separate elements/actions to go about this.
- What code should be added to the code below?
- Should I work with a IOT cloud server like Adafruit IO (mentioned in the ArduinoJson book)?
Thank you in advance ![]()
I have attached my arduino setup (image) and my current code
#include <DS18B20.h>
DS18B20 ds(2);
void setup() {
 Serial.begin(9600);
 Serial.print("Devices: ");
 Serial.println(ds.getNumberOfDevices());
 Serial.println();
}
void loop() {
 while (ds.selectNext()) {
  switch (ds.getFamilyCode()) {
   case MODEL_DS18S20:
    Serial.println("Model: DS18S20/DS1820");
    break;
   case MODEL_DS1822:
    Serial.println("Model: DS1822");
    break;
   case MODEL_DS18B20:
    Serial.println("Model: DS18B20");
    break;
   default:
    Serial.println("Unrecognized Device");
    break;
  }
  uint8_t address[8];
  ds.getAddress(address);
  Serial.print("Address:");
  for (uint8_t i = 0; i < 8; i++) {
   Serial.print(" ");
   Serial.print(address[i]);
  }
  Serial.println();
  Serial.print("Resolution: ");
  Serial.println(ds.getResolution());
  Serial.print("Power Mode: ");
  if (ds.getPowerMode()) {
   Serial.println("External");
  } else {
   Serial.println("Parasite");
  }
  Serial.print("Temperature: ");
  Serial.print(ds.getTempC());
  Serial.print(" C / ");
  Serial.print(ds.getTempF());
  Serial.println(" F");
  Serial.println();
 }
 delay(10000);
}
