Git Product home page Git Product logo

pesor / ttgo-t-higrow Goto Github PK

View Code? Open in Web Editor NEW
70.0 13.0 36.0 13.35 MB

The extremely good plant sensor named LILYGO TTGO-T-HIGrow, is here integrated into Home Assistant, via MQTT messages, that can be Autodiscovered, via the belonging Python program. The program supports both DHT sensors, the new BME280 sensor and the external soil temperature sensor.

Home Page: https://github.com/pesor/TTGO-T-HIGrow

License: MIT License

C 13.51% C++ 85.10% Processing 1.40%
autodiscover mqtt lilygo ttgo-t-higrow plant-growth plant-monitoring plants lilygo-ttgo-higrow ttgo-thigrow

ttgo-t-higrow's People

Contributors

beardedtinker avatar linusnielsen avatar maaciej avatar pesor avatar ppetermann avatar reenari avatar thecranston avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ttgo-t-higrow's Issues

Not using with Home Assistant

Hello, I'd like to use this outside of Home Assistant (MQTT - Node-Red), I have some of the older versions with a 18650 battery and DHT11's, I've set the necessary true and false in user-variables.h and I'm receiving the MQTT messages in node-red, but there are some missing and strange values.
No data from the DHT11 and daysOnBattery: 19092.7 etc. could you give some advice please?

"{"plant":{"Tgrow_HIGrow":"246f28af39e8","sensorname":"Chilli-1","date":"10-04","time":"17:31","sleep5Count":0,"bootCount":34,"lux":-2,"temp":null,"humid":null,"soil":65535,"soilTemp":0,"salt":0,"saltadvice":"needed","bat":-220,"batcharge":"","batchargeDate":"","daysOnBattery":19092.7,"battvolt":69,"battvoltage":0.12233,"pressure":0,"plantValveNo":1,"wifissid":"xxxxx","rel":"4.3.2"}}"

4.0.6 - Arduino --> VSCode and PlatformIO

@ericsebastion WROTE

just purchased the BME280 version and i cant find where to download the arduino file for this new 4.x version I was redirected to. I used the old version and the soil part shows up as working in the serial monitor but the mqtt wont connect and I don't see the temp and humid readings. Any help would be appreciated. I'm trying to use this in Home Assistant also if that helps clarify.

Home Assistant sensor config MQTT not retained and eventually sensors all become 'unavailable'

I've been seeing odd behaviour that all entities for my HIGrow show as unavailable in Home Assistant after a period of time. I found this odd as the device is running from the mains and TIME_TO_SLEEP is at the default of 3 hours (10800 seconds).

I've managed to work out that the config entry to MQTT under topic homeassistant/sensor/Tgrow_HIGrow_macaddress isn't retained and seems to disappear at "some point". I can see that my sensor had crashed on the latest occurrence of this issue and had been offline for 2 weeks while I was away. I've just power cycled it and can see a new message on the broker but the sensors show as unavailable in HA. Expected behaviour here would be that when the new data is pushed to MQTT and you're back running again. Last time this happened there was no two week gap, although I can't remember exactly what happened other than that I had to restart the broker a few times to fix an issue that it didn't have the right write permissions to save it's database and log.

My workaround for whenever this happens is to republish the config using TTGO-T-HIGrow-aut.py which restores it in HA. Must be a better way to deal with this though?

not an issue, mqtt autodiscovery idea for ha

Auto discovery is complicated, it is not working for me, I don't understand what it tries to do, so I played with code.


save-configuration.h

new function


