esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
15.99k stars 13.34k forks source link

Adafruit ESP8266 Huzzah, ADS115, & ADXL 377 #3106

Closed amca02 closed 7 years ago

amca02 commented 7 years ago

Hello, I am very new with using ESP8266 and I am in need of help. This is my current connections... All VCC and GND are connected to power and ground.

ADXL377 X -> ADS115 A0 ADXL377 Y -> ADS115 A1 ADXL377 Z -> ADS115 A2

ADS115 SCL -> Adafruit ESP8266 Huzzah GPIO 12 ADS115 SDA -> Adafruit ESP8266 Huzzah GPIO 14

Adafruit ESP8266 Huzzah RX -> FTDI232 TX Adafruit ESP8266 Huzzah TX -> FTDI232 RX

I am using Arduino IDE rather than LUA since I only want to read the x,y,z values of the adxl377, then send those values to thingspeak.com, so that I can export the .csv file from there. My question is how am I able to do that? With the code I am using it either prints -1 for x,y,z or gives me this error.

ets Jan 8 2013,rst cause:4, boot mode:(1,6)

wdt reset

What can I do to fix this? This is my current code. I got the code from different tutorials and using them to learn. Please help. Thank you!

include

include

include

// Wi-Fi Settings const char ssid = "XXXXXX"; // I have changed this accordingly const char password = "xxxxxx"; // Wi-Fi network password

WiFiClient client;

// ThingSpeak Settings const int channelID = xxxxx; String writeAPIKey = "xxxxxx"; // I have changed this accordingly const char* server = "api.thingspeak.com";

// ADC Converter Settings Adafruit_ADS1115 ads; / Use this for the 16-bit version / int16_t xRaw, yRaw, zRaw;

void setup() { Serial.begin(115200); WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) { delay(500); } Wire.begin(14, 12); // i2c set up ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 0.125mV ads.begin(); }

void loop() { readSensors(); if (client.connect(server, 80)) { // Construct API request body String body = "field1="; body += String(xRaw); body += "field2="; body += String(yRaw); body += "field3="; body += String(zRaw); body += "\r\n\r\n";

Serial.print("X Raw: "); Serial.println(xRaw); Serial.print("Y Raw: "); Serial.println(yRaw); Serial.print("Z Raw: "); Serial.println(zRaw); Serial.println();

client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n"); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: " + writeAPIKey + "\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(body.length()); client.print("\n\n"); client.print(body); client.print("\n\n"); } client.stop(); // wait and then post again delay(20000); } void readSensors() { xRaw = ads.readADC_SingleEnded(0); yRaw = ads.readADC_SingleEnded(1); zRaw = ads.readADC_SingleEnded(2); }

devyte commented 7 years ago

@amca02 your delay(20000) inside the loop will cause a wdt reset. The ESP requires time away from your code to service the wifi stack. Having said that, this is not the right place to ask for help for your particular project. This is an issue tracker, meant for tracking issues in the core. Please ask at esp8266.com or stackoverflow for assistance.