1. HOME
  2. Products & Service
  3. Optical-magnetic sensor

Please feel free to contact us for more details, trial use, or customization.

Optical-magnetic sensor

A sensor unit that can be used to detect light and magnetism in water.
It can be used for position detection of moving parts, switching, etc.

Depth: ~ 3,500m
Magnetic sensor interface: 3.3V I2C(10bit)
Optical sensor interface: 3.3V Analog(Max 5000lx)
Dimension : 60mm×60mm×25mm

Wiring to Arduino Uno

Sample sketch

#include <Wire.h>
//
// Check for Optical magnetic sensor
// Reads the data of register addresses 0x0 to 0x4,0xb in order every 0.5s and outputs them serially.
// Addresses 0x0,0x01 are ADC results
//
int s_addr = 0x56; // Slave address : Default
//int s_addr = 0x57; // When short-circuited on the board
int wd_addr = 0x0;
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
int lower, upper;
int data = 0x0000;
// Lower
Wire.beginTransmission(s_addr);
Wire.write(0x00);
Wire.endTransmission(false);
Wire.requestFrom(s_addr, 1);
lower = Wire.read();
// Serial.print(“Lower: 0x”);
// Serial.println(lower, HEX);
// Uppwer
Wire.beginTransmission(s_addr);
Wire.write(0x01);
Wire.endTransmission(false);
Wire.requestFrom(s_addr, 1);
upper = Wire.read() & 0x03;
// Serial.print(“Upper: 0x”);
// Serial.println(upper, HEX);
data = (upper << 8) | lower;
Serial.print(“MAG Data: “);
Serial.println(data);
Serial.print(“LIGHT: “);
Serial.print(analogRead(A0) * 5.0 / 1023.0);
Serial.println(“V“);
/*
if(wd_addr == 0x4)
wd_addr = 0xb;
else if(wd_addr == 0xb)
wd_addr = 0x0;
else
wd_addr += 1;
*/
delay(1000);
// delay(500);
}