Ina219 script isue

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Ina219 script isue

#1 Post by Dick60 » 09 Apr 2023, 19:53

On my ESP8266 I loaded the 20230306 NORMAL formware. I used to have an ESP32 but that broke down.
The script I used on the ESP32 was

Code: Select all

on spanningsmeter#Voltage do  // %eventvalue% is the actual value that triggered the event
  if %eventvalue%<12.10  // Above this voltage the loader is turned on
GPIO,32,1
    endif
  if %eventvalue%>14.69// Below this voltage the loader is turned off
GPIO,32,0
     endif
endon
that worked fine but now, after modifying the ports matching the ESP8266, it does not work

Code: Select all

on spanningsmeter#Voltage do  // %eventvalue% is the actual value that triggered the event
  if %eventvalue1%<12.10 // Above this voltage the loader is turned on
GPIO,14,1
    endif
  if %eventvalue1%>14.69// Below this voltage the loader is turned off
GPIO,14,0
     endif
endon
Any reason for that?

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#2 Post by Ath » 09 Apr 2023, 20:11

Can you please be more specific on "does not work"?

Is the SPI interface enabled on the Hardware page?
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#3 Post by Dick60 » 09 Apr 2023, 20:14

as soon as the measurements go below or above the settings in the script the GPIO14 is not activated or deactivated. Also the event does not start.
Last edited by Dick60 on 09 Apr 2023, 20:39, edited 2 times in total.

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#4 Post by Ath » 09 Apr 2023, 20:28

Dick60 wrote: 09 Apr 2023, 20:14 Also the event does not start.
That is ca. 99.99% the cause, what kind of device/task is delivering that event?
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#5 Post by Dick60 » 09 Apr 2023, 20:33

It is an INA219, Voltage measurement module and turn on a Battery charger

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#6 Post by Ath » 09 Apr 2023, 20:35

Can you show the device configuration for that task?
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#7 Post by Dick60 » 09 Apr 2023, 20:42

Image Can you open the image? I did not know how to so I hope it works

TD-er
Core team member
Posts: 8757
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Ina219 script isue

#8 Post by TD-er » 09 Apr 2023, 20:53

Please double check also the task name to be "spanningsmeter"
As I get it from your post, you first tried it on an ESP32 and then tried to mirror this onto an ESP8266.
Since that task name for the INA219 isn't a default name, it is easy to overlook.

Also check to see you haven't checked the checkbox on the task page for "Single event with all values:"
When that's checked, the event will be "spanningsmeter#All" (given the task name is "spanningsmeter")

TD-er
Core team member
Posts: 8757
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Ina219 script isue

#9 Post by TD-er » 09 Apr 2023, 20:55

Hmm looking at your screenshot, you also have a input switch task for GPIO-14.
I think this may 'bite' each other if you also try to switch the GPIO pin state of that pin via rules.
Please disable that input switch task for GPIO-14 to see if this may help fix your rules issue.

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#10 Post by Dick60 » 09 Apr 2023, 21:01

14 is my Relay to turn on the 220v of the charger. Removing the 14? In that case I cannot activate the relay

TD-er
Core team member
Posts: 8757
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Ina219 script isue

#11 Post by TD-er » 09 Apr 2023, 21:06

No, disable task 2, called "RE_lader"

I think this "Switch input" task for that GPIO pin may affect the change you intend to make via rules.

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#12 Post by Dick60 » 09 Apr 2023, 21:11

I disabled the GPIO14 switch, waited for the measurement but the event is not started. But deactivating the GPIO14 than it is not possible to change the relay state because the esp doesn't know that there is a relay on GPIO14 ( I think).

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#13 Post by Ath » 09 Apr 2023, 21:19

GPIO is a core command, so doesn't need a task to be able to use it. Theoretically you should be able to use it for monitoring the state of the GPIO, but as suggested, it may interfere, as it 'claims' ownership of that GPIO, possibly blocking the GPIO command.

Btw, I don't see any screenshot yet, just the word "image", though that may be a browser/Windows issue :o
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#14 Post by Dick60 » 09 Apr 2023, 21:22

Node82b.png
Node82b.png (47.61 KiB) Viewed 2000 times
Node82a.png
Node82a.png (31.35 KiB) Viewed 2000 times
Image
Image
But I deactivated the GPIO14 but the relay was not activated
Last edited by Dick60 on 09 Apr 2023, 21:46, edited 1 time in total.

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#15 Post by Ath » 09 Apr 2023, 21:35

Please use the Attachments feature of the forum (below the text area you type your message in) to add attachments, as external services usually 'lose' your images after a couple of months, and future readers won't be able to see what happened. The forum (seems) to keep 'm indefinitely.
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#16 Post by Ath » 09 Apr 2023, 21:37

Can you check in the logs if the event spanningsmeter#Voltage is actually generated? It should show in the logs at Info level.
/Ton (PayPal.me)

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#17 Post by Dick60 » 09 Apr 2023, 21:40

This is the entry of my log:
14122771: INA219 0x40: Voltage: 12.02
14122784: EVENT: spanningsmeter#All=12.02,0,0

Dick60
Normal user
Posts: 243
Joined: 11 Feb 2018, 17:35
Location: The Netherlands

Re: Ina219 script isue

#18 Post by Dick60 » 09 Apr 2023, 21:49

I've got is. The Event is called "spanningsmeter#All ". I changed it and it is switching.
The final and working result is:

Code: Select all

on spanningsmeter#All do  // %eventvalue% is the actual value that triggered the event
  if %eventvalue1%<11.80 // Above this voltage the loader is turned on
GPIO,14,1
    endif
  if %eventvalue1%>14.20// Below this voltage the loader is turned off
GPIO,14,0
     endif
endon
Thanks for the support

User avatar
Ath
Normal user
Posts: 3522
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Ina219 script isue

#19 Post by Ath » 09 Apr 2023, 21:58

That's one of the situations mentioned by TD-er... "Single event with all values:"
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests