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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
#include <Wire.h> //#include <SPI.h> #include <PubSubClient.h> //#include <string.h> //#include <stdio.h> #include <ESP8266WiFi.h> // Wifi settings const char* ssid = "xxxxxx"; const char* password = "xxxxxx"; const char* mqtt_server = "10.0.0.10"; // I2C address of the MPU-6050 - 0x68 or 0x69 if AD0 is pulled HIGH const int MPU = 0x68; int16_t AcX, AcY, AcZ, GyX, GyY, GyZ; float gForceX, gForceY, gForceZ, rotX, rotY, rotZ; // Wifi MAC address byte mac[]= { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; WiFiClient espClient; IPAddress ip; PubSubClient mqttClient(espClient); // IP address of your MQTT server const char* server = "10.0.0.10"; //const char* outTopic = "test/"; //const char* server = "iot.eclipse.org"; void dataReceiver(){ Wire.beginTransmission(MPU); Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) Wire.endTransmission(false); Wire.requestFrom(MPU,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) 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) processData(); } void processData(){ gForceX = AcX / 16384.0; gForceY = AcY / 16384.0; gForceZ = AcZ / 16384.0; rotX = GyX / 131.0; rotY = GyY / 131.0; rotZ = GyZ / 131.0; } void debugFunction(int16_t AcX, int16_t AcY, int16_t AcZ, int16_t GyX, int16_t GyY, int16_t GyZ){ // Print the MPU values to the serial monitor Serial.print("Accelerometer: "); Serial.print("X="); Serial.print(gForceX); Serial.print("|Y="); Serial.print(gForceY); Serial.print("|Z="); Serial.println(gForceZ); Serial.print("Gyroscope:"); Serial.print("X="); Serial.print(rotX); Serial.print("|Y="); Serial.print(rotY); Serial.print("|Z="); Serial.println(rotZ); } void reconnect() { // Loop until we're reconnected while (!mqttClient.connected()) { Serial.print("Attempting MQTT connection..."); // Attempt to connect if (mqttClient.connect("arduinoClient")){ Serial.println("connected"); } else { Serial.print("failed, rc="); Serial.print(mqttClient.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(1000); } } } void setup(){ Serial.begin(9600); Wire.begin(0,2); Wire.beginTransmission(MPU); Wire.write(0x6B); // PWR_MGMT_1 register Wire.write(0); // set to zero (wakes up the MPU-6050) Wire.endTransmission(true); mqttClient.setServer(server, 1883); // Ethernet.begin(mac); // ip = Ethernet.localIP(); Serial.println(ip); Serial.println(server); //delay(1500); } char* init(float val){ char buff[100]; for (int i = 0; i < 100; i++) { dtostrf(val, 4, 2, buff); //4 is mininum width, 6 is precision } return buff; } void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void dataAcc(){ char mpu6050X[100]= ""; strcat(mpu6050X,init(gForceX)); char mpu6050Y[100]= ""; strcat(mpu6050Y,init(gForceY)); char mpu6050Z[100]= ""; strcat(mpu6050Z,init(gForceZ)); // accelerometer - "topic, mpu6050" mqttClient.publish("AcX/", mpu6050X); mqttClient.publish("AcY/", mpu6050Y); mqttClient.publish("AcZ/", mpu6050Z); // mqttClient.publish(outTopic, "text to send via mqtt"); } void dataGy(){ char mpu6050X[100]= ""; strcat(mpu6050X,init(rotX)); char mpu6050Y[100]= ""; strcat(mpu6050Y,init(rotY)); char mpu6050Z[100]= ""; strcat(mpu6050Z,init(rotZ)); // gyroscope - "topic, mpu6050" mqttClient.publish("GyX/", mpu6050X); mqttClient.publish("GyY/", mpu6050Y); mqttClient.publish("GyZ/", mpu6050Z); // mqttClient.publish(outTopic, "text to send via mqtt"); } void loop(){ dataReceiver(); debugFunction(AcX,AcY,AcZ,GyX,GyY,GyZ); if (!mqttClient.connected()) { reconnect(); } mqttClient.loop(); dataAcc(); dataGy(); delay(2000); } |
Arduino IDE code for the ESP8266, same as above but modified for dual (2) MPU6050s. It will spit out the MPU sensor data to MQTT topics: AcX, AcY, AcZ, GyX, GyY, GyZ. And the same for MPU #2. AcX2, AcY2, etc…
Code snaked from https://github.com/jrowberg/i2cdevlib/issues/63#issuecomment-38204650
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
#include <Wire.h> //#include <SPI.h> #include <PubSubClient.h> //#include <string.h> //#include <stdio.h> #include <ESP8266WiFi.h> // Wifi settings const char* ssid = "xxxxxx"; const char* password = "xxxxxx"; const char* mqtt_server = "10.0.0.10"; // I2C address of the MPU-6050 - 0x68 or 0x69 if AD0 is pulled HIGH const int MPU = 0x68; const int MPU2 = 0x69; int16_t AcX, AcY, AcZ, GyX, GyY, GyZ; int16_t AcX2, AcY2, AcZ2, GyX2, GyY2, GyZ2; float gForceX, gForceY, gForceZ, rotX, rotY, rotZ; float gForceX2, gForceY2, gForceZ2, rotX2, rotY2, rotZ2; // Wifi MAC address byte mac[]= { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; WiFiClient espClient; IPAddress ip; PubSubClient mqttClient(espClient); // IP address of your MQTT server const char* server = "10.0.0.10"; //const char* outTopic = "test/"; void dataReceiver(){ Wire.beginTransmission(MPU); Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) Wire.endTransmission(false); Wire.requestFrom(MPU,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) 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) // processData(); Wire.beginTransmission(MPU2); Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H) Wire.endTransmission(false); Wire.requestFrom(MPU2,14,true); // request a total of 14 registers AcX2 = Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L) AcY2 = Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L) AcZ2 = Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L) GyX2 = Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L) GyY2 = Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L) GyZ2 = Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L) processData(); } void processData(){ gForceX = AcX / 16384.0; gForceY = AcY / 16384.0; gForceZ = AcZ / 16384.0; rotX = GyX / 131.0; rotY = GyY / 131.0; rotZ = GyZ / 131.0; gForceX2 = AcX2 / 16384.0; gForceY2 = AcY2 / 16384.0; gForceZ2 = AcZ2 / 16384.0; rotX2 = GyX2 / 131.0; rotY2 = GyY2 / 131.0; rotZ2 = GyZ2 / 131.0; } void debugFunction(int16_t AcX, int16_t AcY, int16_t AcZ, int16_t GyX, int16_t GyY, int16_t GyZ){ // Print the MPU values to the serial monitor Serial.print("Accelerometer: "); Serial.print("X="); Serial.print(gForceX); Serial.print("|Y="); Serial.print(gForceY); Serial.print("|Z="); Serial.println(gForceZ); Serial.print("Gyroscope:"); Serial.print("X="); Serial.print(rotX); Serial.print("|Y="); Serial.print(rotY); Serial.print("|Z="); Serial.println(rotZ); } void debugFunction2(int16_t AcX2, int16_t AcY2, int16_t AcZ2, int16_t GyX2, int16_t GyY2, int16_t GyZ2){ // Print the MPU values to the serial monitor Serial.print("Accelerometer2: "); Serial.print("X2="); Serial.print(gForceX2); Serial.print("|Y2="); Serial.print(gForceY2); Serial.print("|Z2="); Serial.println(gForceZ2); Serial.print("Gyroscope2:"); Serial.print("X2="); Serial.print(rotX2); Serial.print("|Y2="); Serial.print(rotY2); Serial.print("|Z2="); Serial.println(rotZ2); } void reconnect() { // Loop until we're reconnected while (!mqttClient.connected()) { Serial.print("Attempting MQTT connection..."); // Attempt to connect if (mqttClient.connect("arduinoClient")){ Serial.println("connected"); } else { Serial.print("failed, rc="); Serial.print(mqttClient.state()); Serial.println(" try again in 5 seconds"); // Wait 5 seconds before retrying delay(1000); } } } void setup(){ Serial.begin(9600); Wire.begin(0,2); Wire.beginTransmission(MPU); Wire.write(0x6B); // PWR_MGMT_1 register Wire.write(0); // set to zero (wakes up the MPU-6050) Wire.endTransmission(true); Wire.begin(0,2); Wire.beginTransmission(MPU2); Wire.write(0x6B); // PWR_MGMT_1 register Wire.write(0); // set to zero (wakes up the MPU-6050) Wire.endTransmission(true); mqttClient.setServer(server, 1883); // Ethernet.begin(mac); // ip = Ethernet.localIP(); Serial.println(ip); Serial.println(server); //delay(1500); } char* init(float val){ char buff[100]; for (int i = 0; i < 100; i++) { dtostrf(val, 4, 2, buff); //4 is mininum width, 6 is precision } return buff; } void setup_wifi() { delay(10); // We start by connecting to a WiFi network Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); } void dataAcc(){ char mpu6050X[100]= ""; strcat(mpu6050X,init(gForceX)); char mpu6050Y[100]= ""; strcat(mpu6050Y,init(gForceY)); char mpu6050Z[100]= ""; strcat(mpu6050Z,init(gForceZ)); // accelerometer - "topic, mpu6050" mqttClient.publish("AcX/", mpu6050X); mqttClient.publish("AcY/", mpu6050Y); mqttClient.publish("AcZ/", mpu6050Z); char mpu6050X2[100]= ""; strcat(mpu6050X2,init(gForceX2)); char mpu6050Y2[100]= ""; strcat(mpu6050Y2,init(gForceY2)); char mpu6050Z2[100]= ""; strcat(mpu6050Z2,init(gForceZ2)); // accelerometer - "topic, mpu6050" mqttClient.publish("AcX2/", mpu6050X2); mqttClient.publish("AcY2/", mpu6050Y2); mqttClient.publish("AcZ2/", mpu6050Z2); // mqttClient.publish(outTopic, "text to send via mqtt"); } void dataGy(){ char mpu6050X[100]= ""; strcat(mpu6050X,init(rotX)); char mpu6050Y[100]= ""; strcat(mpu6050Y,init(rotY)); char mpu6050Z[100]= ""; strcat(mpu6050Z,init(rotZ)); // gyroscope - "topic, mpu6050" mqttClient.publish("GyX/", mpu6050X); mqttClient.publish("GyY/", mpu6050Y); mqttClient.publish("GyZ/", mpu6050Z); char mpu6050X2[100]= ""; strcat(mpu6050X2,init(rotX2)); char mpu6050Y2[100]= ""; strcat(mpu6050Y2,init(rotY2)); char mpu6050Z2[100]= ""; strcat(mpu6050Z2,init(rotZ2)); // gyroscope - "topic, mpu6050" mqttClient.publish("GyX2/", mpu6050X2); mqttClient.publish("GyY2/", mpu6050Y2); mqttClient.publish("GyZ2/", mpu6050Z2); // mqttClient.publish(outTopic, "text to send via mqtt"); } void loop(){ dataReceiver(); debugFunction(AcX,AcY,AcZ,GyX,GyY,GyZ); debugFunction2(AcX2,AcY2,AcZ2,GyX2,GyY2,GyZ2); if (!mqttClient.connected()) { reconnect(); } mqttClient.loop(); dataAcc(); dataGy(); delay(2000); } |
Example wiring of a single MPU and ESP-01 (image borrowed from myrobotlab)
Example possible wiring of a single MPU and NodeMCU. Keep in mind that you may use different pins for the SDA/SCL on a NodeMCU because well, it has more pins. Just specify which ones you are using in the code before you flash (see code line #87 or #127 “Wire.begin(0,2)” ). (Image borrowed from FilipeFlop)
Discover more from Its_All.Lost
Subscribe to get the latest posts sent to your email.
Hi, my name is Ivanny. There are several questions I want to ask you, I also make my final project using esp8266 and mpu6050 accel gyro. I have no idea about mqtt server that you mention above.
1. how can I make my mqtt server?
2. how’s the final result? is that a table or graph?
thank you so much if you want to help me about this….
I run my mqtt server off a raspberry pi and another on an old PC running Ubuntu. It doesn’t take much to run one. I use mosquitto, but there are others.
I use the mqtt server along with Node-Red. It takes the incoming messages from my sensors and then I can do what I want with the data. So I can graph it or use a table or send SMS messages… etc. Sky is the limit really.
Hey m8 well done!
Quick question, can u provide how u connected the MPU? which wire goes where?
It all depends on which ESP module you are using. The ESP only has two pins available so you must use those (0 &2). If you look at the first example at line #87, #127 in the dual MPU example it shows “Wire.begin(0,2);”. That specifies which pins are to be used for SDA/SCL. If you are using a NodeMCU you have many choices, just specify what they are on that line.
I updated the post with some example images, hope that helps!
Hi, thank you for this…Can i get my esp-01 to mpu6050 connected to my arduino for power source?
how do i do it?
The 3.3v rail on the Arduino can only put out about 200mA of current. The ESP-01 can draw up to 435mA of current – so be careful. If you are using an Arduino Uno you can use the 5v rail, you will need to step down the voltage to 3.3v for the ESP though. Double check your MPU6050, some use 3.3v and some (like the GY-521) prefer 5v.
This also looks like what I am looking for as well. As I am pretty new at this stuff I would like to ask a question or two. I am using Arduino-1,8.5 on windows;trying to flash a nodemcu. Which libraries do I need to import/load to get this to work? I try to compile the sketch, and it always stops saying it’s missing some such library which I thought I had. I know I need pubsub. What else do I need? Sorry if this is rather basic but as I said I am rather new at this.
Thanks.
Hey there, lines 1-6 say which libraries we’re including (the others are commented out, unused).
include Wire.hinclude PubSubClient.hinclude ESP8266WiFi.h
If you include those and it still fails try to read the output message carefully, as it should tell you why it failed and point you in the direction needed.
Thanks for this sample code
I cannot see any call of the setup_wifi(); in your voide setup() loop. Am I wrong ?
I will give a try to your code later today to familiarise myself with the MQTT protocol on ESP8266.
I don’t recall, but I don’t see it either. It has been a while since I have used this code but I remember it working as posted.
Hello, My name is Nasir. This is very close of my project. I want to make motion capture system by using (ESP01s) ESP8266-01 and ADXL345 (GY-85) for animation purpose. So I will take out put in the next step to 3dsmax (real runtime) to link with 3d character.
—–
My questions are:
1. Can I use this code structure and replace MPU6050 and add GY-85 (ADXL345) ?
2. Can I send data to Java Application through TCP/IP by adding java socket to the main code?
3. any other solutions.
——-
* I use arduino IDE and CP2102 for programming.
Wiring:
* 3V3 (UART) >> 3V3 (ESP8266-01)
Ground (UART) >> Ground (ESP8266-01)
TXD (UART) >> RX (ESP8266-01)
RXD (UART) >> TXD (ESP8266-01)
EN (ESP8266) >> 3V3 (ESP8266-01)
GPIO0 (ESP8266) >> GND (ESP8266-01)
1- Blink Test:
in Arduino IDE:
Board: Generic ESP8266 Module.
Flash Mode: DIO
Flash Frequency: 40 MHZ
Reset Method: dtr aka(Nodemcu)
Upload speed: 115200
Flash size: 1MB
——————————
// The Code: (under construction)
/* Define ESP01 (ESP8266) and Wifi. */
#include
#include
#include
//ADXL345
#include
/* Set these to your desired credentials. */
const char ssid = “******”;
const char password = “********”;
ESP8266WebServer server(80);
#define DEBUG true
#define Serial if(DEBUG)Serial
#define DEVICE (0x53) // Device address as specified in data sheet
float last_value = 0;
float prelast_value = 0;
// Reading data from IMU (GY-85) Adxl345
// 5th step (to work with i2c let use the official Arduino library
#include
// 6th step (Now let us define the register in the returned access,
#define SENSOR 0x53
#define Power_Register 0x2D //Power Control Register
#define X_Axis_Register_DATAX0 0x32 //X-Axis Data 0
#define X_Axis_Register_DATAX1 0x33 //X-Axis Data 1
#define Y_Axis_Register_DATAX0 0x34 //Y-Axis Data 0
#define Y_Axis_Register_DATAX1 0x35 //Y-Axis Data 1
#define Z_Axis_Register_DATAX0 0x36 //Z-Axis Data 0
#define Z_Axis_Register_DATAX1 0x37 //Z-Axis Data 1
//also add the variable to work with x axes for, two for returned data and one for compose in float numbers the variables to work with
int DataReturned_x0, DataReturned_x1, DataModified_x_out;
float x;
int DataReturned_y0, DataReturned_y1, DataModified_y_out;
float y;
int DataReturned_z0, DataReturned_z1, DataModified_z_out;
float z;
void setup() {
Wire.begin (9600);
Serial.begin (9600);
Delay (100);
Wire.beginTransmission(SENSOR);
// Q1- which device (address) are you interest in?
Wire.beginTransmission(SENSOR);
// 2- Which register do you want to talk to?
Wire.write(Power_Register);
// 3- What do you want the register to transmit?
Wire.endTransmission();
}
void loop() {
Wire.beginTransmission(SENSOR);
// 4- What do you want to ask about the specific register?
Wire.endTransmission();
// 5- Now ask and wait for the data looping in a while
Wire.requestFrom(SENSOR, 6);
If (Wire.available() <= 6);
{
DataReturned_x0 = Wire.read();
DataReturned_x1 = Wire.read();
DataReturned_y0 = Wire.read();
DataReturned_y1 = Wire.read();
DataReturned_z0 = Wire.read();
DataReturned_z1 = Wire.read();
// 6- Now how do you want the configuration of the three axes numbers ?
DataReturned_x1 = DataReturned_x1 << 8;
DataModified_x_out = DataReturned_x0 + DataReturned_x1;
X = DataModified_x_out / 256.0;
DataReturned_y1 = DataReturned_y1 << 8;
DataModified_y_out = DataReturned_y0 + DataReturned_y1;
Y = DataModified_y_out / 256.0;
DataReturned_z1 = DataReturned_z1 << 8;
DataModified_z_out = DataReturned_z0 + DataReturned_z1;
X = DataModified_z_out / 256.0;
}
Serial.print("x = ");
Serial.println(x);
Serial.print("y = ");
Serial.println(y);
Serial.print("z = ");
Serial.println(z);
}
// The last part print data to serial, I want to send it continuously to java .
// Transmitting data to laptop (Java) through (esp01s) Wifi module.
// Java socket !!
——————————
Thanks