Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By amca02
#64462 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 14
ADS115 SDA -> Adafruit ESP8266 Huzzah GPIO 12
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? How does the ESP8266 know that its reading values from the ADS115? This is my current code. I got the code from different labs and using this to learn. Please help. Thank you!

#include <ESP8266WiFi.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
// 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 */
//Maximum value of ADS
#define ADC_COUNTS 32768
#define PHASECAL 1.7
#define VCAL 0.6
#define ICAL 0.003
int16_t xRaw, yRaw, zRaw;
void setup()
{
Serial.begin(115200);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
Wire.begin(12, 14); // 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";
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);
}