sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
227 stars 121 forks source link

Capacitive Soil Moisture Sensor data not Reaching Alexa #371

Closed DougpUK closed 2 months ago

DougpUK commented 3 months ago

Hi, are you still supporting this project?

I have been looking for a project to use as a basis for communicating between ESP8266 / ESP32 and Alexa.

This is a great project and very well written! I have followed the instructions exactly, except for the Locale in the device template which I have set to UK English and the TODO items in the code.

I'm getting some fascinating results. With debug set to SSL and HTTP_CLIENT and viewing the Serial Monitor, the ESP8266 (NodeMCU 1.0) seems to be happily sending data to Sinric Pro:

    [SinricPro:handleSendQueue]: Sending to websocket
    [SinricPro:handleSendQueue()]: message sent.
    [SinricPro:handleSendQueue()]: 1 message(s) in sendQueue
    [SinricPro:handleSendQueue()]: Sending message...
    {
      "header": {
        "payloadVersion": 2,
        "signatureVersion": 1
      },
      "payload": {
        "action": "setRangeValue",
        "cause": {
          "type": "PHYSICAL_INTERACTION"
        },
        "createdAt": 1711447997,
        "deviceId": "xxxxxxxxxxxx",
        "replyToken": " xxxxxxxxxxxxxxxx",
        "type": "event",
        "value": {
          "rangeValue": 3
        },
        "instanceId": "rangeInstance1"
      },
      "signature": {
        "HMAC": "yHZv8LZrq5J32fZv5EcCgGQtLspx6z2xxxxxxxxxxxxx"
      }
    }

And

      [SinricPro:handleSendQueue]: Sending to websocket
      [SinricPro:handleSendQueue()]: message sent.
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 1024. as a percentage: 100%
      Soil moisture did not changed. do nothing...!
      Soil Moisture: 3. as a percentage: 1%
      [SinricPro:sendMessage()]: pushing message into sendQueue
      [SinricPro:sendMessage()]: pushing message into sendQueue

And

      [SinricPro:handleSendQueue]: Sending to websocket
      [SinricPro:handleSendQueue()]: message sent.
      [SinricPro:handleSendQueue()]: 1 message(s) in sendQueue
      [SinricPro:handleSendQueue()]: Sending message...
      {
        "header": {
          "payloadVersion": 2,
          "signatureVersion": 1
        },
        "payload": {
          "action": "pushNotification",
          "cause": {
            "type": "ALERT"
          },
          "createdAt": 1711448537,
          "deviceId": "xxxxxxxxxxx",
          "replyToken": "xxxxxxxxxx",
          "type": "event",
          "value": {
            "alert": "Plants are too dry. Time to water the plants!"
          }
        },
        "signature": {
          "HMAC": "OU0GBYAXIyOhqM9RMICmIMF3Jxu0dOxxxxxxxxxx"
        }
      }
      [SinricPro:handleSendQueue]: Sending to websocket
      [SinricPro:handleSendQueue()]: message sent.

The Sinric Pro dashboard currently says that the device is online and moisture is 1024%

image

I have modified the following levels:

  const int VERY_DRY = 8; // TODO: This is when soil is dry. Adjust according to your sensor
  const int VERY_WET = 900; // TODO: This is when soil is wet. Adjust according to your sensor
  const int NEITHER_DRY_OR_WET = 500; // TODO: This is when soil is neither wet or dry. Adjust according to your sensor
  const int DRY_PUSH_NOTIFICATION_THRESHHOLD = 200; // TODO: This is when to send a push notification to the mobile phone. 
  const int UNPLUGGED = 1024; // This is the value sensor produce when it's not in the ground.

The Alexa I have is Echo Dot 5th generation 2022 release - up to date. I have asked Alexa to scan for new devices but she didn't find any.

I tried saying, "Alexa, What’s the moisture in garden", but she tells me about a gardening programme. I then tried saying, "Alexa, What’s the moisture level in garden", again she quotes something from the Internet about gardening.

What additional information do you need to help me to "connect" with Alexa please? Many thanks

kakopappa commented 3 months ago

Hi.

Yes we are supporting this project since 2019 :)

According to the log, ESP is sending 1024% that could be the reason Alexa doesn’t like it. Can you please send a fix value eg: 50 and see whether that reflects. You may need to rescan for devices after doing so

On Tue, 26 Mar 2024 at 5:42 PM DougpUK @.***> wrote:

Hi, are you still supporting this project?

I have been looking for a project to use as a basis for communicating between ESP8266 / ESP32 and Alexa.

This is a great project and very well written! I have followed the instructions exactly, except for the Locale in the device template which I have set to UK English and the TODO items in the code.

I'm getting some fascinating results. With debug set to SSL and HTTP_CLIENT and viewing the Serial Monitor, the ESP8266 (NodeMCU 1.0) seems to be happily sending data to Sinric Pro:

