Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Conversation

hcharan
Copy link

@hcharan hcharan commented Oct 28, 2017

ADC1 needed to be configured for 12 bit output before calling the IDF's hall sensor function. It works, only issue might be ambiguity with machine module's ADC implementation.
Board - WEMOS Lolin32 V1.0.
It would be great if someone tests and reviews it.

@dpgeorge
Copy link
Member

This functionality might find a better home in the ADC class as a special channel (eg the 8th channel), something like:

import machine
hall = machine.ADC(8)
hall.read()

@nickzoic
Copy link
Collaborator

nickzoic commented Oct 30, 2017 via email

@hcharan
Copy link
Author

hcharan commented Oct 30, 2017

I added it to the esp module because hall sensor is esp specific functionality, similar to #192 ...
The wrapper for hall sensor was added to the Arduino port as well, so I thought the IDF implementation was complete enough to port it here.
Internally, the IDF's hall_sensor_read() function I'm calling uses channels 0-3 of the ADC1. As in http://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/adc.html?highlight=hall.

@MrSurly
Copy link
Contributor

MrSurly commented Nov 4, 2017

Tried it, and it works. Might want to return a signed integer. With no magnet, I get 110-ish. With a small strong neodymium, I can get around 1500, but flipping the other way I got 4294965952, which works out to about -1500 w/ two's complement.

@robert-hh
Copy link
Contributor

Confirmed. According to Eric's comment, I changed the last line of the function to:

    return MP_OBJ_NEW_SMALL_INT(hall_sensor_read());

The base level here is is in the 30's, and the reading is quite noisy, and dose not change with the orientation of the board. Flipping an external magnet changes the sign.

@nickzoic
Copy link
Collaborator

nickzoic commented Nov 4, 2017 via email

@nickzoic
Copy link
Collaborator

nickzoic commented Nov 26, 2017

( @hcharan and @robert-hh : Sorry for the delay, I'm continuing to follow this up with Espressif and hope we'll see a better hall_sensor_read() in the near future, at which point we can re-test this and hopefully merge it in!)

@omarahmad81
Copy link

@nickzoic Hi, any progress with a better hall_sensor_read()? Specifically with using LNA for the Hall sensor input? Eagerly waiting for it.

@dpgeorge
Copy link
Member

Support for reading the hall sensor was added upstream as esp32.hall_sensor() in commit micropython/micropython@5e5aef5

@dpgeorge dpgeorge closed this Jan 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants