When using Two-way-ranging (TWR) mode, the position of the tag is also available on the tag itself. You can retrieve it using the Arduino or Python libraries.

The Arduino and Python tutorials for the Creator series are not compatible with the Enterprise series.

In the Arduino and Python tutorials for the Creator series, the Pozyx system is completely controlled by the tag attached to your Arduino / Raspberry Pi / computer. Therefore, in these tutorials you will see things like setting the anchor coordinates, instructing the tag to start ranging, instructing the tag to start positioning, etc.

In the Enterprise series however, the Pozyx system is controlled by the gateway and the anchors attached to it: The gateway sets the anchor coordinates, instructs the anchors to start ranging with the tags, instructs the tag to calculate its position, etc. This means that you don’t have to go through all these steps when you want to retrieve the position on the tag.

The coordinates retrieved from the tag directly will be different from the coordinates retrieved from the gateway. This is because the gateway is using our newest positioning engine that doesn't run on the tag itself. The position calculation on the gateway happens with the settings you define in the web application. The position calculation on the tag happens with the settings you define via the Device Configurator:

Reading xyz

Below you can find an example script to retrieve the position directly from the tag. If you select 2D or 2.5D dimension in the Device Configurator you will need set the height of the tag in your script.

from pypozyx import (get_first_pozyx_serial_port, PozyxSerial, Coordinates)
from time import sleep

serial_port = get_first_pozyx_serial_port()

if serial_port is not None:
	pozyx = PozyxSerial(serial_port)
	print("Connection success!")
else:
	print("No Pozyx port was found")
	exit(1)

# pozyx.setHeight(1000) # For 2D and 2.5D positioning

while True:
	coordinates = Coordinates()
	pozyx.getCoordinates(coordinates)
	print(coordinates)
	sleep(0.1)
PY

Reading sensor data

Below you can find an example script to retrieve the position and the sensor data directly from the tag. If you select 2D or 2.5D dimension in the Device Configurator you will need set the height of the tag in your script.

Additional info on the functions used can be found here.
Additional info on the data structures used can be found here and here.

from pypozyx import (get_first_pozyx_serial_port, PozyxSerial, Coordinates, Acceleration, AngularVelocity, EulerAngles, LinearAcceleration, Magnetic, MaxLinearAcceleration, Pressure, Quaternion, Temperature)
from time import sleep

serial_port = get_first_pozyx_serial_port()

if serial_port is not None:
	pozyx = PozyxSerial(serial_port)
	print("Connection success!")
else:
	print("No Pozyx port was found")
	exit(1)

# pozyx.setHeight(1000) # For 2D and 2.5D positioning

def printCoordinates():
	coordinates = Coordinates()
	pozyx.getCoordinates(coordinates)
	print("Coordinates: ", coordinates.x, ", ", coordinates.y, ", ", coordinates.z)


def printAcceleration():
	acceleration_mg = Acceleration()
	pozyx.getAcceleration_mg(acceleration_mg)
	print("Acceleration: ", acceleration_mg.x, ", ", acceleration_mg.y, ", ", acceleration_mg.z)

def printAngularVelocity():
	angular_velocity_dps = AngularVelocity()
	pozyx.getAngularVelocity_dps(angular_velocity_dps)
	print("Angular velocity: ", angular_velocity_dps.x, ", ", angular_velocity_dps.y, ", ", angular_velocity_dps.z)

def printEulerAngles():
	euler_angles_deg = EulerAngles()
	pozyx.getEulerAngles_deg(euler_angles_deg)
	print("Euler angles: ", euler_angles_deg.heading, ", ", euler_angles_deg.roll, ", ", euler_angles_deg.pitch)

def printGravityVector():
	gravity_vector_mg = Acceleration()
	pozyx.getGravityVector_mg(gravity_vector_mg)
	print("Gravity vector: ", gravity_vector_mg.x, ", ", gravity_vector_mg.y, ", ", gravity_vector_mg.z)

def printLinearAcceleration():
	linear_acceleration_mg = LinearAcceleration()
	pozyx.getLinearAcceleration_mg(linear_acceleration_mg)
	print("Linear acceleration: ", linear_acceleration_mg.x, ", ", linear_acceleration_mg.y, ", ", linear_acceleration_mg.z)

def printMagnetic():
	magnetic_uT = Magnetic()
	pozyx.getMagnetic_uT(magnetic_uT)
	print("Magnetic: ", magnetic_uT.x, ", ", magnetic_uT.y, ", ", magnetic_uT.z)

def printMaxLinearAcceleration():
	max_linear_acceleration_mg = MaxLinearAcceleration()
	pozyx.getMaxLinearAcceleration_mg(max_linear_acceleration_mg)
	print("Max linear acceleration: ", max_linear_acceleration_mg.value)

def printNormalizedQuaternion():
	normalized_quaternion = Quaternion()
	pozyx.getNormalizedQuaternion(normalized_quaternion)
	print("Normalized quaternion: ", normalized_quaternion.x, ", ", normalized_quaternion.y, ", ", normalized_quaternion.z, ", ", normalized_quaternion.w)

def printPressure():
	pressure_pa = Pressure()
	pozyx.getPressure_Pa(pressure_pa)
	print("Pressure: ", pressure_pa.value)

def printQuaternion():
	quaternion = Quaternion()
	pozyx.getQuaternion(quaternion)
	print("Quaternion: ", quaternion.x, ", ", quaternion.y, ", ", quaternion.z, ", ", quaternion.w)

def printTemperature():
	temperature_c = Temperature()
	pozyx.getTemperature_c(temperature_c)
	print("Temperature: ", temperature_c.value)


while True:
	printCoordinates()
	printAcceleration()
	printAngularVelocity()
	printEulerAngles()
	printGravityVector()
	printLinearAcceleration()
	printMagnetic()
	printMaxLinearAcceleration()
	printNormalizedQuaternion()
	printPressure()
	printQuaternion()
	printTemperature()
	print()
	sleep(0.1)
PY

It's also possible to read all the sensor data with one function: getAllSensorData.
Additional info on the SensorData data structure can be found here.