void mqttSetup(String identyfikator, String chipId, String uom = "x" )
{

  Serial.println("*****************************************" );

  const String topicStr_c = "homeassistant/sensor/" + device_name + "-" + chipId + "/" + identyfikator +"/config";
  const char* topic_c = topicStr_c.c_str();
  Serial.println(topic_c);

  StaticJsonDocument<1536> doc_c;
  JsonObject root = doc_c.to<JsonObject>();

  root["name"] = device_name +" "+ identyfikator;
  root["state_topic"] = "homeassistant/sensor/" + device_name + "-" + chipId  + "/status";
  root["value_template"] = "{{ value_json['" + identyfikator +"'] }}";
  if ( uom != "x" ) {
    root["unit_of_measurement"] = uom;
  }
//copy of existing sending code
// // Send to mqtt
  char buffer_c[1536];
  serializeJson(doc_c, buffer_c);


  Serial.print("Sending message to topic: ");
  if (logging) {
    writeFile(SPIFFS, "/error.log", "Sending message to topic: \n");
  }

  Serial.println(buffer_c);

  // Connect to mqtt broker
  Serial.print("Attempting to connect to the MQTT broker: ");
  if (logging) {
    writeFile(SPIFFS, "/error.log", "Attempting to connect to the MQTT broker! \n");
  }

  // Serial.println(broker);
  mqttClient.setServer(broker, port);

  if (!mqttClient.connect(broker, mqttuser, mqttpass)) {
    if (logging) {
      writeFile(SPIFFS, "/error.log", "MQTT connection failed! \n");
    }

    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.state());
    // goToDeepSleepFiveMinutes();
  }

  if (logging) {
    writeFile(SPIFFS, "/error.log", "You're connected to the MQTT broker! \n");
  }

  Serial.println("You're connected to the MQTT broker!");
  Serial.println();

  bool retained = true;

  if (mqttClient.publish(topic_c, buffer_c, retained)) {
    Serial.println("Message published successfully");
  } else {
    Serial.println("Error in Message, not published");
    goToDeepSleepFiveMinutes();
  }
  Serial.println("*****************************************" );  
  Serial.println();

}

called before making json for mqtt with measure values:


  Serial.println("chipId " + chipId); //existing line

  mqttSetup("daysOnBattery", chipId);
  mqttSetup("battvoltage", chipId, "V");
  mqttSetup("bat", chipId, "%");
  mqttSetup("lux", chipId, "lx");
  mqttSetup("humid", chipId, "%");
  mqttSetup("soil", chipId, "%");
  mqttSetup("salt", chipId);
  mqttSetup("temp", chipId, "°C");

const String topicStr = "homeassistant/sensor/" + device_name + "-" + chipId + "/status"; //existing line

And with this changes measurements show itself in home assistant for me:

snap0000609

still don't know how to make the measurements to be possible to disable, I mean make them with unique entity_id

snap0000610


And question,
it seems like there somewhere is log stored and other files, how to access them?
I thought there is web server, or it should be visible as a portable drive but I can't find.
Can anybody explain how to access log?

PIN left

hi, how many pins left? I want to add 6 channel relay.

external PT100 sensor

the idea is to make use of of the external I2C UART port, adding support for DS18b20 sensors would be really useful for measuring the temperature of the soil rather than the air temperature that the integrated sensor measures.
As current firmware does not use, could you please implement it?

Thanks & Regards

Battery consumption issue, temporary fix.

This change will come in a later release, but I think you should correct your code, and upload it next time you charge a battery from a module.

This is the original code in the main.cpp
Original-text

Change it to:
change_1

I discovered this when due to the DDoS attach at one of the biggest ISP’s here in Denmark.

It made my timeClient.update() come back empty, and then it just keep looping, and ate my batteries in less than 3 hours.

With this change, module just sleeps for another hour, and tries again.

Battery Charge counting days not working

I am desperately trying to get the counter for days since last charge to work, but I really have challenges for the correct update of the counter.

I am working on this.

[Casing] Size-up hole + screw

Really nice project, already using this to monitor some plants.
Also want to monitor some outdoor plants, so was looking at your caseing, nice!

But isn't it easier to make the hole on the side a bit bigger, so you can just connect the USB-C on the port?

Auto configuration script error

Hi, running into an issue with the auto discover python script. Have tried multiple python versions just to be sure. Any thoughts?

python3 TTGO-T-HiGrow-aut.py Connected with result code 0 in on_message Tgrow_HIGrow/fcf5c40cfb10 b'{"plant":{"Tgrow_HIGrow":"fcf5c40cfb10","sensorname":"driveway_lawn","date":"30-09","time":"10:03","sleep5Count":0,"bootCount":0,"lux":523.3333,"temp":27.8,"humid":59,"soil":1,"soilTemp":0,"salt":0,"saltadvice":"needed","bat":100,"batcharge":"charging","batchargeDate":"30-09","daysOnBattery":0,"battvolt":2768,"battvoltage":4.90737,"pressure":0,"plantValveNo":1,"wifissid":"-REDACTED-","rel":"4.3.2"}}' in read_yaml Traceback (most recent call last): File "TTGO-T-HiGrow-aut.py", line 210, in <module> client.loop_forever() File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.6/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message self.on_message(self, self._userdata, message) File "TTGO-T-HiGrow-aut.py", line 196, in on_message yaml_data = read_yaml_file(mac_id, name) File "TTGO-T-HiGrow-aut.py", line 36, in read_yaml_file line_mac_id = line_mac_id_arr[1] IndexError: list index out of range

Fix Broker Port in save-configuration.h

error in save-configuration.h in line 77
mqttClient.setServer(broker, 1883);
must be
mqttClient.setServer(broker, port);
port is fixed 1883 instead of variable "port" in user-variables.h
my server works on 1884 so I find this

in go-to-deep-sleep.h in
line 7
writeFile(SPIFFS, "/error.log", "Going to sleep for 10800 seconds \n");
is fixed 10800 and not the variable "TIME_TO_SLEEP" in user-variables.h

line 32
Serial.println(" sekunder");
must be
Serial.println(" seconds");

In code remarks You're wondering what "Salt" is

The sensor measures the conductivity of the earth between the two shiny silver buttons. This is an indication of the amount of dissolved salts that the plants need as food. These values can only be approximations. And they only make sense if the soil is moist. The limit values for "needed", for example, seem to me to be set too high.
I measured once:

  • Fresh rainwater has 0 (measured value: 30µS)
  • Tap water has 78 (measured value: 588 µS)
  • Water with liquid fertiliser according to the manufacturer's instructions: 371 (measured value: 4000 µS)
    The values of the sensor are fairly linear.

This is not a criticism of your magnificent work, just a (perhaps) helpful addition.

Wakup button support

Hi pesor,

Is it possible to use the builtin "wakup" button?
It's only 1 line in go-to-deep-sleep.h

esp_sleep_enable_ext0_wakeup(GPIO_NUM_35, LOW);

Thanks:
Norbert

Core panic

My Board tells me:

SSID name: HelloG............
Connected to network
0C:9E:9D:9B:92:9C
10.10.17.6
IN VINTERTIME
Wire ok
Could not find a valid BMP280 sensor, check wiring!
BH1750 Advanced begin
lux 27.50
0
Soil before map: 3523
Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.

And reboots.
Tried with another (new) Board but it's the same.

Reliability of this TTGO version the original HiGrow

Hi,
I heard a lot of complain about the original HiGrow. Do you have any feedback on this TTGO version in term of its result and battery usage?

I have used several soil moisture sensors(analog capacitive) ranging from the 1$ low cost to 15$ from DF-Robot. I found DF-Robot to be more stable in its result and I need to ADS1115 with my esp32(ADC of Esp32 is bad, as far as I know) or it may be due to my limited knowledge on how to use it properly.

I plan to use it to manage small plot of land per sensor(1 sensor for 4x20meter row) with a few relay to manage the water.

Thanks;

BME280 and MQTT

Hello

Is it compatible with the BME280 model, as well as an MQTT connection ?

Thanks

Observation, possible issue with soil humidity measuring

I noticed it before, readings of soil humidity increases in correlation with lowering battery level:

snap0000735

now made "laboratory test", with lilygrow in glass, first there was evaporating, I fixed it, put more water and covered glass

snap0000733e

Then you can see twice, "voltage lower than 3,6V" => humidity rises.

Can it be software compensated? It is the question.
Does it have the same effect for different humidity levels?
More testing necessary.

And there comes another thing, reading depends of physical water level, I start to thinking that visible round connectors are for salt (it measure like resistance, but other way, in the air reading is 0, when I connected them with wire reading was like 3000), and the water level measurement is coming from painted surfaces, so calibration probably should take it into account and during water level calibration.

I made a test, the the water is always wet, but readings are changing during Liligo immersing into water, (and it not dry fast)

zanurzanie

So I think the calibration description should be more specific about how to put it in water, and warn that first completely dry device should be checked, before going into water, or long drying will be necessary.

Autodiscover - HowTo

@elecoq129 wrote

