Announcement

Collapse
No announcement yet.

Basic problem with SendToHS(x,x)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I got all to work!

    I'm posting the code here if anyone is interested. It's nothing fancy....but for other code newbies it might be helpful.

    In summary the code runs once when triggered by the the API Input device "Convert", when it = 255.
    Once triggered the NodeMCU converts the A/D input, then writes the result to the API Output Device.

    With this code (along with a load cell strain gauge), I can now measure the weight of the propane tank on my gas grill. From that measured analog value, I'll create a gas gauge type display (Jon00 Dashboard add on) in HS touch to display the propane tank level. In addition, when the tank is near empty an email will be sent to remind me to fill the tank!

    Mike; thank you for all your help!!

    Rick


    ------------------------------------------------------------
    Convert = FromHS[0];

    if (Convert == 0){
    count=0;
    }

    if (Convert == 255){
    if (count == 0){
    for (i=0; i<1; i++){

    int reading = analogRead(0);
    float voltage = reading / 204.6;
    Serial.print ("Reading=");
    Serial.print (reading);
    Serial.print ("\t\tVolts=");
    Serial.println (voltage);

    SendToHS(1,voltage);


    count ++;
    }

    }
    }

    Comment


    • #17
      You’re welcome. Glad you got it working. Sounds like a cool project and a great use of HomeSeer!

      Mike

      Comment


      • #18
        Hello,
        How to you write the result to the API Output Device?
        Do you have an Example?

        Andre

        Comment


        • #19
          Andre;

          Below is a sample of my code to write to the API.
          The command is "SendToHS(1,reading)" where "1" is plugin device number, not the HS3 device number.



          if (Convert == 255){
          if (count == 0){
          for (i=0; i<1; i++){

          int reading = analogRead(0);

          Serial.print ("Reading=");
          Serial.print (reading);

          SendToHS(1,reading);

          count ++;
          }

          }
          }

          Comment


          • #20
            Thanks a lot,that could help me

            Comment


            • #21
              This is a picture of the an Arduino configuration page using an API sketch. The SendToHS uses the "Input No" column on this screen This sends the data from the Arduino pin back to the HomeSeer device. The SendToHS does not use the HomeSeer device ref number, but the "Input No" below...

              Hope this helps.

              Click image for larger version

Name:	Annotation 2019-05-04 073013.jpg
Views:	19
Size:	123.6 KB
ID:	1302927
              Billy Draper

              Comment

              Working...
              X