Comments (5)
I was trying following program
#include <driver/i2c.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include
#include
#include
#include
#include "nvs_flash.h"
#include "sdkconfig.h"
#include "ADXL355.h"
#define SDA_PIN 42
#define SCL_PIN 22
// static char tag[] = "i2cscanner";
using namespace std;
void calibrateSensor(ADXL355 &sensor, int fifoReadCount);
void task_i2cscanner(void *ignore) {
ADXL355 sensor(0x1d, (gpio_num_t)SDA_PIN, (gpio_num_t)SCL_PIN);
cout << "Analog Devices ID = " << (int)sensor.GetAnalogDevicesID() << endl; // Always 173
cout << "Analog Devices MEMS ID = " << (int)sensor.GetAnalogDevicesMEMSID() << endl; // Always 29
cout << "Device ID = " << (int)sensor.GetDeviceId() << endl; // Always 237 (355 octal)
cout << "Revision = " << (int)sensor.GetRevision() << endl;
sensor.Stop();
sensor.SetRange(ADXL355::RANGE_VALUES::RANGE_8G);
ADXL355::RANGE_VALUES rangeValue = sensor.GetRange();
switch (rangeValue)
{
case ADXL355::RANGE_VALUES::RANGE_2G:
cout << "Range 2g" << endl;
break;
case ADXL355::RANGE_VALUES::RANGE_4G:
cout << "Range 4g" << endl;
break;
case ADXL355::RANGE_VALUES::RANGE_8G:
cout << "Range 8g" << endl;
break;
default:
cout << "Unknown range" << endl;
break;
}
sensor.SetOdrLpf(ADXL355::ODR_LPF::ODR_31_25_AND_7_813);
cout << "Low pass filter = " << sensor.GetOdrLpf() << endl;
ADXL355::HPF_CORNER hpfCorner = sensor.GetHpfCorner();
cout << "hpfCorner = " << hpfCorner << endl;
ADXL355::ODR_LPF OdrLpf = sensor.GetOdrLpf();
cout << "OdrLpf = " << OdrLpf << endl;
calibrateSensor(sensor, 5);
sensor.StartTempSensor();
cout << "Temperature is " << sensor.GetTemperatureF() << "F" << endl;
int32_t x = 0;
int32_t y = 0;
int32_t z = 0;
// for (int i = 0; i < 10; i++)
while (true)
{
if (0 == sensor.GetRawAxes(&x, &y, &z))
{
cout << "Axes received: x="
<< ADXL355::ValueToGals(x)
<< ";y="
<< ADXL355::ValueToGals(y)
<< ";z="
<< ADXL355::ValueToGals(z)
<< endl;
}
vTaskDelay(500 / portTICK_RATE_MS);
}
cout << "FIFO entries = " << sensor.GetFifoCount() << endl;
if (sensor.IsFifoFull())
cout << "FIFO is full" << endl;
if (sensor.IsFifoOverrun())
cout << "FIFO is overrun" << endl;
if (sensor.Stop())
{
cout << "Device is probably not running now" << endl;
if (!sensor.IsRunning())
{
cout << "Device is not running" << endl;
}
}
vTaskDelete(NULL);
}
void calibrateSensor(ADXL355 &sensor, int fifoReadCount)
{
long fifoOut[32][3];
int result;
int readings = 0;
long totalx = 0;
long totaly = 0;
long totalz = 0;
memset(fifoOut, 0, sizeof(fifoOut));
cout << endl << "Calibrating device with " << fifoReadCount << " fifo reads" << endl << endl;
sensor.Stop();
sensor.SetTrim(0, 0, 0);
sensor.Start();
this_thread::sleep_for(chrono::milliseconds(2000));
for (int j = 0; j < fifoReadCount; j++)
{
cout << "Fifo read number " << j + 1 << endl;
while (!sensor.IsFifoFull())
{
this_thread::sleep_for(chrono::milliseconds(10));
}
if (-1 != (result = sensor.ReadFifoEntries((long *)fifoOut)))
{
cout << "Retrieved " << result << " entries" << endl;
readings += result;
for (int i = 0; i < result; i++)
{
totalx += fifoOut[i][0];
totaly += fifoOut[i][1];
totalz += fifoOut[i][2];
}
}
else
{
cerr << "Fifo read failed" << endl;
}
}
long avgx = totalx / readings;
long avgy = totaly / readings;
long avgz = totalz / readings;
cout
<< endl
<< "Total/Average X=" << totalx << "/" << avgx
<< "; Y=" << totaly << "/" << avgy
<< "; Z=" << totalz << "/" << avgz
<< endl << endl;
sensor.Stop();
sensor.SetTrim(avgx, avgy, avgz);
int32_t xTrim;
int32_t yTrim;
int32_t zTrim;
result = sensor.GetTrim(&xTrim, &yTrim, &zTrim);
if (result == 0)
{
cout << "xTrim=" << xTrim << ";yTrim=" << yTrim << ";zTrim=" << zTrim << endl;
}
sensor.Start();
this_thread::sleep_for(chrono::milliseconds(2000));
}
extern "C" void app_main()
{
nvs_flash_init();
//initialise_wifi();
if ( xTaskCreate(&task_i2cscanner, "i2cscanner_task", 1024 * 10, NULL, 5, NULL) != pdPASS ) {
printf("Creation of i2c scanner task failed\r\n");
}
}
I changed the pin for SDA to 42 from 23 in the code since i am using ESP32 Wroom module
from esp32-adxl355.
I am getting following error
In file included from /Users/ankitbhardwaj/Documents/Arduino/hardware/espressif/esp32/cores/esp32/esp32-hal.h:53:0,
from /Users/ankitbhardwaj/Documents/Arduino/hardware/espressif/esp32/cores/esp32/Arduino.h:35,
from sketch/adxl355-esp32.ino.cpp:1:
/Users/ankitbhardwaj/Documents/Arduino/hardware/espressif/esp32/cores/esp32/esp32-hal-gpio.h:51:19: error: expected identifier before numeric constant
#define DISABLED 0x00
^
sketch/ADXL355.h:109:9: note: in expansion of macro 'DISABLED'
DISABLED = 0b000,
^
/Users/ankitbhardwaj/Documents/Arduino/hardware/espressif/esp32/cores/esp32/esp32-hal-gpio.h:51:19: error: expected '}' before numeric constant
#define DISABLED 0x00
^
sketch/ADXL355.h:109:9: note: in expansion of macro 'DISABLED'
DISABLED = 0b000,
^
/Users/ankitbhardwaj/Documents/Arduino/hardware/espressif/esp32/cores/esp32/esp32-hal-gpio.h:51:19: error: expected unqualified-id before numeric constant
#define DISABLED 0x00
^
sketch/ADXL355.h:109:9: note: in expansion of macro 'DISABLED'
DISABLED = 0b000,
^
In file included from /Users/ankitbhardwaj/Documents/Arduino/adxl355-esp32/adxl355-esp32.ino:11:0:
sketch/ADXL355.h:135:18: error: expected ')' before 'deviceAddress'
ADXL355(uint8_t deviceAddress, gpio_num_t sdaPin, gpio_num_t sclPin);
^
sketch/ADXL355.h:140:5: error: 'STATUS_VALUES' does not name a type
STATUS_VALUES GetStatus();
^
sketch/ADXL355.h:144:5: error: 'RANGE_VALUES' does not name a type
RANGE_VALUES GetRange();
^
sketch/ADXL355.h:145:18: error: 'RANGE_VALUES' was not declared in this scope
int SetRange(RANGE_VALUES value);
^
sketch/ADXL355.h:146:5: error: 'HPF_CORNER' does not name a type
HPF_CORNER GetHpfCorner();
^
sketch/ADXL355.h:147:22: error: 'HPF_CORNER' was not declared in this scope
int SetHpfCorner(HPF_CORNER value);
^
sketch/ADXL355.h:167:1: error: expected unqualified-id before 'private'
private:
^
sketch/ADXL355.h:174:1: error: expected declaration before '}' token
};
^
exit status 1
Error compiling for board ESP32 Dev Module.
from esp32-adxl355.
Please help in this issue
from esp32-adxl355.
Sorry didn't even see this. I must have missed the notification. I haven't visited this code for quite some time. What environment are you using? This code was built for the ESP-IDF. It might be that they have modified some of their headers to cause this issue. I suggest you fork my code and try renaming the clashes. I don't have the time to look at this right now.
from esp32-adxl355.
Closed due to lack of response
from esp32-adxl355.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32-adxl355.