Chat freely about anything...

User avatar
By Zamfir
#12313 Nope, I got the modules but I am working on another ESP8266 project right now. I am now less convinced of the plan above. That library has, roughly speaking, two parts. One does direct access to the raw values of the MPU6050. This part should be doable to translate.

But the other part of the library is sheer byte-level magic. They give commands to the DSP of the MPU6050, and get access to the internally smoothed values according to the manufacturer's secret algorithm. I am not up to the task of translating that part.

So I might be better off tying an Arduino Nano clone to the MPU6050, as "translator", or use the Nano as main node and use the ESP8266 only for wifi
User avatar
By glebedev
#15736 I'm struggling to make it work now but the result is very unstable. For instance here is me reading who_i_am register:

Code: Select alldofile(i2c_mpu6050.lua)  Monday, April 27, 2015  00:07:51

dofile("i2c_mpu6050.lua")
who_i_am should be 104 = 0
>
dofile(i2c_mpu6050.lua)  Monday, April 27, 2015  00:07:52

dofile("i2c_mpu6050.lua")
who_i_am should be 104 = 104
>
dofile(i2c_mpu6050.lua)  Monday, April 27, 2015  00:07:55

dofile("i2c_mpu6050.lua")
who_i_am should be 104 = 255
>
dofile(i2c_mpu6050.lua)  Monday, April 27, 2015  00:07:56

dofile("i2c_mpu6050.lua")
who_i_am should be 104 = 104


As you can see the result is very unstable. What am I doing wrong?

Lua script:

Code: Select allid=0
sda=4
scl=3
mpu6050_addr=104

WHO_I_AM=117

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

-- user defined function: read from reg_addr content of dev_addr
function read_reg(dev_addr, reg_addr)
  i2c.start(id)
  i2c.address(id, dev_addr ,i2c.TRANSMITTER)
  i2c.write(id,reg_addr)
  i2c.stop(id)
  i2c.start(id)
  i2c.address(id, dev_addr,i2c.RECEIVER)
  c=i2c.read(id,1)
  i2c.stop(id)
  return c
end

x=string.byte(read_reg(mpu6050_addr,WHO_I_AM))
print("who_i_am should be 104 = " .. x)
Attachments
2015-04-27 00_14_44-ESP8266 LuaLoader 0.86.png
User avatar
By Squonk
#18925
Zamfir wrote:But the other part of the library is sheer byte-level magic. They give commands to the DSP of the MPU6050, and get access to the internally smoothed values according to the manufacturer's secret algorithm. I am not up to the task of translating that part.

It is a proprietary, but not a "secret" algorithm...

It is pretty involved, though: it is called a "Fusion" algorithm and consists in combining the raw accelerometer and gyroscope values into some useful data, not smoothing.

More information here:
https://github.com/kriswiner/MPU-6050/w ... sor-Fusion
http://www.geekmomprojects.com/gyroscop ... on-a-chip/
http://playground.arduino.cc/Main/MPU-6050
http://www.geekmomprojects.com/mpu-6050 ... /#more-876
http://www.olliw.eu/2013/imu-data-fusing/#refSM2
http://www.varesano.net/projects/hardware/FreeIMU
Last edited by Squonk on Sat May 30, 2015 3:41 am, edited 3 times in total.
User avatar
By Squonk
#18930 @Byglebedev: I just used your Lua script and it works reliably. I changed sda to pin 5 and scl to pin 6:

ESPlorer.png
ESPlorer MPU-6050

I have a NodeMCU DEVKIT V0.9 (05/12/12014) board and a no-name "MPU-6050" sensor board, I am using "nodemcu_integer_0.9.6-dev_20150406.bin", and here are the connections:
  • VCC <-> 5V
  • GND <-> GND
  • SDA <-> D5
  • SCL <-> D6

Make sure that the sensor board's VCC is connected to the 5V pin on the NodeMCU board, as the sensor board has a built-in LDO voltage regulator and pull-up resistors meant to work with this supply voltage.