BAS.HALL on ESP32 1.44.2

Place code snippets and demo code here
Post Reply
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 120 times
Been thanked: 132 times

BAS.HALL on ESP32 1.44.2

Post by AndyGadget »

I've just had a quick fiddle with the new BAS.HALL function in 1.44.2 which accesses the on-chip Hall effect (magnetic field) sensor of the ESP32 and although it works, don't expect wonders. On the ESP32 I was using, quiescent reading was around 12 with a variation of 15 or so either side so you need to average the reading to get any meaningful results.
Using the strongest magnet I have I was able to get readings of +620 to -430 with the north and south poles.
With a smaller magnet I was getting a swing of around 300 overall so plenty to use as a non-contact method of switching, possibly to be used as an alarm disable or with multiple swipes for simple configuration setting.

Code: [Local Link Removed for Guests]

' Hall sensor
wlog "Running"
Pd = 12

do
  HVal = bas.hall
  HAve = ((HAve * (Pd - 1)) + HVal) / Pd
  
  ThUpp = HAve + 20
  ThLow = HAve - 20
  pause 200
  wlog HVal, cint(HAve)
  'if (HVal > ThUpp) then wlog "Positive trigger"
  'if (HVal < ThLow) then wlog "Negative trigger"
loop
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: BAS.HALL on ESP32 1.44.2

Post by PeterN »

Thanks for that testing.
I expected that results and so did not try to turn around my old setup with an external sensor
998B6D5E-BBF6-447E-AE63-94421A2EC20F.gif
You do not have the required permissions to view the files attached to this post.
Post Reply