one more question now on the autodiscovery configuration. When you say:
T_he downloaded folder Autodiscovery, you copy to Home Assistant config folder (where you have your configuration.yaml)__

Do you mean copy the contents of the autodiscovery into config from HomeAssistant or you have to create also the directory structure and the files?

TTGO HiGrow with BME280

I have just picked up 2 HiGrow boards and both have BME280 sensors onboard which are reporting null values. Both a version 1.1 boards 19-8-22.

How do I get these sensors to report values?

Wake button does nothing, but

Wake button does nothing, but
when you change in go-to-deep-sleep.h
THIS
esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);

TO THAT

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
esp_sleep_enable_ext1_wakeup(GPIO_SEL_35, ESP_EXT1_WAKEUP_ALL_LOW);

Wake button does the same what RST button.
Almost; it keeps boot count I think, RST does not.

4.x.x integration HA on Raspberry PI

@ericsebastion

Lets start with the basics.

You are running Home Assistant on Raspberry PI!
Which version of PI?

Do you have a mqtt server running on the Raspberry PI?

Do you have a Windows10 PC, as a workstation?

This is 3 crucial questions - I need answer for, to proceed.

Fertilizier recommandations

The specifications for the breakpoints for the fertiliser recommendation from line 30 onwards in the user-variables.h do not override the specifications from main.cpp line 236 onwards in my installation. What do I do wrong?
Christian

MQTT Connection failure

Hi, I have been following bearded tinkerer's instructions to get this setup with home assistant.

I have the mosquitto MQTT broker running in home assistant, working for multiple other devices.

When I configure the user variables and flash the board, it successfully connects to wifi but cannot reach the MQTT broker, giving the error below:

Sending message to topic: {"plant":{"Tgrow_HIGrow":"c44f337fc6e1","sensorname":"","date":"06-07","time":"15:46","sleep5Count":0,"bootCount":0,"lux":835.8333,"temp":26.3,"humid":42,"soil":65535,"soilTemp":0,"salt":0,"saltadvice":"needed","bat":100,"batcharge":"charging","batchargeDate":"06-07","daysOnBattery":0,"battvolt":2752,"battvoltage":4.879004,"pressure":0,"plantValveNo":1,"wifissid":"21BTG_NoT","rel":"4.3.2"}}
Attempting to connect to the MQTT broker: 192.168.1.100
[E][WiFiClient.cpp:258] connect(): socket error on fd 55, errno: 104, "Connection reset by peer"
MQTT connection failed! Error code = -2
Going to sleep... 300 sekunder

Any help would be much appreciated. Thanks!

Not all sensor data shown in HASS

Hello @pesor

Thanks for developing this software! I've got it setup now.

The only thing i dont understand is when i monitor my sensor in visual code:

chipId 4417938f3cf8
Tgrow_HIGrow/4417938f3cf8

Sending message to topic: {"plant":{"Tgrow_HIGrow":"4417938f3cf8","sensorname":"Sensor1","date":"29-06","time":"13:08","sleep5Count":0,"bootCount":0,"lux":21.66667,"temp":25.6,"humid":64,"soil":97,"soilTemp":0,"salt":278,"saltadvice":"optimal","bat":100,"batcharge":"charging","batchargeDate":"29-06","daysOnBattery":0,"battvolt":2864,"battvoltage":5.077568,"pressure":0,"plantValveNo":1,"wifissid":"The Promised LAN","rel":"4.3.2"}}
Attempting to connect to the MQTT broker: 10.0.1.100
You're connected to the MQTT broker!

Message published successfully

I see allot more information being send to the mqtt broker then that i can i see in HASS:
https://i.imgur.com/UAmtj3V.png
There's allot of sensor data that has the value Unknown in HASS, what might be causing this?

problems with Hive MQTT broker

I'm having a problem with the connection of T-HIGrow to Hive Cloud Broker.
MQTT connection failed! Error code = -4
Going to sleep... 300 sekunder
I have checked the port, password, and user but still nothing. Does anyone face a similar issue?
It might be related to some kind of root certificate for secure connection do Hive Cloud.

Still working on it? + some questions

