Chat freely about anything...

User avatar
By roccomuso
#24089 Someone can link me a tutorial on how to connect and make the MPU6050 works with the ESP?

I've heard that the MPU6050 have also a temperature sensor, is it right?
User avatar
By roccomuso
#30540 Actually i made the WHO_AM_I lua script work.. but i can't figure it out how to read the temperature and the others registers..

I'm trying to translate the arduino code: http://playground.arduino.cc/Main/MPU-6050 in lua, without success.

Here is my code:

Code: Select allid=0
sda=5 -- D5
scl=6 -- D6

mpu6050_addr=104

i2c.setup(id,sda,scl,i2c.SLOW)

 
function read_reg(dev_addr, reg_addr)
  -- WRITING
  i2c.start(id)
  i2c.address(id, dev_addr, i2c.TRANSMITTER)
  i2c.write(id, reg_addr) -- writing reg_addr in dev_addr
  i2c.stop(id)
  -- READING
  i2c.start(id)
  i2c.address(id, dev_addr, i2c.RECEIVER)
  c=i2c.read(id, 1) -- reading dev_addr
  i2c.stop(id)
  return c
end

x=string.byte(read_reg(mpu6050_addr, 65))
y=string.byte(read_reg(mpu6050_addr, 66))
sleep_reg=string.byte(read_reg(mpu6050_addr, 107)) -- 64 = 1000000
print(x.." Temperature: " .. bit.bor(bit.lshift(tonumber(x), 8), tonumber(y))) --bit.bor(bit.lshift(tonumber(x), 8), tonumber(y))



what am i doing wrong?
User avatar
By Abd.kh
#36059 Hi All,
Many thanks for all for sharing this,
i am trying to connect ESP8266 to MPU6050 , could you please send the layout of connections?