Skip to content

Digital Hall Sensor Wireling Python Tutorial

This Wireling lets you measure the intensity of magnetic fields using the TCS40DLR Discrete Hall Switch.

Technical Details

Toshiba TCS40 Hall Switch Specs (Digital)

  • Omnipolar (dual detection) 
  • Open-Drain 
  • ßON = 3.4mT
  • ßOFF = 2.0mT
  • Operating Voltage: 2.3V - 5.5V
  • Operating Current: 1.0mA

Power Requirements

  • Voltage: 3.0V - 5.5V 

Pins Used

  • A5/SCL - I²C Serial Clock line
  • A4/SDA - I²C Serial Data line

Dimensions

  • 10mm x 10mm (.394 inches x .394 inches)
  • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 4.60mm (0.18 inches)
  • Weight: 1 gram (.04 ounces)

Materials

Hardware

Required Software

  • Python 3 (Python 2 is not supported!)
  • All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)

Hardware Assembly

Plug your Wireling into the port you plan on using! The default in the included program is port 0.

If you want to use a different port, you just need to change the port value in the program mentioned later.


Programming

The Wireling Python package includes helper functions that make I/O programming, like for a digital hall switch, easy. There is even an I/O example for reading the digital signal in the Wireling package that we will use here:

wireling_input-example.py
# Wireling Simple Input Example
# This example can be used with the Large Button, Small button, Switch, 
# and Digital Hall Sensor Wirelings to read the digital state

import time
import tinycircuits_wireling

wireling = tinycircuits_wireling.Wireling()

while(True):
    wireling.digitalRead(0) # Insert 0-3 correlating with the port label on pi hat
    time.sleep(0.2)

Run Program

Navigate in the terminal to the Wireling examples folder and type:

python3 wireling_input-example.py

After you run the program, you should see a 1 printed to signify a HIGH state every 0.2 seconds. Once you hold a magnet close enough to the Digital Hall Wireling, you should see a 0 printing every 0.2 seconds as it is still pressed to signify a LOW state.


Downloads


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!