6 years, 7 months ago.

problems in Interfacing ESP8266 and ADXl345 with LPC1768

Hi All,

I am trying to problems interface ESP8266 and ADXl345 with LPC1768. I have tried all powering options to ESP8266 and ADXL345 1. Both With Vout of LPC1768 2. ESP8266 powered by 3.3V with USB to serial converter and ADXL345 via Vout of LPC1768. 3. ADXL345 powered by 3.3V with USB to serial converter and ESP8266 via Vout of LPC1768. 4. both with USB to serial converter. In all these cases I am able to establish connection with ESP8266 but I am not able to get ADXL345 readings and it shows (0,0,0). Can you please tell me where I am getting Wrong. my Code is as Follows. //////////////////////////////

  1. include "mbed.h" #include "arm_math.h"
  2. include "ADXL345.h"
  3. include "iostream"
  4. include "ESP8266.h"
  5. include <string>
  6. include <stdio.h>
  7. include "algorithm"
  8. include <limits.h>
  9. define APIKEY WMLMAUBBIZDFBE0I Put "Write key" of your channel in thingspeak.com
  10. define IP "184.106.153.149" IP Address of "api.thingspeak.com\"
  11. define WIFI_SSID "pravin"
  12. define WIFI_PASS "pravin83800"

char snd[255],rcv[1000],snd_Data[255]; DigitalIn sensorVal(p10); digital in pin is connected with PIR sensor to check the obstacle present? int sensorInput; ESP8266 esp(p28, p27, 115200); baud rate for wifi Serial pc(USBTX, USBRX); DigitalOut myled(LED1); ADXL345 accelerometer(p5, p6, p7, p8);

int readings[3] = {0, 0, 0}; short AccelerationsX[1025]={0}; short AccelerationsY[1025]={0}; short AccelerationsZ[1025]={0}; void esp_initialize(void); int main() { pc.printf("Starting ADXL345 test...\n"); accelerometer.setPowerControl(0x00); pc.baud(115200); esp_initialize(); Full resolution, +/-4g, 4mg/LSB. accelerometer.setDataFormatControl(0x0B);

data rate. accelerometer.setDataRate(ADXL345_400HZ);

Measurement mode. accelerometer.setPowerControl(0x08);

wait(0.1); printf("Accelerometer Data Aquisition Started \n"); accelerometer.getOutput(readings);just test for (int j=0;j<1025;j++) { accelerometer.getOutput(readings); AccelerationsX[j]=readings[0]; * acc_res_mg; AccelerationsY[j]=readings[1];* acc_res_mg; AccelerationsZ[j]=readings[2]; * acc_res_mg; 13-bit, sign extended values. pc.printf("%i, %i, %i\n", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2]); } myled = 1; wait(0.1); myled = 0; wait(0.1); } void esp_initialize(void) { pc.printf("Initializing ESP\r\n"); pc.printf("Reset ESP\r\n"); esp.Reset(); RESET ESP esp.RcvReply(rcv, 400); receive a response from ESP wait(20);

strcpy(snd,"AT"); esp.SendCMD(snd); pc.printf(snd); esp.RcvReply(rcv, 400); pc.printf(rcv); wait(20);

strcpy(snd,"AT+CWMODE=3"); esp.SendCMD(snd); pc.printf(snd); wait(20);

strcpy(snd,"AT+CWJAP=\""); strcat(snd,WIFI_SSID); strcat(snd,"\",\""); strcat(snd,WIFI_PASS); strcat(snd,"\"");

esp.SendCMD(snd); pc.printf(snd); wait(20); esp.RcvReply(rcv, 400); pc.printf("\n %s \n", rcv);

strcpy(snd,"AT+CIPMUX=0"); esp.SendCMD(snd); pc.printf(snd); esp.RcvReply(rcv, 400); pc.printf("\n %s \n", rcv); }

Serial Output is as follows. /media/uploads/pravin_kokane/putty.png

Be the first to answer this question.