Hello,
I bought this board a while ago and only now have some time to work on it in order to water the plant in my office .
I also bought the Lilygo pump to hook up to the esp board (I'm planning to modify your code in order to trigger the pump when needed)

I came across BeardedTinker 2 videos on this board and your incredible work on it, thanks for that!
I just have a couple of questions:

  1. Main question: are you still working on improving this code? You've been doing a great job. I do not have enough experience with the board and your code to say if it needs improvement or not, but I am just curious to know if you plan to improve it.

  2. In BeardedTinker's second video there's an explanation about autodiscovery, the python stuff etc... I decided to leave it alone and just install the board and see what's going on.
    I was really surprised to see that, without any change in the configuration.yaml of HA the main values of the board were already autodiscovered by HA ( see below screenshot of default sensor card)
    Does it mean autodiscovery, in your latest version, does work without the python thing?

  3. Again in BeardedTinker's second video I see that the pressure is displayed on his dashboard. My board is the one without DHT sensor but with the BME one however in the mqtt status I do not have any pressure information, therefore it cannot be retrieved in HA (see below my mqtt status message). Do you have any explanation about this and how to get pressure info?

Thanks for your answers!
Eric

{
"time": "09:59:31",
"battvolt": 2687,
"battvoltage": 4.544215,
"bat": 100,
"sleep5Count": 0,
"bootCount": 12,
"device_name": "Tgrow_HIGrow",
"chipId": "083af2666f74",
"sensorname": "HiGrow_Bureau",
"date": "2024-07-10",
"batchargeDate": "2024-07-10",
"daysOnBattery": 0,
"lux": 0.833333,
"temp": 28.17,
"humid": 55.58496,
"soil": 65535,
"salt": 0,
"rel": "4.3.2mw",
"millis": 4622,
"RSSI": -63
}

image

Config Page Not Accessible

I can connect to the AP but only see dash lite. Statistics and Overview are available but no way to adjust configs.

Proposition to add RSSI measurement

It appears 7 meters with two walls is too much for LILYGO TTGO-T-HIGrow to maintain WiFi connection and I think possibility to monitor the RSSI counter can be useful.

Example of implementation:

I added it in save-configuration.h (I would name the file rather "send-measurements.h")
in the last possible place before actual sending:

plant["RSSI"] = WiFi.RSSI(); //wifiRSSI;

also with MQTT autodiscovery there is possibility to define entity in Home Assistant with proposed before function:

mqttSetup("RSSI", chipId, "dBm", "signal_strength");

and there is new version of whole file, with only one time connect to MQTT server (faster, simpler, probably saves some energy) and with variable which decide to or not print all MQTT configuration definition (print_info):

void mqttSetup(String identyfikator, String chipId, String uom = "x", String dc = "x" )
{
  bool print_info = false;

  const String topicStr_c = "homeassistant/sensor/" + device_name + "-" + chipId + "/" + identyfikator +"/config";
  const char* topic_c = topicStr_c.c_str();

  StaticJsonDocument<1536> doc_c;
  JsonObject root = doc_c.to<JsonObject>();

  root["name"] = device_name +" "+ identyfikator;

  if ( dc != "x" ) {
    root["device_class"] = dc;
  }

  root["unique_id"] = chipId +"-"+ identyfikator;
  root["state_topic"] = "homeassistant/sensor/" + device_name + "-" + chipId  + "/status";
  root["value_template"] = "{{ value_json['" + identyfikator +"'] }}";
  if ( uom != "x" ) {
    root["unit_of_measurement"] = uom;
  }

// // Send to mqtt
  char buffer_c[1536];
  serializeJson(doc_c, buffer_c);


  if (logging) {
    writeFile(SPIFFS, "/error.log", "Sending message to topic: \n");
  }

// nice print of configuration mqtt message
if (print_info) {
    Serial.println("*****************************************" );
    Serial.println(topic_c);
    Serial.print("Sending message to topic: \n");
    serializeJsonPretty(doc_c, Serial);
    Serial.println();
}

   bool retained = true;

  if (mqttClient.publish(topic_c, buffer_c, retained)) {
    if (print_info) {
      Serial.println("Message published successfully");
    }
  } else {
    if (print_info) {
        Serial.println("Error in Message, not published");
    }
    // goToDeepSleepFiveMinutes();
  }

  if (print_info) {
    Serial.println("*****************************************\n" );
  }

}


// Allocate a  JsonDocument
void saveConfiguration(const Config & config) {

  //  Serial.println(WiFi.macAddress());
  //  String stringMAC = WiFi.macAddress();
  //  stringMAC.replace(':', '_');

  byte mac[6];
  WiFi.macAddress(mac);

  //  String chipId = String(mac[0], HEX) + String(mac[1], HEX) + String(mac[2], HEX) + String(mac[3], HEX) + String(mac[4], HEX) + String(mac[5], HEX);
  String chipId = "";
  String HEXcheck = "";
  for (int i = 0; i <= 5; i++) {
    HEXcheck = String(mac[i], HEX);
    if (HEXcheck.length() == 1) {
      chipId = chipId + "0" + String(mac[i], HEX);
    } else {
      chipId = chipId + String(mac[i], HEX);
    }
  }
  Serial.println("chipId " + chipId);


 // Connect to mqtt broker
  Serial.print("Attempting to connect to the MQTT broker: ");
  if (logging) {
    writeFile(SPIFFS, "/error.log", "Attempting to connect to the MQTT broker! \n");
  }

  Serial.println(broker);
  mqttClient.setServer(broker, port);

  if (!mqttClient.connect(broker, mqttuser, mqttpass)) {
    if (logging) {
      writeFile(SPIFFS, "/error.log", "MQTT connection failed! \n");
    }

    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.state());
    goToDeepSleepFiveMinutes();
  }

  if (logging) {
    writeFile(SPIFFS, "/error.log", "You're connected to the MQTT broker! \n");
  }

  Serial.println("You're connected to the MQTT broker!");
  Serial.println();


  mqttSetup("daysOnBattery",  chipId, "x",  "duration");
  mqttSetup("battvoltage",    chipId, "V",  "voltage");
  mqttSetup("bat",            chipId, "%",  "battery");
  mqttSetup("lux",            chipId, "lx", "illuminance");
  mqttSetup("humid",          chipId, "%",  "humidity");
  mqttSetup("soil",           chipId, "%",  "humidity");
  mqttSetup("salt",           chipId, "x");
  mqttSetup("temp",           chipId, "°C", "temperature");
  mqttSetup("RSSI",           chipId, "dBm", "signal_strength");
 


  // //testing wifi strength
  //wire should be an odd multiple ( i.e. 3/4, 5/4, 7/4 etc.) of the wavelength of the 2.4GHz signal.  So it should be ~3.25cm (1.28in) for 1/4 or or ~9.75cm (3.84in) for 3/4 wavelength.
  // We saw an increase of WiFi  Range by about 2x times versus the internal antenna on the ESP32.
  
  // long rssi = 0;
    
  //   for (int i = 0 ; i < 5 ;i++){
  //       rssi += WiFi.RSSI();
  //       delay(20);
  //   }

  // float wifiRSSI = rssi/5;
  // Serial.print("WiFi RSSI = ");
  // Serial.println(wifiRSSI);

  const String topicStr = "homeassistant/sensor/" + device_name + "-" + chipId + "/status";
  const char* topic = topicStr.c_str();
  // Serial.println(ssid);

  StaticJsonDocument<1536> doc;
  // Set the values in the document
  // Device changes according to device placement
  JsonObject plant = doc.to<JsonObject>();
  
  
  // JsonObject plant = root.createNestedObject("sensor");
  plant["device_name"] = device_name;
  plant["chipId"] = chipId;
  plant["sensorname"] = plant_name;
  plant["date"] = config.date;
  plant["time"] = config.time;
  plant["batchargeDate"] = config.batchargeDate;
  plant["daysOnBattery"] = config.daysOnBattery;
  plant["battvolt"] = config.batvolt; //nie
  plant["bat"] = config.bat;
  plant["battvoltage"] = config.batvoltage;
  plant["RSSI"] = WiFi.RSSI(); //wifiRSSI;
  plant["sleep5Count"] = config.sleep5no;
  plant["bootCount"] = config.bootno;
  // plant["batcharge"] = config.batcharge; //nie
  plant["lux"] = config.lux; //nie
  plant["temp"] = config.temp;
  plant["humid"] = config.humid;
  // plant["pressure"] = config.pressure;
  plant["soil"] = config.soil;
  // plant["soilTemp"] = config.soilTemp; //nie
  plant["salt"] = config.salt;
  // plant["saltadvice"] = config.saltadvice;//nie
  // plant["plantValveNo"] = plantValveNo; //nie
  // plant["wifissid"] = WiFi.SSID(); //nie
  plant["rel"] = config.rel;

  // Send to mqtt
  char buffer[1536];
  serializeJson(doc, buffer);


  Serial.print("Sending message to topic: ");
  Serial.println(topic);
  if (logging) {
    writeFile(SPIFFS, "/error.log", "Sending message to topic: \n");
  }

  // Serial.println(buffer);
  serializeJsonPretty(doc, Serial);
  Serial.println();

 
  bool retained = true;

  if (mqttClient.publish(topic, buffer, retained)) {
    Serial.println("Message published successfully");
  } else {
    Serial.println("Error in Message, not published");
    goToDeepSleepFiveMinutes();
  }
  Serial.println();
}


