Walczę o d kilku/kilkunastu dni z czujnikami temperatury DS18B20. Mam ich 10 szt gdyż chcę nimi mierzyć temperaturę przy piecu: Piec, wyjście na grzejniki, powrót, wyjście na bojler, powrót, podłogówka itp. itd. Mam jednak problem z wyświetlaniem temperatury, a mianowicie przy wgraniu programu czy do NodeMcu, czy do Arduino Mega temperatura sie nie pokazuje. Dopiero po odcięciu zasilania do czujnika "zaskakuje pomiar" i po ponownym podłączeniu zasilania już jest ok. Co może być tego przyczyną. Nie chcę biegać do Arduino za każdym zanikiem napięcia w sieci. Może nowa wersja Clouda coś nie tak współgra z Arduino?
Dla Arduino Mega pokazuje cały czas 5 stopni a dla NodeMcu nic.
Bardzo mało jest informacji na temat programowania przez ArduinoIDE - Może ktoś obcykany by zrobił jakiegoś tutoriala?
Moj program z Arduino Mega
Kod: Zaznacz cały
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SuplaDevice.h>
/*
* This example requires Dallas Temperature Control library installed.
* https://github.com/milesburton/Arduino-Temperature-Control-Library
*/
// Setup a oneWire instance
OneWire oneWire(24); // 24 - Pin number
// Pass oneWire reference to Dallas Temperature
DallasTemperature sensors(&oneWire);
// DS18B20 Sensor read implementation
double get_temperature(int channelNumber, double last_val) {
double t = -275;
if ( sensors.getDeviceCount() > 0 )
{
sensors.requestTemperatures();
t = sensors.getTempCByIndex(0);
};
return t;
}
void setup() {
Serial.begin(9600);
// Init DS18B20 library
sensors.begin();
// Set temperature callback
SuplaDevice.setTemperatureCallback(&get_temperature);
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {0x2F,0xF9,0xF2,0x22,0x97,0xC7,0xD7,0x7E,0xE6,0xF1,0x95,0x93,0xCF,0xA9,0x7D,0x71};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x00, 0x01, 0x02, 0x04, 0x03, 0x05};
/*
* Having your device already registered at cloud.supla.org,
* you want to change CHANNEL sequence or remove any of them,
* then you must also remove the device itself from cloud.supla.org.
* Otherwise you will get "Channel conflict!" error.
*/
// CHANNEL0 - RELAY
SuplaDevice.addRelay(44, true); // 44 - Pin number where the relay is connected
// Call SuplaDevice.addRelay(44, true) with an extra "true" parameter
// to enable "port value inversion"
// where HIGH == LOW, and LOW == HIGH
// CHANNEL1 - RELAY
SuplaDevice.addRelay(45, true); // 45 - Pin number where the relay is connected
// CHANNEL3 - TWO RELAYS (Roller shutter operation)
SuplaDevice.addRelay(46, true); // 46 - Pin number where the relay is connected
// CHANNEL4 - Opening sensor (Normal Open)
SuplaDevice.addSensorNO(A0); // A0 - Pin number where the sensor is connected
// Call SuplaDevice.addSensorNO(A0, true) with an extra "true" parameter
// to enable the internal pull-up resistor
// CHANNEL5 - Opening sensor (Normal Open)
SuplaDevice.addSensorNO(A1); // A1 - Pin number where the sensor is connected
// CHANNEL6 - Thermometer DS18B20
SuplaDevice.addDS18B20Thermometer();
/*
* SuplaDevice Initialization.
* Server address, LocationID and LocationPassword are available at https://cloud.supla.org
* If you do not have an account, you can create it at https://cloud.supla.org/account/create
* SUPLA and SUPLA CLOUD are free of charge
*
*/
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"svr.supla.org", // SUPLA server address
, // Location ID
" "); // Location Password
}
void loop() {
SuplaDevice.iterate();
}