Closed scientistnobee closed 4 years ago
Heya, can you please provide me with more info so that i can replicate it :
Dear Micooke,
My Arduino version is 1.6.9. Yes, I installed Sandeep's repo. I am able to upload a simple blick sketch without a problem. However, for this to happen, I need to choose "none" option for softdevice. If not Arduino is hanging saying "Uploading", but never going to say "uploaded". If I choose softdevice "none", I am able to upload the sketch. If I am trying to upload any of your examples, they are not getting compiled, even though I have the correct libraries installed. For example, when I tried to compile the following example from your files https://github.com/micooke/Kx022-1020/blob/1083297cac12a4750ab15018c95c06e5300b62f9/examples/KX022_getAcc/KX022_getAcc.ino
the error was about SSD1306Spi.h. If I install that library it is saying some other file is missing. It's kind of loop. These files are compiling without a problem if I use rogerclark's repo. But I couldn't upload them as my Arduino/BMP is hanging at the uploading process. In the following, I am posting the output from Arduino's output for a successful flash (simple blink) using Sandeep's repo.
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/nobee/appdata/local/arduino15/packages/sandeepmistry/tools/gcc-arm-none-eabi/5_2-2015q4/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
Sketch uses 1,580 bytes (0%) of program storage space. Maximum is 262,144 bytes. C:\Users\nobee\AppData\Local\Arduino15\packages\sandeepmistry\tools\gcc-arm-none-eabi\5_2-2015q4/bin/arm-none-eabi-gdb -quiet -cd C:\Users\nobee\AppData\Local\Temp\buildd0753066408258c07747789135b326db.tmp -b 230400 -l 10 -ex set debug remote 0 -ex set target-async off -ex set remotetimeout 10 -ex set mem inaccessible-by-default off -ex set confirm off -ex set height 0 -ex target extended-remote .\COM15 -ex monitor swdp_scan -ex attach 1 -ex file Blink2.ino.elf -ex load -ex tbreak main -ex run -ex echo \nProgram complete!\n -ex quit Remote debugging using .\COM15 Target voltage: 3.3V Available Targets: No. Att Driver 1 Nordic nRF51 Attaching to Remote target 0x000004c2 in ?? () Reading symbols from Blink2.ino.elf...done. Loading section .text, size 0x62c lma 0x0 Loading section .ARM.exidx, size 0x8 lma 0x62c Loading section .data, size 0x6c lma 0x634 Start address 0x210, load size 1696 Transfer rate: 12 KB/sec, 424 bytes/write. Temporary breakpoint 1 at 0x416: file C:\Users\nobee\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.5.1\cores\nRF5\main.cpp, line 29. Starting program: C:\Users\nobee\AppData\Local\Temp\buildd0753066408258c07747789135b326db.tmp\Blink2.ino.elf Note: automatically using hardware breakpoints for read-only addresses.
Temporary breakpoint 1, main () at C:\Users\nobee\AppData\Local\Arduino15\packages\sandeepmistry\hardware\nRF5\0.5.1\cores\nRF5\main.cpp:29 29 init();
Program complete!
Ah, theres a few issues here. Have you uploaded the softdevice to your hardware? This needs to be done using a board from sandeeps repo at the moment (any board with the right chipset). The accelerometer example uses my squix78_OLED repo - which is currently broken. Ill redo the example to use u8g2 or my sparkfun_OLED. Ill also create a travis CI build file for this so i can very every push works. Long story short, ill look in to it and get back to you.
Thank you very much micooke. Yes, I have flashed the softdevice. I was so desperately trying to reach anyone who can help me with this. Hope I can work with this fitness tracker. So far it was difficult.
One thing i noted - sandeep's repo lists that Arduino 1.6.12 is the minimum that is supported (I use 1.8.4 - no issues). Ill look in to it a bit more, but the putc error sounds like it cant find the arm headers which are installed by using the board manager with sandeeps repo.
Yes, in fact I am also using 1.8.5 version. May be a stupid question, but I think I misunderstood your instructions from your github:
4.3 Install arduino-nRF5-smartwatches : Do you mean that I need to keep this folder inside the hardware folder in Documents/Arduino/hardware/arduino-nRF5-smartwatches or do I need to keep it in Documents/Arduino/hardware/arduino-nRF5, which is sandeep's repo.
I am asking this because I am getting the following error:
No valid hardware definitions found in folder arduino-nRF5-smartwatches.
Could not find boards.txt in C:\Users\nobee\Documents\Arduino\hardware\arduino-nRF5-smartwatches\variants. Is it pre-1.5?
The folder structure for hardware has changed, so the easiest way is to install it through the board manager then copy over the latest version from github into its installed directory.
Otherwise from memory the folder in documents/hardware
needs another layer to say what architecture it is. I.e. Boards.txt would be located in Hardware/arduino-nRF5-smartwatches/nRF5/boards.txt
instead of Hardware/arduino-nRF5-smartwatches/boards.txt
Im sorry, i dont have a pc with me to check. If that doesn't work then the easiest way is to install the old release then copy over the libraries you want to the libraries folder until i create a nee release.
Success. Thanks for the tip. I uninstalled Arduino and installed everything again in order as you explained above. Now the MicroOLED_64X32 is compiled. Although, I don't see anything on the screen yet, but compiling the code itself seems a big success for the time being. I think, my definition of pins might be wrong. Could you please if the below definitions are correct for ID107HR:
MicroOLED oled(7,8);
Do I need to change anything?
Thank you so much for your help so far.
Its an SPI oled, so you need to use the spi initialisation and comment out/delete the i2c stuff. I.e.
MicroOLED oled(PIN_RESET, PIN_DC, PIN_CS); // SPI Example
//MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example
//#ifdef SFE_MicroOLED_SoftwareI2C
//MicroOLED oled(7,8); // SoftwareI2C Example - sda,scl = 7,8
//#else
//MicroOLED oled; // I2C Example (No RST pin, i2c address = 0x3C)
//#endif
Note that for the smartwatch variants ive also added #defines for a lot/all of the pin mapping (look at the relevant variant.h file). So for example you could instead ignore the PIN_* defines and use MicroOLED oled(OLED_RST, OLED_DC, OLED_CS);
to instantiate the screen.
Ive tested my libraries against i2c, SoftwareI2C and SPI for the 64x32 and 64x128 oled screens. Hence my examples are in a bit of flux. When i get time ill tidy them up so that it instantiates using the correct pin mapping and peripheral type, based off whether e.g. _VARIANT_ID107HR_
is defined
Thanks for the help. I got the screen working now. I am able to display the acceleratorometer data on screen. I didn't use: MicroOLED oled(OLED_RST, OLED_DC, OLED_CS)
as it was giving me an error. My code is as following:
#include <Wire.h>
#include <SPI.h>
#include <KX022.h>
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library
#define PIN_RESET 30 // Connect RST to pin 30 (SPI & I2C)
#define PIN_DC 0 // Connect DC to pin 0 (SPI only)
#define PIN_CS 29 // Connect CS to pin 29 (SPI only)
#define DC_JUMPER 0 // DC jumper setting(I2C only)
//#define USE_SOFTWAREI2C
#ifdef USE_SOFTWAREI2C
#include <SoftwareI2C.h>
SoftwareI2C sWire(14, 16);
KX022<SoftwareI2C> acc(sWire);
#else
KX022<> acc(Wire);
//KX022<TwoWire> acc(Wire); // TwoWire is the default class, so this is the same as above
#endif
#define OLED_WIDTH 64
#define OLED_HEIGHT 32
MicroOLED oled(OLED_RST, OLED_DC, OLED_CS); // (pin_rst, pin_dc, pin_cs)
float xyz[3];
uint32_t tPage;
bool B1_isPressed = false;
uint8_t page_num = 0;
const uint8_t page_count = 2;
void draw_page(uint8_t idx = 0);
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println(__FILE__);
pinMode(PIN_BUTTON1, INPUT_PULLUP);
acc.init();
oled.setScreenSize(OLED_WIDTH, OLED_HEIGHT);
oled.begin();
//oled.flipScreenVertically();
// oled.setTextAlignment(TEXT_ALIGN_LEFT);
// oled.setFont(ArialMT_Plain_10);
draw_page(page_num++);
delay(3000); // show splash for 3s
tPage = millis();
}
void loop()
{
if (!B1_isPressed & !digitalRead(PIN_BUTTON1)) // timer used for button debounce
{
page_num = (page_num + 1 < page_count)?page_num+1:0;
}
B1_isPressed = !digitalRead(PIN_BUTTON1);
if (millis() - tPage > 20) // 20ms = 50Hz
{
tPage = millis();
draw_page(page_num);
}
yield();
delay(500);
oled.clear(PAGE); // Clear the display's internal memory
oled.clear(ALL); // Clear the library's display buffer
}
void float2chars(float &in, char (&out)[5])
{
bool sign_bit = (in < 0);
uint16_t tmp = sign_bit?(-in * 10):(in * 10);
out[0] = (sign_bit)?'-':' ';
out[1] = char('0' + (tmp / 10));
out[2] = '.';
out[3] = char('0' + (tmp % 10));
out[4] = '\0';
}
void draw_page(uint8_t idx)
{
switch(idx)
{
case 1:
page_accelerometer(); break;
default:
page_startup();
break;
}
}
void page_startup()
{
oled.clear();
//oled.drawString(0,0,"github.com/");
//oled.drawString(0,10,"micooke");
// oled.drawString(0,20,__TIME__);
oled.display();
}
void page_accelerometer()
{
char fltBuf[5];
acc.getAccelXYZ(xyz);
oled.clear();
oled.setCursor(5, 4); // points cursor to x=27 y=0
oled.print("X");
oled.setCursor(25, 4); // points cursor to x=27 y=0
float2chars(xyz[0],fltBuf);
oled.print(fltBuf);
oled.setCursor(5, 14); // points cursor to x=27 y=0
oled.print("Y");
oled.setCursor(25, 14); // points cursor to x=27 y=0
float2chars(xyz[1],fltBuf);
oled.print(fltBuf);
oled.setCursor(5, 24); // points cursor to x=27 y=0
oled.print("Z");
oled.setCursor(25, 24); // points cursor to x=27 y=0
float2chars(xyz[2],fltBuf);
oled.print(fltBuf);
oled.display();
}
Now, I would like to work with the HR sensor. If you don't mind could you please point me towards a right direction. Thanks a lot for your help so far.
I haven't got that working properly. I need to upload my update, but not getting any usefull data from the sensor. It is a Si1143, ive pulled another repo into mine but haven't done anything with it. It didn't work for me in its default state. Pinout is in readme.md
Okay, Thanks for letting me know. I am looking at the following libraries:
https://github.com/Cornell-Engineering-World-Health/Si1143-Pulse-Oximetry/blob/master/IRE.ino https://github.com/openenergymonitor/RFu_jeelib/blob/master/examples/Ports/lux_demo/lux_demo.ino
Let me know if you get something working and ill write/adapt a library using it
This is the one i was working on https://github.com/micooke/SI1143_Pulse_Prox_Sensors
If you find an algorithm to decouple the motion induced noise using the accelerometer - definitely let me know 😊
I too looked at that library, but it is written with ports for providing the I2C address. Are you sure that I2C address for HR sensor is 0x5A ??
To be frank, I am really not good with coding. I am trying my best to hack this fitness tracker to use it for light measuring device. If I get it working I will let you know.
Hi, I have Si1143 file compiled. But unfortunately, I was not able to see the output on the serial port as I don't know how to use the serial port with black magic probe. So, I am now trying to see the bmp values on OLED screen which might take some time. Please see the file below, which would work with serial port. Let me know, if it works with your fitness tracker.
Yes, its 0x5A. SPI and I2C interrupts are shared on the nRF51, by default it is set to use 1xSPI, 1xI2C - so you need to use a SoftwareI2C library (luckily i wrote one) and modify your code to work with SoftwareI2C
Okay. But I feel I didn't progress much today, although I spent my whole day on it. Just to clarify, I want to detect the light values using this SI1143 sensor. I am not interested in BPM measurements. So, if you have any semi working code, could you please share. I had a look at your library in the following, but I couldn't able to compile it.
I got it the wrong way around, the Si1143 library (https://github.com/micooke/Si1143) is hardware I2C, use SoftwareI2C for the accelerometer.
See https://github.com/micooke/Si1143/blob/master/Examples/ReadSensors/ReadSensors.ino for an example on reading the sensors with and without (Ambiant) the LEDs on.
Thank you. I will check it now and let you know my progress.
No worries. Ill leave this issue open for the meantime. If i dont hear anything ill close it in a couple months
Hi Mark, I am able to communicate with Si114 using the code from @najnesnaj below link. I am updating here, so anyone following this thread might find this useful. Thanks for your help in troubleshooting the code.
@micooke concerning an algorithm for cleaning up the heart rate signal: I started digging around for scientific papers on that topic and there are quite a few. For a start you can simply type: "photoplethysmography accelerometer" into Google Scholar. I plan to try to implement such an algorithm at some point but getting DFU to work has a higher priority to me :)
Thanks Tim, ill look in to it 👍
Hi Mark,
What are the typical values of photodiodes (als_vis and als_ir) you get using your Si1143 codes. I am getting these values as below:
AMBIENT_VIS 4294910181 AMBIENT_IR 15859711 AMBIENT_VIS 21234092 AMBIENT_IR 16843020 AMBIENT_VIS 20906423 AMBIENT_IR 16449826 AMBIENT_VIS 20840893 AMBIENT_IR 16843038 AMBIENT_VIS 21496239 AMBIENT_IR 16580882 AMBIENT_VIS 21234088 AMBIENT_IR 16974110 AMBIENT_VIS 21430716 AMBIENT_IR 16974110 AMBIENT_VIS 21168546 AMBIENT_IR 16580890 AMBIENT_VIS 21758384 AMBIENT_IR 16843038 AMBIENT_VIS 21168569 AMBIENT_IR 16711968 AMBIENT_VIS 20709798 AMBIENT_IR 17039635 AMBIENT_VIS 20644250 AMBIENT_IR 16777498 AMBIENT_VIS 21234097 AMBIENT_IR 16908574 AMBIENT_VIS 21168543 AMBIENT_IR 16580891 AMBIENT_VIS 21168564 AMBIENT_IR 16908577 AMBIENT_VIS 21365150 AMBIENT_IR 16515358 AMBIENT_VIS 20840879 AMBIENT_IR 16711960 AMBIENT_VIS 21561779 AMBIENT_IR 16580897 AMBIENT_VIS 20709793 AMBIENT_IR 16777501 AMBIENT_VIS 21168539
Do you think these values are realistic and do they make sense? I don't know what these numbers corresponds to. Please let me know, if you have any idea. Thank you.
Heya, i haven't looked at this in a while.. I'm away from my test setup at the moment, so I'll try and reply next week. From memory they both should be measuring distance, so try placing a solid object different distances away and observing the measurements. Ambiant is without the leds on. Should be useful for detecting on /off wrist to turn on /off the leds for hr measurement
Oh, and it's short range. 8cm as the max distance comes to mind.. Dunno, i would have to check the datasheet
I think als_vis and als_ir are the only photodode measurements while ps_data measuring the distance.
I thought als_vis is given by ALS_VIS_DATA=256*ALS_VIS_DATA1+ALS_VIS_DATA0 as shown in page 36 of the following pdf. https://www.silabs.com/documents/public/application-notes/AN498.pdf
But these values (als_vis and ALS_VIS_DATA) are not the same when I read from the sensor. So I don't know what pulse.als_vis is measuring.
Mark any update on these pulse.als_vis values?
No worries. All the best with your work. By the way, did you ever encountered the following problem, while working with ID107HR.
I was able to upload the code, If I chose softdevice as "none" in the "tools" "softdevice" options of Arduino IDE. However, if I chose "s130", Arduino IDE is struck while uploading the code to ID107HR.
If you are busy please ignore this.
Yeah sometimes my programmer gets itself into a state. I normally have to remove it and restart Arduino. Normally with a blackmagic probe.
Hi Mark,
I resolved the above soft device inclusion problem. I downloaded the softdevice file from Nordioc and kept in the softdevice folder of Sandeep's core.
I actually had the same issue when running this on Linux so i wrote this (only valid for the current revision of sandeeps repo) : https://github.com/micooke/micooke.github.io/blob/master/canihaz_softdevices.sh
@scientistnobee - regarding the sensor value : ALS_VIS_DATA=256*ALS_VIS_DATA1+ALS_VIS_DATA0
is the same as ALS_VIS_DATA=(ALS_VIS_DATA1 << 8) +ALS_VIS_DATA0
<<
is a bit shift operator in c. So im bit shifting left by 8, which is multiplying by 2^8 (bit shifting to the right >>
is dividing)
The max 16b value is 2^16 - 1 = 65535 so something else is happening. I'm averaging (line 402 - 413) and i suspect the issue is there. I'll have a look in the next week, sorry been busy with the release :)
Cheers
Thanks for your working on this problem. I am still struggling with this. Hope we can resolve this soon.
Just a note, using the board manager - try installing 0.2.0 to get the latest of everything... excluding the file i just updated :) https://github.com/micooke/Si1143/blob/master/Examples/ReadSensors/ReadSensors.ino
Using ReadSensors.ino, Im getting the following :
Note, by default 5 samples are averaged together (see samples_to_average
):
https://github.com/micooke/Si1143/blob/da51cfe2a745b1db8d0f387e96afe5eb6a8f245c/Si114.h#L104
I just commited this. The diff may make the measurements a bit easier to understand: https://github.com/micooke/Si1143/commit/da51cfe2a745b1db8d0f387e96afe5eb6a8f245c
I never be able to get connected to Si114x with your library. I don't know what the problem is. I get only the following result
No SI114x found
I use the si114x files I uploaded in the following folder and they work at least for finding the si114
What board settings are you using? The example i pointed to assumes you have the hr sensor attached to hardware i2c, which is not the default configuration for my id107hr variant
I used the generic nrf51 variant with your files of variant.h in it.
How can I attach the HR sensor to the hardware i2c? Could you please tell me your configuration?
What is the physical device? I'm using the id107hr variant - it's a nrf51. Do you have the latest si1143 library? As i said I updated it. If your library is templated, then it is the latest. One thing, i released the wrong commit by accident - software i2c doesn't work (no error produced), but the standard wire library does (this is the default example)
I have only 107HR device. yes, I do download your latest version of the library. I updated your variants as well to version 0.2.0. I am not changing anything in your ReadSensors.ino, so I am sure I am not using software I2C. Please let me know, if I have to change any lines in the files of Si1143 library.
Are you selecting ID107HR
for the board and I2C:Accel=SW, HeartRate=HW
for the Board Variant
?
Thanks for the tip. Now I understood, what you have been saying all these days. I didn't see the Board variant before. I am extremely sorry for that. Now I am getting sensible values.
Now coming to the values, if I keep my smart phone flash light shining on to the sensor, I can see the Ambient Visible and IR photo diode values changing as expected. However, there is no significant change in the Active LEDS values. So Active LEDS are only measuring the reflectance values i.e distance wrt to the sensor rather than light coming on the sensor. If that is the case, how these LEDS are used to measure the heartbeat rate?
Not a problem, it's easy enough to miss. With PPG you measure the variance in reflected signal, which should peak and trough in time with your blood flow - ie your heartrate. As i said, I haven't got this part working
Thanks for understanding. I am looking forward to PPG measurements.
Hi Mark, I again hit the softdevice problem. If I select softdevice as "none" I am able to upload the code, but if I chose s130, I could not. This time, I copied the softdevice into the softdevice folder in your core, just like I did before for sandeep's code. But it is still not working. Please let me know, if there are any tricks to get it worked this time.
Dear Micooke,
When I used your OLED smarty example, I am getting the following error. Could you please let me know, how to troubleshoot it.
C:\Users\nobee\Documents\Arduino\libraries\SFE_MicroOLED/SFE_MicroOLED.h:118:18: error: macro "putc" requires 2 arguments, but only 1 given