If I don't use it, everything is working very well.
In my device I want to display the temperature on a local OLED-display like shown in the ZUNO examples. This works, but a some hours the Z-UNO is blocked.
So I made some changes in my sketch, to reproduce the error. For that, I don't use the DS18B20 but increment a variable in the loop and display that value on the OLED Display. With that the device will block after a few minutes.
I the first step I thought, it may be a memory leak somewhere. But with my my test procedure I saw that there is not a specific amount of cycles when the device stops. So there is something else going wrong. What I saw, is that the blinking of the green LED seems to be interrupted sometimes.. That means it is flickering a little bit from time to time. May be there are concurrent processes running on the device?
Nevertheless here the the sketch I used for testing.
Remark: I didn't test, if the problem will be solved by excluding the device from my HC 2.
Code: Select all
// Z-UNO used to connect a Mitsubishi A/C controller to Fibaro HC 2
// It provides the actual temperature and an ON/OFF switch.
// The device can be operated via HC 2 or with a local push button.
// Due to the small amount of ram, it was not possible to implement a connection to
// the A/C controller via IR within this device.
// So the task of sending the 288 Bit IR codes is done by an additional Arduino device.
// The Z-UNO provides an binary output to talk to the Arduino.
// September 2017
// by Michael Schmidt
#include <ZUNO_DS18B20.h>
#include <ZUNO_OLED_I2C.h>
#include <EEPROM.h>
// pin connection ds18b20
#define PIN_DS18B20 11
// Shows the state of the device
#define LED_PIN 13
// Output to control the Arduino
#define ControlPin 6
// Input for the local On/Off button
#define SWITCH_LOCAL 18
// local push button handled with ISR
ZUNO_SETUP_ISR_INT0(int0_handler);
OneWire ow(PIN_DS18B20);
// local Display for temperature an state
OLED oled;
// onewire connection temperature sensors
DS18B20Sensor ds1820(&ow);
byte addr1[8];
int temp = 0; // here we will store the actual temperature
int lastTemp = 0; // temperature during the last scan cycle
byte currentLEDValue; // Last saved LED value
float temperature;
// set up channel
ZUNO_SETUP_CHANNELS(
ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE,
SENSOR_MULTILEVEL_SCALE_CELSIUS,
SENSOR_MULTILEVEL_SIZE_TWO_BYTES,
SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
getterTemp),
ZUNO_SWITCH_BINARY(getSWBin,setSWBIN)
);
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(SWITCH_LOCAL,INPUT_PULLUP);
zunoExtIntMode(ZUNO_EXT_INT0, FALLING);
pinMode(ControlPin, OUTPUT);
digitalWrite(ControlPin, LOW);
oled.begin();
oled.clrscr();
// Get the last state before shut down
EEPROM.get(0,¤tLEDValue,1);
setSWBIN(currentLEDValue);
oled.gotoXY(0,5);
oled.print("Status : ");
if (currentLEDValue == 0)
{
oled.print("Aus");
}
else
{
oled.print("Ein");
}
oled.gotoXY(0,2);
oled.print("Temperatur: *C");
}
void loop() {
// ds1820.scanAloneSensor(addr1);
// // obtaining readings from the sensor ds18b20
// temperature = ds1820.getTemperature(addr1);
// // make scaled word value for report
// temp=int((temperature*100));
temperature += 0.01;
temp=int(temperature);
// send data to channel
// data will be send in case of a change of value only
//if (abs(temp - lastTemp) >= 5)
if (abs(temp - lastTemp) >= 0)
{
//zunoSendReport(1);
lastTemp = temp; // store the actual value for the next compare
oled.gotoXY(72,2);
oled.print(temperature);
zunoSendReport(1);
}
delay(10000);
// delay(60000);
}
// methode to update the state of the device
void setSWBIN(byte value) {
// value is a variable, holding a "new value"
// which came from the controller or other Z-Wave device
if (value > 0) { // if greater then zero
digitalWrite (LED_PIN, HIGH); //turn the LED on (HIGH is the voltage level)
} else { // if equals zero
digitalWrite(LED_PIN, LOW); //turn the LED off by making the voltage LOW
}
// we'll save our value for the situation, when the controller will ask us about it
if (currentLEDValue != value)
{
currentLEDValue = value;
// Store the actual state in EEProm
EEPROM.put(0,¤tLEDValue,1);
// Update HC 2
zunoSendReport(2);
// Update local display
oled.gotoXY(0,5);
oled.print("Status : ");
if (currentLEDValue == 0)
{
oled.print("Aus");
}
else
{
oled.print("Ein");
}
}
}
// Interrupt handler to read the local switch
void int0_handler()
{
if (currentLEDValue == 0)
{
setSWBIN(255);
}
else
{
setSWBIN(0);
}
}
// Binary value read by HC2
byte getSWBin() {
return currentLEDValue;
}
// Temperature read by HC2
word getterTemp() {
return temp;
}