[SinricPro:handleSendQueue]: Sending to websocket
[SinricPro:handleSendQueue()]: message sent.
[SinricPro:handleSendQueue()]: 1 message(s) in sendQueue
[SinricPro:handleSendQueue()]: Sending message...
{
  "header": {
    "payloadVersion": 2,
    "signatureVersion": 1
  },
  "payload": {
    "action": "setRangeValue",
    "cause": {
      "type": "PHYSICAL_INTERACTION"
    },
    "createdAt": 1711447997,
    "deviceId": "xxxxxxxxxxxx",
    "replyToken": " xxxxxxxxxxxxxxxx",
    "type": "event",
    "value": {
      "rangeValue": 3
    },
    "instanceId": "rangeInstance1"
  },
  "signature": {
    "HMAC": "yHZv8LZrq5J32fZv5EcCgGQtLspx6z2xxxxxxxxxxxxx"
  }
}

And

  [SinricPro:handleSendQueue]: Sending to websocket
  [SinricPro:handleSendQueue()]: message sent.
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 1024. as a percentage: 100%
  Soil moisture did not changed. do nothing...!
  Soil Moisture: 3. as a percentage: 1%
  [SinricPro:sendMessage()]: pushing message into sendQueue
  [SinricPro:sendMessage()]: pushing message into sendQueue

And

  [SinricPro:handleSendQueue]: Sending to websocket
  [SinricPro:handleSendQueue()]: message sent.
  [SinricPro:handleSendQueue()]: 1 message(s) in sendQueue
  [SinricPro:handleSendQueue()]: Sending message...
  {
    "header": {
      "payloadVersion": 2,
      "signatureVersion": 1
    },
    "payload": {
      "action": "pushNotification",
      "cause": {
        "type": "ALERT"
      },
      "createdAt": 1711448537,
      "deviceId": "xxxxxxxxxxx",
      "replyToken": "xxxxxxxxxx",
      "type": "event",
      "value": {
        "alert": "Plants are too dry. Time to water the plants!"
      }
    },
    "signature": {
      "HMAC": "OU0GBYAXIyOhqM9RMICmIMF3Jxu0dOxxxxxxxxxx"
    }
  }
  [SinricPro:handleSendQueue]: Sending to websocket
  [SinricPro:handleSendQueue()]: message sent.

The Sinric Pro dashboard currently says that the device is online and moisture is 1024%

image.png (view on web) https://github.com/sinricpro/esp8266-esp32-sdk/assets/73337513/323c93a1-7e97-4687-ac8f-34f86599be0d

I have modified the following levels:

const int VERY_DRY = 8; // TODO: This is when soil is dry. Adjust according to your sensor const int VERY_WET = 900; // TODO: This is when soil is wet. Adjust according to your sensor const int NEITHER_DRY_OR_WET = 500; // TODO: This is when soil is neither wet or dry. Adjust according to your sensor const int DRY_PUSH_NOTIFICATION_THRESHHOLD = 200; // TODO: This is when to send a push notification to the mobile phone. const int UNPLUGGED = 1024; // This is the value sensor produce when it's not in the ground.

The Alexa I have is Echo Dot 5th generation 2022 release - up to date. I have asked Alexa to scan for new devices but she didn't find any.

I tried saying, "Alexa, What’s the moisture in garden", but she tells me about a gardening programme. I then tried saying, "Alexa, What’s the moisture level in garden", again she quotes something from the Internet about gardening.

What additional information do you need to help me to "connect" with Alexa please? Many thanks

— Reply to this email directly, view it on GitHub https://github.com/sinricpro/esp8266-esp32-sdk/issues/371, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZTG4OJYRUO5CZVUFALY2E7JNAVCNFSM6AAAAABFIVGQD2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYDOOBYGQZTSMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

DougpUK commented 3 months ago

Hi, Thank you for such an amazingly quick response. I didn't know that I had to link Sinric Pro with Alexa, though I wondered how this would happen. I found the answer here: https://iotcircuithub.com/sinric-pro-alexa-home-automation/

I now have Alexa connected to Sinric Pro which is fantastic.
However, the output to the Sinric Pro dashboard and to Alexa is still the value output by the sensor / ESP8266 and not the percentage. Should I modify the map command to get the percentage?

Thank you so much :-)

sivar2311 commented 3 months ago

Should I modify the map command to get the percentage?

Yes you need to map the raw sensor reading to a percentage value.

kakopappa commented 3 months ago

Hi @DougpUK

updateMoistureLevel(soilMoisture); should be updateMoistureLevel(percentage); I have updated the tutorial Thanks!

github-actions[bot] commented 3 months ago

This issue has gone quiet. Spooky quiet. We currently close issues after 14 days of inactivity. It’s been at least 7 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks for being a part of the SinricPro community!

github-actions[bot] commented 2 months ago

Hey again! It’s been 14 days since anything happened on this issue, so our friendly robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else. As a friendly reminder, the best way to fix this or any other problem is to provide a detailed error description including a serial log. Thanks again for being a part of the SinricPro community!

DougpUK commented 2 months ago

Thank you for your help. It has set me on the road to success. :-)