So after a wile playing and a few basic tutorials. I finally started with my first serious project.
Scope of project: at the end, I like all variables of our home like energy usage, energy production, temperatures in house and temperatures of our heating pump in a dashboard.
First part of my mission is to connect multiple temperature sensors on the complete heating system. We are the owners of a heating pump and I want to learn in detail how the system reacts to tweaking. This is not only for personal use, but I think it will provide me with knowledge that is usefull to use professional ( technical installer).
So part one:
Create a dashboard with sensors to see temperature through several DS1820 sensors. Ive got the necessary items, created a sketch and installed the dashboard. Everything is working fine but one thing:
Make a fixed connection between a DS18B20 sensor and variabel in the dashboard.
I've re-write/used a lot of sketches to work with the factory serial of the sensor, but nothing wil work.
Perhaps someone can take a look and guide me (or deliver the piece of code) to the solution.
Thanks in advance. Your input is appriciated
Marco
------ Sketch--------
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/714ef962-fa37-4453-835a-dbfa8ab9b190
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float temp100;
float temp200;
float temp300;
float temp400;
float temp500;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <OneWire.h>
#include <DallasTemperature.h>
// Define variables for DS1820 sensors
#define ONE_WIRE_BUS 26 // Pin for OneWire communication
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(5000);
sensors.begin(); // initialize DallasTemperature library
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
// Request temperature to all devices on the data line
byte addr[8];
sensors.requestTemperatures();
// We can connect morte tan one IC on the same datawire. 0 refers to the first IC on the wire
// -Serial.print(sensors.getTempCByIndex(0));
// -Serial.print(sensors.getTempCByIndex(1));
// -Serial.print(" - Fahrenheit temperature; ");
Serial.print("Celsius temperature 100: ");
Serial.println(sensors.getTempCByIndex(0));
Serial.print("Celsius temperature 200: ");
Serial.println(sensors.getTempCByIndex(1));
Serial.print("Celsius temperature 300: ");
Serial.println(sensors.getTempCByIndex(2));
Serial.print("Celsius temperature 400: ");
Serial.println(sensors.getTempCByIndex(3));
Serial.print("Celsius temperature 500: ");
Serial.println(sensors.getTempCByIndex(4));
// -Serial.println(sensors.getTempFByIndex(1));
temp100=(sensors.getTempCByIndex(0));
temp200=(sensors.getTempCByIndex(1));
temp300=(sensors.getTempCByIndex(2));
temp400=(sensors.getTempCByIndex(3));
temp500=(sensors.getTempCByIndex(3));
int tempC=(sensors.getTempCByIndex(0));
// -int tempF=sensors.getTempFByIndex(0);
// -Wait for 15 seconds before sending data again
delay(5000);
}
/*
Since Teet is READ_WRITE variable, onTeetChange() is
executed every time a new value is received from IoT Cloud.
*/
void onTeetChange() {
// Add your code here to act upon Teet change
}
----- thinproperties.h ---------------------------
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char DEVICE_LOGIN_NAME[] = "XXXX";
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password
float temp100;
float temp200;
float temp300;
float temp400;
float temp500;
void initProperties(){
ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(temp100, READ, 10 * SECONDS, NULL);
ArduinoCloud.addProperty(temp200, READ, 10 * SECONDS, NULL);
ArduinoCloud.addProperty(temp300, READ, 10 * SECONDS, NULL);
ArduinoCloud.addProperty(temp400, READ, 10 * SECONDS, NULL);
ArduinoCloud.addProperty(temp500, READ, 10 * SECONDS, NULL);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

