tag:blogger.com,1999:blog-5163165289293853070.post8730423986880481757..comments2024-02-20T10:05:21.350+02:00Comments on IoT with ESP8266: Various accelerometers ADXL345 with ESP8266Unknownnoreply@blogger.comBlogger15125tag:blogger.com,1999:blog-5163165289293853070.post-27559311934075385112019-11-13T17:11:52.866+02:002019-11-13T17:11:52.866+02:00Hi,
While below program is uploaded to Arduino At...Hi,<br /><br />While below program is uploaded to Arduino Atmel everything works well, have +/-2 measurements from accelerometer. When the same one is uploaded to Lolin wifi esp8266 nodemcu v3 (ESP12-E) the output is very different. Has no negative values and some of the axis jumps sudenly to 255. What is the difference here?<br /><br />#include // Wire library - used for I2C communication<br />int ADXL345 = 0x53; // The ADXL345 sensor I2C address<br />float X_out, Y_out, Z_out; // Outputs<br />void setup() {<br /> Serial.begin(115200); // Initiate serial communication for printing the results on the Serial monitor<br /> Wire.begin(); // Initiate the Wire library<br /> // Set ADXL345 in measuring mode<br /> Wire.beginTransmission(ADXL345); // Start communicating with the device<br /> Wire.write(0x2D); // Access/ talk to POWER_CTL Register - 0x2D<br /> // Enable measurement<br /> Wire.write(8); // (8dec -> 0000 1000 binary) Bit D3 High for measuring enable<br /> Wire.endTransmission();<br /> delay(10);<br />}<br />void loop() {<br /> // === Read acceleromter data === //<br /> Wire.beginTransmission(ADXL345);<br /> Wire.write(0x32); // Start with register 0x32 (ACCEL_XOUT_H)<br /> Wire.endTransmission(false);<br /> Wire.requestFrom(ADXL345, 6, true); // Read 6 registers total, each axis value is stored in 2 registers<br /> X_out = ( Wire.read()| Wire.read() << 8); // X-axis value<br /> X_out = X_out/256; //For a range of +-2g, we need to divide the raw values by 256, according to the datasheet<br /> Y_out = ( Wire.read()| Wire.read() << 8); // Y-axis value<br /> Y_out = Y_out/256;<br /> Z_out = ( Wire.read()| Wire.read() << 8); // Z-axis value<br /> Z_out = Z_out/256;<br /> Serial.print("Xa= ");<br /> Serial.print(X_out);<br /> Serial.print(" Ya= ");<br /> Serial.print(Y_out);<br /> Serial.print(" Za= ");<br /> Serial.println(Z_out);<br /> delay(10);<br />}Anonymoushttps://www.blogger.com/profile/06195850848920623220noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-55073603812091184972019-09-09T08:19:01.830+03:002019-09-09T08:19:01.830+03:00Let me know how may I help you with your project.Let me know how may I help you with your project.Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-29122493004702468952019-09-08T07:44:09.042+03:002019-09-08T07:44:09.042+03:00i need u help in iot project i need u help in iot project VIBNEShttps://www.blogger.com/profile/11033009397771266364noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-66453134878390596292017-11-21T13:10:37.204+02:002017-11-21T13:10:37.204+02:00My advice is to move to ADXL345. The 335 is old, l...My advice is to move to ADXL345. The 335 is old, limited to +/-3g and I guess it has analog outputs. Use ADXL345 since you can connect it direct to the ESP8266 so you don't need Arduino. Also has sleep mode, free fall detection and I2C and SPI outputs. Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-33262641486320994612017-11-21T13:06:40.777+02:002017-11-21T13:06:40.777+02:00This is the code I am using for the modules ADXL 3...This is the code I am using for the modules ADXL 335 & ESP8266 interfacing with arduino mega.<br />I use thing speak server for displaying the analytics. But this code only gives me X & Y output values not Z output. Though I am not good at coding,can you please give a time for correcting my code.<br />Thanks regards.<br />#include <br />#include <br />#include <br />#include <br />#include<br />Timer t;<br />#include <br />//SoftwareSerial Serial1(2, 3);<br />#define heart 13<br />char *api_key="API KEY"; // Enter your Write API key from ThingSpeak<br />static char postUrl[150];<br />void httpGet(String ip, String path, int port=80);<br /><br />const int groundpin = 18; // analog input pin 4 -- ground<br />const int powerpin = 19; // analog input pin 5 -- voltage<br />const int xpin = A3; // x-axis of the accelerometer<br />const int ypin = A2; // y-axis<br />const int zpin = A1; // z-axis (only on 3-axis models)<br /><br />void setup() {<br /> // put your setup code here, to run once:<br />Serial1.begin(115200);<br /> Serial.begin(9600);<br /> Serial.println("Connecting Wifi....");<br /> connect_wifi("AT",1000);<br /> connect_wifi("AT+CWMODE=1",1000);<br /> connect_wifi("AT+CWQAP",1000); <br /> connect_wifi("AT+RST",5000);<br /> connect_wifi("AT+CWJAP=\"admin\",\"password\"",10000);<br /> delay(5000);<br /> Serial.println("Wifi Connected"); <br /> pinMode(heart, OUTPUT);<br /> delay(2000);<br /> t.oscillate(heart, 1000, LOW);<br /> t.every(20000, send2server);<br /> <br /> pinMode(groundpin, OUTPUT);<br /> pinMode(powerpin, OUTPUT);<br /> digitalWrite(groundpin, LOW);<br /> digitalWrite(powerpin, HIGH);<br />}<br /><br />void loop() {<br /> // put your main code here, to run repeatedly:<br /> // print the sensor values:<br /> Serial.print(analogRead(xpin));<br /> // print a tab between values:<br /> Serial.print("\t");<br /> Serial.print(analogRead(ypin));<br /> // print a tab between values:<br /> Serial.print("\t");<br /> Serial.print(analogRead(zpin));<br /> Serial.println();<br /> // delay before next reading:<br /> delay(10000);<br /> t.update();<br /> <br />}<br /><br />void send2server()<br />{<br /> char xpinStr[8];<br /> char ypinStr[8];<br /> char zpinStr[8];<br /> dtostrf(xpin, 5, 3, xpinStr);<br /> dtostrf(ypin, 5, 3, ypinStr);<br /> dtostrf(zpin, 5, 3, zpinStr);<br /> sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,xpinStr, ypinStr, zpinStr);<br /> httpGet("api.thingspeak.com", postUrl, 80);<br /> }<br /><br />void httpGet(String ip, String path, int port)<br />{<br /> int resp;<br /> String atHttpGetCmd = "GET /"+path+" HTTP/1.0\r\n\r\n";<br /> //AT+CIPSTART="TCP","192.168.20.200",80<br /> String atTcpPortConnectCmd = "AT+CIPSTART=\"TCP\",\""+ip+"\","+port+"";<br /> connect_wifi(atTcpPortConnectCmd,1000);<br /> int len = atHttpGetCmd.length();<br /> String atSendCmd = "AT+CIPSEND=";<br /> atSendCmd+=len;<br /> connect_wifi(atSendCmd,1000);<br /> connect_wifi(atHttpGetCmd,1000);<br /> } <br /> <br /> void connect_wifi(String cmd, int t)<br /> {<br /> int xpin=0,i=0;<br /> while(1)<br /> {<br /> <br /> Serial.println(cmd);<br /> Serial1.println(cmd); <br /> while(Serial1.available())<br /> {<br /> if(Serial1.find("OK"))<br /><br /> i=8;<br /> }<br /> delay(t);<br /> if(i>5)<br /> break;<br /> i++;<br /> }<br /> if(i==8)<br /> {<br /> Serial.println("OK");<br /> <br /> }<br /> else<br /> {<br /> Serial.println("Error");<br /> <br /> }<br /> }Naveedhttps://www.blogger.com/profile/05801935494012860555noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-80475747527198517622017-11-21T12:56:00.088+02:002017-11-21T12:56:00.088+02:00I am using accelerometer ADXL335 and ESP8266 inter...I am using accelerometer ADXL335 and ESP8266 interfacing with arduino. I need it its code, can you please send it to me on email: naveedkhanuet@gmail.com<br />Thanks regards.<br />And the above written code is best one I have ever seen.Naveedhttps://www.blogger.com/profile/05801935494012860555noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-91612166043883997962017-07-27T13:01:02.104+03:002017-07-27T13:01:02.104+03:00You need to connect the SDA, SCL, VCC and GND. Now...You need to connect the SDA, SCL, VCC and GND. Now depending on what you want to do with ADXL345 you need the interrupt pins. First read the ADXL345 documentation. It is a good point to start with.Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-77845579303588647792017-07-27T12:39:04.022+03:002017-07-27T12:39:04.022+03:00Hi i am using module esp-12e ESP8266 Node Mcu with...Hi i am using module esp-12e ESP8266 Node Mcu with adxl 345.<br />can i use the above program. i want to measure the x, y, z acceleration . <br />MY question is <br />what is the connction with adxl 345.<br /> veramechkarthikhttps://www.blogger.com/profile/14433261876102375229noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-54567877105646010252017-04-27T12:07:47.736+03:002017-04-27T12:07:47.736+03:00I got the wifi connection working now, but very un...I got the wifi connection working now, but very unreliable it keeps losing connection and sometimes it cant find it annymore.<br /><br />How: before I could open the serial monitor the part where the ip is shown was scrolled out of view, I changed the delay to 5000 to see the ip. Then I could connect through my laptop to the wifi.<br /><br />My sensor is an ADXL module, like the one depicted above with pins on two sides but an different (older?) model. <br /><br />I haven’t gotten to calibrating yet.<br />I now have a different problem. the wifi is very unstable, and only works while the usb is connected. It doesnt want to work on 3 AA batteries with a voltage regulator, any tips, or perhaps a link to a tutorial would be much apreciated.<br /><br />Thanks for your help so far.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-20325963599776373842017-04-27T00:54:12.161+03:002017-04-27T00:54:12.161+03:00Btw what accelerometer did you used and how you di...Btw what accelerometer did you used and how you did your calibration ?Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-45681966323843754162017-04-27T00:52:15.589+03:002017-04-27T00:52:15.589+03:00You need to send the values to an MQTT broker or s...You need to send the values to an MQTT broker or send them over websocket or create a RESTfull api and get data from other app. I've did it over MQTT and over websockets and is working fine. Depend on your project and what do you want to di with your data.Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-21922424006389035932017-04-27T00:46:53.450+03:002017-04-27T00:46:53.450+03:00This may be obvious, but I am stuck, sorry if this...This may be obvious, but I am stuck, sorry if this is a stupid question.<br /><br />This appears to be working fine (I see the data in the serial monitor, and I can connect to the ESPap wifi.)<br /><br />But what do I do to see the data through the wifi connection?<br /><br />I think I need some URL or port in my browser, but cant find the right example.<br /><br />Thanks for the write-up it has already helped a lot. <br /><br />Cheers SmitjeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-7494180092975734222017-03-15T10:07:36.973+02:002017-03-15T10:07:36.973+02:00can you send me the code for it.
ashutosh0199@gmai...can you send me the code for it.<br />ashutosh0199@gmail.com<br />thanksAnonymoushttps://www.blogger.com/profile/10003093410318903226noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-89224003147624826502017-03-06T11:32:55.463+02:002017-03-06T11:32:55.463+02:00You can add the Socket.io in your sketch and send ...You can add the Socket.io in your sketch and send data over websocket directly in your web page without refresh it every time. Also decrease the last line ( delay(100) ) to a small value. Catalin B.https://www.blogger.com/profile/05005510951764417065noreply@blogger.comtag:blogger.com,1999:blog-5163165289293853070.post-37687840526377004272017-03-06T11:09:53.625+02:002017-03-06T11:09:53.625+02:00how to refresh the value of its content every 100 ...how to refresh the value of its content every 100 ms on the webpage?<br />please help.<br />great program BTWAnonymousnoreply@blogger.com