MD R. Islam
Published © Apache-2.0

Mapping Road Conditions

Map road conditions by using Infineon's 3D magnetic sensor.

BeginnerFull instructions provided1 hour3,322

Things used in this project

Story

Read more

Code

Recording + sensor collection

Python
Record using Pi Camera + Infineon 3D Magnet Sensor
import serial
import picamera

camera = picamera.PiCamera()
camera.rotation = 180

ser = serial.Serial('/dev/ttyACM0')

with open('log.txt', 'w') as log_file:
 camera.start_recording('/home/pi/video.h264')
 while True:
     msg = ''
     c = ser.read(1).decode('utf-8')
     while c != '\n':
         c = ser.read(1).decode('utf-8')
     c = ser.read(1).decode('utf-8')
     while c != '\n':
         msg += c
         c = ser.read(1).decode('utf-8')
     print('Writing', msg)
     log_file.write(msg + '\n')
 camera.close()

rw_sensor_data_cr50sf0sDF.py

Python
Steam sensor data to file
import serial

ser = serial.Serial('/dev/ttyACM0')

with open('log.txt', 'w') as log_file:
  
  while True:
      msg = ''
      c = ser.read(1).decode('utf-8')
      while c != '\n':
          c = ser.read(1).decode('utf-8')
      c = ser.read(1).decode('utf-8')
      while c != '\n':
          msg += c
          c = ser.read(1).decode('utf-8')
      print('Writing', msg)
      log_file.write(msg + '\n')

Raw log data for Demo

Tex
This is the raw log data collected for the demo where the car goes over a PC case
13.13 ; 3.25 ; 5.85
13.00 ; 3.38 ; 5.98
13.00 ; 3.12 ; 6.11
13.13 ; 2.99 ; 6.11
13.52 ; 2.99 ; 4.16
13.39 ; 3.77 ; 6.76
14.43 ; 3.64 ; 6.76
13.91 ; 4.03 ; 7.02
12.22 ; 2.99 ; 4.68
14.30 ; 2.34 ; 6.50
11.05 ; 3.25 ; 5.72
14.30 ; 3.38 ; 4.55
15.47 ; 2.73 ; 6.11
9.23 ; 4.16 ; 4.81
17.16 ; 3.64 ; 5.72
15.08 ; 4.68 ; 5.20
12.87 ; 4.81 ; 5.33
12.87 ; 4.81 ; 5.20
13.00 ; 4.68 ; 5.33
14.69 ; 4.42 ; 4.03
18.59 ; 2.60 ; 4.94
13.39 ; 4.55 ; 5.07
10.53 ; 4.03 ; 5.46
14.43 ; 4.81 ; 5.59

Cartesian Arduino Sketch

Credits

MD R. Islam

MD R. Islam

7 projects • 13 followers
software engineer

Comments