snap0000674

The two new modules suggested in issues

I have been a little under the weather for some time, due to a lot of work.

I will today look into the two suggested new scripts and integrate them into a new release, when tested and approwed.

Autodiscover in Raspi 4

Hi pesor,

thank you fpr the whole wiki.

I really like to bring it to work on a my raspiberry pi. I studied again and again the youtube vids and the Wiki. It all works fine for me. The sensor is connecting to the MQTT broker und publishes the message succesfully. And then I stop because I don't know how to execute the "TTGO-T-HIGrow-aut.py" via python.

  • Via putty: There ist no python to start on raspi for starting the "TTGO-T-HIGrow-aut.py"

  • Via Add-On "Visual Studio Code" in Homeassistant: There is the wrong python-version and therefore no paho-mqtt.

  • Via eric IDE I don't know how to start the "TTGO-T-HIGrow-aut.py" on raspi, Home Assistant from the WIN 10 Eric IDE

I really don't want to throw the towel after those hours of trying and i'm very interested in getting things done. Can you please tell me, how to do it in raspi or is it not possible. When it is the second point, can you tell me whre to find how to integrate the sensor manually in home assistant?

Thank you so much. Up to this point, I am very disappointed. If you can help me, It woul be a pleasure for me.

front0708

WiFi connected but no DHCP

