MPU6050 on an ESP8266-01 via MQTT

Update 3/16/17: I added code at the end of the post for dual MPU6050s
Update 2/2/18: Added images of possible wiring examples for ESP-01 and NodeMCU

Another milestone for me. I’m on a fucking roll! I found an Arduino sketch that takes an MPU6050 on an ESP8266-01  and spits it out data via MQTT. I have been looking for this and trying to accomplish this for months. My end goal is a clothes washer and dryer monitor for the family. There are sketches out there for laundry monitors but they don’t have what I need, mainly multiple users…I digress. So I found the script and it works, but some of it was it Italian which made it confusing for me and it did clumped all the sensor data into just two categories; accelerometer or gyroscope. I need more detailed information so I hacked it up a bit and it works!!

I commented out some stuff that was not needed (it all works for me YMMV), and I split all of the sensor data up into their own MQTT topic. So you get topics for AcX, AcY, AcZ and GyX, GyY, GyZ. This allows me to just use the sensor that works for the washer or dryer. Made it really easy once I plotted the data to a line graph.

Code below:
Originally taken from here

View Post

ESP8266 and the Arduino IDE on macOS

Won't Connect

Doesn’t work. Fucking go figure. There’s always something to cause a problem. If you have been following the last few posts I’ve made you would see that I have been working on ESPs all weekend. I finally got a new TTL adapter that works with the ESPs and have been playing with ESPlorer and LUA code. I decided to switch over to the Arduino IDE since there seems to be more support and tutorials for it. Well it won’t connect.

That is what I am greeted with. Well after about an hour of trying different shit I found this tidbit on the Github for Arduino issues: This is because esptool-ck doesn’t work with PL2303 based converters on OS X. Fucking great. Thats what I just bought, so I could flash the chips again. So I fired up Virtual Box and Windows 7, downloaded/installed all the needed Arduino shit and drivers and blah blah. Opened a blank sketch in the IDE, selected the ESP board and hit upload. BAM! Shit worked. Took daaays, but it worked. Fucking Apple. Looks like I’m stuck to a Windows machine no matter what I do. Sad face.

Update: So after flashing via Windows in Arduino IDE and it working I went back to macOS to try again. I changed “ck” to “nodemcu”, which didn’t work at all. So I changed it back, thats when it started working. I still had to do the reset-flash-dance. Ground GPIO02 and reset, once booted release GPIO02 and set it high, or let it float. That should put you in bootloader mode so you can flash via the Arduino IDE. I also noticed that I cannot switch back and form between the IDE and ESPlorer. They don’t play nice together. If I want to switch I have to reflash the ESP firmware. That sucks. Picky ass modules.