Thank you all for the advice! I will try first with log2ram, but for long term I want to install an SSD.
A nice week to all!
Thank you all for the advice! I will try first with log2ram, but for long term I want to install an SSD.
A nice week to all!
@skywatch i have the original charger. Does it matter if the SSD is external type?
@Yveaux for how long do you use it?
Hi,
Yesterday my controller (HA) went down, after some debugging it seems that there is a problem with the memory card. Then I remembered a colleague which had similar issues but with Domoticz. My Raspberry worked for about 1 year without issues. Do you guys have the same problem? I am thinking to switch to a device (for HA) that supports different types of memory (like this or this).
Cheers!
Here is some code I use with NRF24 for a temperature sensor . So far works great with lastest HA version.
// Enable debug prints to serial monitor
//#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_NODE_ID 10
#define DEBUG 0
#define BATTERY_SENSOR 1
#include <MySensors.h>
#define TH1_CHILD_ID 11
#define VOLTAGE_CHILD_ID 12
#define TH_PIN 3
int _nominal_resistor = 4700;
int _nominal_temperature = 25;
int _b_coefficient = 3950;
int _series_resistor = 4877;
int _pin = 0;
float BatteryMin = 2.4;
float BatteryMax = 3.0;
MyMessage msgTemp(TH1_CHILD_ID, V_TEMP);
MyMessage msgVoltage(VOLTAGE_CHILD_ID, V_VOLTAGE);
void setup()
{
//Serial.begin(115200);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Temp battery", "1.0");
present(TH1_CHILD_ID, S_TEMP, "Temp");
present(VOLTAGE_CHILD_ID, S_MULTIMETER, "Batt");
}
void loop()
{
tempReport();
batteryReport();
sleep(180000);
}
// Measure VCC
float getVcc() {
#ifndef MY_GATEWAY_ESP8266
// Measure Vcc against 1.1V Vref
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = (_BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = (_BV(MUX5) | _BV(MUX0));
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = (_BV(MUX3) | _BV(MUX2));
#else
ADMUX = (_BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1));
#endif
// Vref settle
wait(70);
// Do conversion
ADCSRA |= _BV(ADSC);
while (bit_is_set(ADCSRA, ADSC)) {};
// return Vcc in mV
return (float)((1125300UL) / ADC) / 1000;
#else
return (float)0;
#endif
}
// Send a battery level report to the controller
void batteryReport() {
// measure the board vcc
float volt = getVcc();
// calculate the percentage
int percentage = ((volt - BatteryMin) / (BatteryMax - BatteryMin)) * 100;
if (percentage > 100) percentage = 100;
if (percentage < 0) percentage = 0;
#if DEBUG == 1
Serial.print(F("BATT V="));
Serial.print(volt);
Serial.print(F(" P="));
Serial.println(percentage);
#endif
#if BATTERY_SENSOR == 1
// report battery voltage
send(msgVoltage.set(volt, 3));
#endif
// report battery level percentage
sendBatteryLevel(percentage);
}
void tempReport()
{
// set TH pin in output mode
pinMode(TH_PIN, OUTPUT);
// set TH_PIN HIGH
digitalWrite(TH_PIN, HIGH);
wait(1);
// read the voltage across the thermistor
float adc = analogRead(_pin);
// set TH_PIN LOW
digitalWrite(TH_PIN, LOW);
// calculate the temperature
float reading = (1023 / adc) - 1;
reading = _series_resistor / reading;
float temperature;
temperature = reading / _nominal_resistor; // (R/Ro)
temperature = log(temperature); // ln(R/Ro)
temperature /= _b_coefficient; // 1/B * ln(R/Ro)
temperature += 1.0 / (_nominal_temperature + 273.15); // + (1/To)
temperature = 1.0 / temperature; // Invert
temperature -= 273.15; // convert to C
#if DEBUG == 1
Serial.print(F("THER I="));
Serial.print(TH1_CHILD_ID);
Serial.print(F(" V="));
Serial.print(adc);
Serial.print(F(" T="));
Serial.println(temperature);
#endif
send(msgTemp.set(temperature, 1));
}
@mtiutiu Thank you for the information! I will give it a try with the bluetooth module.
I use Home Assistant as the controller and store the relay state in the EEPROM (according to the relay example) and on top of that I have configured the node to send updates of the state (taken form EEPROM) to home assistant periodically.
@Michał-Szura I had problems with relay and HA too. The best solution was to save the state of the relay in the EEPROM and to recall the value after a defined amount of time and send it to HA in loop(). This way you do not have to restart the relay node everytime you restart HA.
@mfalkvidd Thanks for the info! Then my idea is not worth the trouble (would have to change the batteries too often).
A good day to everyone!
@Grubstake that sleep time is too much, even 2 seconds delay is not good for me. But, last night I got an idea, so I will supply the whole node with 3V. I was thinking to supply the NRF24 directly from the battery and use it as an interrupt when the gateway will transmit. According to some google-ing the stand-by current of the NRF24 is pretty low. Could this work? Do you know if the IRQ pin is used for something in mysensors?
PS: @Yveaux while loop ideea did not work as expected
@Yveaux thank you for the help! I managed to make it work. Now need to see how to optimize it to be able to run as long as possible from the batteries. I was thinking to use a while loop to check V_STATUS, send command to relay and then go to sleep.
Hi,
I am trying to build a battery (2xAA) powered node that will control a 3V latching relay (http://en.hf-relay.com/uploadfile/2019/0703/20190703021713865.pdf) single coil. The relay is drived by a H bridge (http://www.ti.com/lit/ds/symlink/drv8833.pdf). Does anyone have a working code? Programming is not my strength, I was thinking to reset (turn OFF) the relay everytime Arduino will start and to turn ON/OFF with function call:
void RelayON()
{
digitalWrite(7, HIGH);
delay(50);
digitalWrite(7, LOW);
}
The last part would be to have it run in smartSleep and wake up when state change request is sent by gateway (as far as I read this is not possible).
If you have any suggestions please let me know.
Thanks!
@sundberg84 Nice, I had hanging issues with Domoticz in the past, until I decided to switch to Home Assistant. Best decision ever.
I have tried Domoticz, Mozilla WebThings and Home Assistant. So far the best is Home Assistant, it has many integrations and a nice UI. If you want to be able to access it outsite your network I recommend ZeroTier (had many issues trying thru the router).