I have made a little progress with this Digital Hydrometer project. I must mention right from the start that my knowledge of Arduinos, electronics in general, and all that I am doing here, I know very little about! It possibly isn’t the best way at all and I will likely make mistakes – anyone that can help me out feel free to comment on improvements!
Arduino
I wired up my Arduino Uno clone and MPU-6050 according to the Fritzing diagram below, which I found here.

Then using code I found here (the code with 36 line, approx. 1/4 down the page), I got some form of tilt readings off the MPU-6050. I don’t know at this stage how to convert the raw data into recognized values (like degrees), but to be honest I don’t think I need worry. All I am interested in is getting a difference in values when the angle of tilt changes. Which this does!
Wemos D1
I then swapped the Uno clone for a Wemos D1 board I bought cheap from AliExpress. The Wemos D1 (apparently obsolete; perhaps that was why it was so cheap) is an Arduino UNO Compatible WiFi board based on ESP8266. It looks virtually the same as an Uno, but it is quite different, one difference being the pins run at 3.3V rather than Arduino’s 5V. Luckily the MPU-6050 board I am using (GY-521) which can handle both.
The wiring was as follows:
GY-521 (MPU-6050) Wemos D1
VCC –> 5V
GND –> GND
SCL –> SCL/D3
SDA –> SDA/D4
INT –> D2
(XDA, XCL, ADO not used)

You will also need to add the ESP8266 Library to the Arduino IDE, if you want it to run the Wemos D1 on the Arduino IDE (which I did). You add the library in the Arduino IDE by going to Files and click on Preferences. Copy the following into the Additional Boards Manager URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json. Click OK, and it will add the library; you should be able to find example ESP8266 sketches.
Ubidots
I then used Ubidots, a great online Internet Of Things platform, that allows you to send data from home projects online and view the data.
I added the relevant lines to my previous code (see my code at the bottom of this post) to have the tilt readings from the accelerometer sent to the cloud. This data can be visualised on a graph to see the trend, and Ubidots allows alerts to be sent which could come in handy in the future for this project.

Ubidots; raw data graphed. The downward spikes in the graph are when I tilted the acceleroometer. It doesn’t appear smooth because I chose a 3 second sampling rate.
Next Steps
Having got a prototype that reads tilt values and can send the data wirelessly to the cloud, I imagine my next steps will include adding a battery pack to power it, and enclosing it in something that will float atop the wort/beer in the fermentor, with a suitable weight to give it tilt as the density changes. I will need to make up differing sugar solutions to see what weight will be suitable, and hopefully to calibrate (with a regular hydrometer) the tilt data with a specific gravity reading.
Appendix: My Code
#include <UbidotsMicroESP8266.h>
#define TOKEN “XXXXXXXXXXXXXXXXXXXXXX” // Put here your Ubidots TOKEN
#define WIFISSID “XXXXXXXXXXXX”// Put your WiFi SSID here
#define PASSWORD “XXXXXXXXXXXX” // Put your Wifi Password here
Ubidots client(TOKEN);
#include<Wire.h>
const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void setup(){
client.wifiConnection(WIFISSID, PASSWORD);
pinMode(LED_BUILTIN, OUTPUT);
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
/*
Serial.print(“AcX = “); Serial.print(AcX);
Serial.print(” | AcY = “); Serial.print(AcY);
Serial.print(” | AcZ = “); Serial.print(AcZ);
Serial.print(” | Tmp = “); Serial.print(Tmp/340.00+36.53); //equation for temperature in degrees C from datasheet
Serial.print(” | GyX = “); Serial.print(GyX);
Serial.print(” | GyY = “); Serial.print(GyY);
Serial.print(” | GyZ = “); Serial.println(GyZ);
*/
Serial.println(AcX);
client.add(“Tilt”, AcX);
client.sendAll(true);
delay(3000);
}



