Soil moisture graph

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
insippo
Posts: 41
Joined: Sunday 26 June 2016 20:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Soil moisture graph

Post by insippo »

I use mysensors soil moisture driver. All is ok but domoticz put graph to temperature menu and write to graph window Temperature last 7days, Temperature last month, and year. How to change this?
User avatar
gizmocuz
Posts: 2712
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Soil moisture graph

Post by gizmocuz »

Your using a 100% copy of the MySensors soil example? Or are you also sending other sensors ?
if it is a copy, it should work... i think... i do not find it a good sample...

How about you change the presentation from S_HUM to S_MOISTURE ? that should give you a better sensor i suppose
Quality outlives Quantity!
insippo
Posts: 41
Joined: Sunday 26 June 2016 20:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Soil moisture graph

Post by insippo »

Yes.100% Mysensors example. Only soil moisture. Where i change S_HUM to S_MOISTURE ? In mysensors arduino sketch ? Oh. Too many questions.
trixwood

Re: Soil moisture graph

Post by trixwood »

Yes in the sketch.
insippo
Posts: 41
Joined: Sunday 26 June 2016 20:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Soil moisture graph

Post by insippo »

Okay. I change after work.
insippo
Posts: 41
Joined: Sunday 26 June 2016 20:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Soil moisture graph

Post by insippo »

#include <SPI.h>
#include <MySensor.h>

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

#define CHILD_ID_BATTERY 0
#define SLEEP_TIME 600000 // Sleep time between reads (in milliseconds)
#define STABILIZATION_TIME 500 // Let the sensor stabilize 0.5 seconds before reading
#define BATTERY_FULL 3000 // 3,000 millivolts when battery is full (assuming 2xAA)
#define BATTERY_ZERO 1700 // 1,700 millivolts when battery is empty (reqires blown brownout detection fuse, use 2,800 otherwise)
// This sketch assumes power from 2xAA on Vcc (not RAW). Remove the power led and the voltage regulator for better battery life.
// Sensors shall be connected to GND and their analog pin. Throw away the middle chip, just use the pitchfork.
// Number of analog pins for each Arduino model can be seen at https://www.arduino.cc/en/Products/Compare
// A5 and A6 on most Arduinos cannot be used because they don't have internal pullups
const int SENSORS[] = {A0, A1, A2, A3}; // Remove the pins that you don't want to use
#define N_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
long oldvoltage = 0;

MySensor gw;
MyMessage moisture_messages[N_ELEMENTS(SENSORS)];
MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);

void setup()
{
gw.begin();
gw.sendSketchInfo("Plants moisture w bat", "1.2");
gw.present(CHILD_ID_BATTERY, S_CUSTOM);
for (int sensor = 0; sensor < N_ELEMENTS(SENSORS); sensor++) {
moisture_messages[sensor].sensor = sensor + 1; // Battery uses child ID 0 so sensors start at 1
moisture_messages[sensor].type = V_HUM;
delay(250);
gw.present(sensor + 1, S_HUM);
}
for (int i = 0; i < N_ELEMENTS(SENSORS); i++) {
pinMode(SENSORS, OUTPUT);
digitalWrite(SENSORS, LOW);
}
}

void loop()
{
for (int sensor = 0; sensor < N_ELEMENTS(SENSORS); sensor++) {
pinMode(SENSORS[sensor], INPUT_PULLUP); // "Power on" the sensor and activate the internal pullup resistor
analogRead(SENSORS[sensor]); // Read once to let the ADC capacitor start charging
gw.sleep(STABILIZATION_TIME);
int moistureLevel = (1023 - analogRead(SENSORS[sensor])) / 10.23;

// Turn off the sensor to conserve battery and minimize corrosion
pinMode(SENSORS[sensor], OUTPUT);
digitalWrite(SENSORS[sensor], LOW);

gw.send(moisture_messages[sensor].set(moistureLevel));
}

long voltage = readVcc();
if (oldvoltage != voltage) { // Only send battery information if voltage has changed, to conserve battery.
gw.send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts and set wants volts and how many decimals (3 in our case)
gw.sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO)));
oldvoltage = voltage;
}
gw.sleep(SLEEP_TIME);
}

long readVcc()
{
// From http://provideyourown.com/2012/secret-a ... y-voltage/
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#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

delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA, ADSC)); // measuring

uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both

long result = (high << 8) | low;

result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
insippo
Posts: 41
Joined: Sunday 26 June 2016 20:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Soil moisture graph

Post by insippo »

Here is V_HUM and S_HUM. What exactly needed replaced ?
trixwood

Re: Soil moisture graph

Post by trixwood »

I would try the S_HUM as gizmocuz suggested. If that don't work change the other one too. I have no Idea.

You got this one from: https://forum.mysensors.org/topic/2147/ ... /24?page=1

Cuz the official one looks very different.

https://github.com/mysensors/MySensors/ ... Sensor.ino

Well, all the better, i am building that one too! at least if the last parts arrive from the hung dynasty.

The only thing I want to change is sleeptime/delay vs rate of change for smoother graphs. But that probably will reduce battery life at least half. Brainstorming away...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest