Closed scientistnobee closed 4 years ago
Solved the above problem. After copying the softdevice file in to the softdevice folder, I had to restart the Arduino. Now it's working.
By the way, I developed a simple UART communication app using MIT app inventor platform. One can modify it for any other purpose.
Thanks for that, I'll have to try it out! I just use the serial connection with the blackmagic probe, but at some stage ill look in to upload over bt and this will be very handy
Hi, I encounter a strange problem. My code on the ID107HR is running for a while (15 minutes) then it stops working. What I mean is that it stops communicating on serial port and stops displaying values on the OLED screen. But still the LEDs of HR sensor are switched on for at least 2-3 hours until the battery is completely discharged. Then if I charge the device again, it works for a while and again same problem repeats. Do you know what's going on?
Heya, Ive never had this issue, and its kind of hard for me to say without looking at the code. The first thing i would look at is memory - are you using up all your memory, are you going out of bounds of an array, are you forgetting to deallocate memory, etc. The second thing i would look at is commenting out the serial stuff, and commenting out the oled stuff (one at a time) and seeing if the error still occurs.
Hi Mark,
Thanks for the suggestions. I will try as you suggested. In between, I am posting my code here. Please have a look and let me know, if you see any obvious problems.
#include <Wire.h>
#include <SPI.h>
//#include <KX022.h>
#include <SFE_MicroOLED.h> // Include the SFE_MicroOLED library
#include <avr/dtostrf.h>
#include <Si114.h>
PulsePlug<> pulse(Wire);
#include <BLEPeripheral.h>
#include "BLESerial.h"
BLESerial bleSerial(10, 2, 9);
unsigned long long lastSent = 0;
#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();
bleSerial.setLocalName("UART");
bleSerial.begin();
Serial.begin(9600);
Serial.println(__FILE__);
pinMode(PIN_BUTTON1, INPUT_PULLUP);
oled.setScreenSize(OLED_WIDTH, OLED_HEIGHT);
oled.begin();
draw_page(page_num++);
delay(1000); // show splash for 1s
tPage = millis();
while (pulse.isPresent() == false)
{
Serial.println(F("No SI114x foundxxx"));
delay(1000);
}
Serial.println(F("SI114x Pulse Sensor found"));
pulse.init();
}
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(1000); // show splash for 3s
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()
{
pulse.readSensor(3);
Serial.print(F("Active LEDs [red, ir1, ir2] = ["));
Serial.print(pulse.led_red);
Serial.print(F(", "));
Serial.print(pulse.led_ir1);
Serial.print(F(", "));
Serial.print(pulse.led_ir2);
Serial.println(F("]"));
Serial.print(F("Ambiant LEDs [visible, ir] = ["));
Serial.print(pulse.als_vis);
Serial.print(F(", "));
Serial.print(pulse.als_ir);
Serial.println(F("]"));
float total=pulse.led_red+pulse.led_ir1+pulse.led_ir2;
char fltBuf[5];
char charVal[10];
oled.clear();
oled.setCursor(5, 4); // points cursor to x=27 y=0
oled.print("Vis");
oled.setCursor(25, 4); // points cursor to x=27 y=0
dtostrf(pulse.als_vis,5,0,charVal);
oled.print(charVal);
oled.setCursor(5, 20); // points cursor to x=27 y=0
oled.print("IR");
oled.setCursor(25, 20); // points cursor to x=27 y=0
// float2chars(pulse.als_ir,fltBuf);
dtostrf(pulse.als_ir,5,0,charVal);
oled.print(charVal);
oled.display();
bleSerial.print("V");
bleSerial.print(pulse.led_red);
bleSerial.print(",");
bleSerial.print("I");
bleSerial.print(pulse.led_ir1);
}
Hi Mark, I have an update. As you predicted, bleSerial is causing the problem. If I remove the lines related to bleSerial, the device works continuously without stopping. Do you have any idea how to make the device keep working with bleSerial ? I need this bleSerial as I want to monitor remotely.
I'm not sure exactly. One thing I would try is replacing all delay()
calls with a millis()
based delay i.e.
yield();
delay(1000); // show splash for 3s
becomes
uint32_t t = millis();
while (millis() - t < 1000)
{
yield();
}
The reason being that a lot of wireless comms require background processes to maintain a connection, and also considering it is uart it will have an interrupt service routine for receiving Bluetooth data. Passing control to yield()
frees up the processor for these processes.
The other thing it could be is an error in the btSerial library.
Yet another thing, you could remove Serial
comms and replace them with bleSerial
.
I doubt that they conflict, but it's another thing to tick off. Particularly if you aren't using hardware serial
Hi Mark,
Thanks, I did replace the Serial comms with bleSerial and it is working as I updated above. I have made the changes to delays as you suggested. I am waiting to see when it will stop working.
Hi Mark, replacing the delays with millis(), didn't help the BLE stopping problem. I raised issue at Sandeepmistry's repo https://github.com/micooke/arduino-nRF5-smartwatches/issues/2
Hope someone helps.
Hi Mark,
I am having this Bluetooth problem only if I use your new version of the 0.2.0 version and new Si1143 library. If I fall back to the old Si1143 library and using generic nRF51, I don't have any problem. I am reporting here, just to let you know.
Oh damn, thanks for finding that out! Most likely candidate is the library. Sorry for the delay, new phone and i wasnt getting notifications. Unfortunately it's bad timing, I'm offline for a bit. Rest assured that this will be my highest priority when i get back. Ta, Mark
Hi Mark,
Thanks for your reply. I am glad that you would look into this problem. I just came from holidays.
Hi @scientistnobee. I can't replicate your issue, but im using uncommitted versions of a few of those libraries so maybe i inadvertently fixed it? I'll try and update it this week
Thanks, Mark.
Give this a try: https://github.com/micooke/arduino-nRF5-smartwatches/tree/master/libraries/examples/Examples/ID107_u8g2_sensors_clock_bleUart
Use the default configuration for ID107 (HW Accelerometer, SW Heartrate), and it uses the u8g2 library (https://github.com/olikraus/u8g2)
Hi Mark,
I got the following error message.
C:\Users\nobee\Documents\Arduino\libraries\Timezone\src/Timezone.h:16:66: fatal error: TimeLib.h: No such file or directory
Where can I find that file? As you can see in the attached image, the Timezone library is flagged as in compatible.
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Virus-free. www.avg.com http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Thu, Jan 31, 2019 at 4:22 AM Mark Cooke notifications@github.com wrote:
Give this a try:
Use the default configuration for ID107 (HW Accelerometer, SW Heartrate), and it uses the u8g2 library (https://github.com/olikraus/u8g2)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micooke/arduino-nRF5-smartwatches/issues/5#issuecomment-459209869, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmv3nRSgKgJtzC1qB-WOELo9USK6sQDks5vIm-ggaJpZM4T5JPT .
Oops, like like a library interdependency! Line 16 of Timezone.h is
So you will need that. It's a very good library, I use it on other projects to e.g. sync the time to gps.
Dont worry about the complaints. The library says it's for avr, but there is no avr specific code in it.
Hi Mark,
I installed the timeLib, but I am getting the following error. 'PIN_WIRE1_SDA' was not declared in this scope It is pointing the error to ID107HR_sensor.h file. In particular to the following line SoftwareI2C sWire(PIN_WIRE1_SDA, PIN_WIRE1_SCL);
I tried with both Board variants (Accl:HW, Hr:SW and Accl:SW, Hr:HW)
On Thu, Feb 7, 2019 at 8:26 PM Mark Cooke notifications@github.com wrote:
Oops, like like a library interdependency! Line 16 of Timezone.h is
include
// https://github.com/PaulStoffregen/Time So you will be that. It's a very good library, I use it on other projects to e.g. sync the time to gps.
Dont worry about the complaints. The library says it's for avr, but there is no avr specific code in it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micooke/arduino-nRF5-smartwatches/issues/5#issuecomment-461583108, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmv3qNbsMtin7w_srlE2oOfS79mjqI4ks5vLIv3gaJpZM4T5JPT .
That's actually very strange because selecting those options is what changes the defines I'm referencing.
Try this : In the Arduino Ide, go to the board manager and update to the latest which is 0.2.1
Of it still doesn't work, try adding
#include <arduino.h>
to the top of ID107_sensors.h
. It may be that I'm working on a newer ide and the linker is better so it doesn't need the explicit include
Sorry about the run around, I'm trying to make it easy for people :disappointed:
Hi Mark,
After updating the board manager the code has compiled without any errors. Now, what I am supposed see. I can't see anything on the screen or on the serial output.
On Thu, Feb 21, 2019 at 10:16 AM Mark Cooke notifications@github.com wrote:
Sorry about the run around, I'm trying to make it easy for people 😞
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micooke/arduino-nRF5-smartwatches/issues/5#issuecomment-465942680, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmv3rs_rAn_cMxvjmFtKlaE_xjQPWAbks5vPnHegaJpZM4T5JPT .
You may need to reflash the bootloader and try uploading it again.
The ble example will just output the filename over serial at startup. However it will display the sensor information on the oled, which you can cycle through by clicking the side button. It will also push the vis and ir sensor readings over bluetooth, peripheral name UART
as per your example
Hi Mark, Thanks for your help while I was hacking the fitness sensor. Thanks to your help, we built a small biolab instrument with the fitness tracker and our results are published in the ACS journal (see the attached pdf and the link) I also cited your github page in the paper. Only because of you, I was able to get the Si114x sensor working. I hope to get it working with your updated library, which I yet to make it happen. I owe you a treat. Thanks, again. https://pubs.acs.org/doi/10.1021/acs.analchem.9b02628
On Fri, Mar 8, 2019 at 10:28 PM Mark Cooke notifications@github.com wrote:
You may need to reflash the bootloader and try uploading it again. The ble example will just output the filename over serial at startup. However it will display the sensor information on the oled, which you can cycle through by clicking the side button. It will also push the vis and ir sensor readings over bluetooth, peripheral name UART as per your example
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micooke/arduino-nRF5-smartwatches/issues/5#issuecomment-471098047, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmv3s1dH8AOveagcuf_oreyaRqQHI1Xks5vUuQKgaJpZM4T5JPT .
Great work! Thanks for the reference, and im glad you got something out of my work. Happy to help anytime in the future :)
Thank you so much for your kind help, Mark.
I will get back to you on your new Si114x library soon.
On Mon, 16 Sep 2019, 21:59 Mark Cooke, notifications@github.com wrote:
Great work! Thanks for the reference, and im glad you got something out of my work. Happy to help anytime in the future :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/micooke/arduino-nRF5-smartwatches/issues/5?email_source=notifications&email_token=AB427XW2HEWNZ6AABRNUBVLQJ7XUPA5CNFSM4E7ESPJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD62QCSQ#issuecomment-531956042, or mute the thread https://github.com/notifications/unsubscribe-auth/AB427XQXC2ZAPI2MQPQJUIDQJ7XUPANCNFSM4E7ESPJQ .
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