I'm not sure what happened other than I made a change to the sleep length and re-uploaded...

I see the esp32 connect to my WiFi access point, however I don't see a DHCP request going out.
The AP shows an association but no IP address.
The esp32 is "stuck" with this continuous error in the serial console:
[xxxx][E][WiFiUdp.cpp:170] beginPacket(): could not get host from dns: 11
where the [xxxx] is an ever increasing number.

I've tried using esptool.py to erase the SPI flash and start over thinking something got corrupted there. No change in behaviour.
I'm thinking something is out of compatibility spec in the platform.io environment, but alas I'm lost there. really just following BeardedTinker's video/docs on how to build the project. It did auto update a bunch of libraries and maybe that's the issue. Any help is apprecaited.

I've also tried fully ripping out VSC and platform.io and starting over. Same result. Not sure what is breaking.
pio core 5.2.5 home 3.4.1 with espressif 4.1.0

I know the WiFi is physically working as I went back to Arduino IDE and was able to get the http client example sketch to work just fine.

And some pause before submitting and a little google searching and I find a recommended adjustment:

#include <WiFi.h>
void setup() {
  Serial.begin(115200);
  WiFi.begin(); //Put ssid, passwd in here if needed
  WiFi.waitForConnectResult();
  Serial.println(WiFi.dnsIP());
  WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), WiFi.dnsIP()); 
  delay(10);
  Serial.println(WiFi.dnsIP());
}

Tested locally and can confirm it works now.

Fertilizer reporting in percentage rather than µS/cm

First - Thanks for this great project. Really appreciate you and @BeardedTinker working on this!

I’m noticing that the output from the HiGrow sensor for the fertilization level is retuning a % value. But strangely - it looks like the value can sometimes be high ( seeing 399% on one sensor. ) Given that I’ve mapped the sensor._name_fertilizer into the conductivity key for the HomeAssistant Plant integration. Should we think of the fertilizer value as mapping direction to the µS/cm value? Ie. The max/min conductivity values for the Plant integration should still apply?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.