Help with pins, memory and sensors

Hello,

I have a Flora controller. Currently, I have the following ports in use:

  • GND, SCL, SDA, 3.3V: BME280 sensor, in I2C mode
  • GND, RX, TX, 3.3V: Bluefruit (Bluetooth LE module)
  • GND,VBATT, D6: Neopixel (LEDs)

Free ports:

  • D9, D10, D12

What I want to do next:

  • I want to add 2 buttons: one to turn the controller on/off. The second button to trigger an event when is pushed.
  • I need to add an EDA (also known as GSR) sensor.
  • I need to add more code in a limited memory.
  • I want to charge this device with the battery of an old Samsung phone.

Problems:

  • do I have enough pins to attach the 2 buttons and an additional EDA sensor? If not, what I should do (I heard about port extension, but I don't know much about it).
  • I don't know what buttons to buy and where/how to wire them. Some code will also be useful.
  • right now I'm using 22kb of 28kb available on Flora. I'm quite sure that I'll run out of memory soon. Is there a way to expand this memory, or I should focus on optimizing the code?
  • the Samsung battery has 4 pins, two of them marked with minus and plus signs. To which of them should I connect the device in order to power it?

Thanks in advance!

george_i:

  • do I have enough pins to attach the 2 buttons and an additional EDA sensor? If not, what I should do (I heard about port extension, but I don't know much about it).

I have no idea what a EDA sensor is. Please provide us with a datasheet.

But you say you want to add a button for on/off. Why not simply use a switch between the device and the battery? With 1 port for the button you still have two for the EDA whatever it is...

george_i:

  • I don't know what buttons to buy and where/how to wire them. Some code will also be useful.

Simple push button should do. For how to wire it you can use Google :wink: It's to damn basic.

george_i:

  • right now I'm using 22kb of 28kb available on Flora. I'm quite sure that I'll run out of memory soon. Is there a way to expand this memory, or I should focus on optimizing the code?

You can't expand it. I think you can optimize but you did not post the code. Do you use a lot of strings to send? Or even the String class?

george_i:

  • the Samsung battery has 4 pins, two of them marked with minus and plus signs. To which of them should I connect the device in order to power it?

The Arduino isn't a battery so you don't charge it, you power it. The + and - pins of the battery are probably the battery terminals. The two pins left are probably for the temperature sensor in the battery.

Thanks in advance!
[/quote]

EDA stands for electrodermal activity, also known as GSR (galvanic skin response).
This is a sensor I found: http://www.seeedstudio.com/depot/Grove-GSR-p-1614.html
I'm not sure about it, so I want a second opinion.

The Samsung battery has those 4 sort of pins. I have the feeling that one is for charging port and one to power the device. I just don't know for sure how it is.

The code I have right now is just the setup basically.
I will need to define around 20 colors and do some if/else based on the 4 sensor values.
Probably I'll come later with the sketch here after it becomes more stable and I run out.

The EDA is going to be a problem. Not because you don't have pins available, but because the output of the EDA is an analog voltage and the Flora has no ADC pins. The uC (ATmega32) itself has but they are not onto pads...

I don't think the battery is wired that way (but you're never sure). In most mobiles the charger circuit is just inside the phone. The protection circuit is in the battery. Measure the resistance between the 2 unlabeled pads. Probably around 100ohm or 1k. And do it again after keeping the battery in you pocket for 10 minutes to warm it up. Probably the resistance changed. But yeay, every battery can be different and without data(sheet) you're never sure.

And why not post the code now? Looks like an awful lot for just setup! For us it's easier to give you tips now the code is just basic then it is when it's 20 pages long...

What about a heart rate monitor sensors instead of EDA sensor?
Can you recommend such sensor?

PS: I'll follow up soon with the code.

The GSR sensor need a analog input pin.

const int BUZZER=3;
const int GSR=A2;
int threshold=0;
int sensorValue;

void setup(){
  long sum=0;
  Serial.begin(9600);
  pinMode(BUZZER,OUTPUT);
  digitalWrite(BUZZER,LOW);
  delay(1000);
  
  for(int i=0;i<500;i++)
  {
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold =");
   Serial.println(threshold);
}

void loop(){
  int temp;
  sensorValue=analogRead(GSR);
  Serial.print("sensorValue=");
  Serial.println(sensorValue);
  temp = threshold - sensorValue;
  if(abs(temp)>50)
  {
    sensorValue=analogRead(GSR);
    temp = threshold - sensorValue;
    if(abs(temp)>50){
    digitalWrite(BUZZER,HIGH);
    Serial.println("YES!");
    delay(3000);
    digitalWrite(BUZZER,LOW);
    delay(1000);}
  }
}

If you need more pins and memory space why not change to Atmega1284

ATMega1284P-AU with 32 IO, Dual Hardware UART, 128K FLASH, 16K SRAM.

http://www.crossroadsfencing.com/BobuinoRev17/

BillHo:
If you need more pins and memory space why not change to Atmega1284

I would say because that's a HUGE board compared to the flora... A Arduino Pro Mini is more size compatible...

And I don't know heart rate sensors that don't use a analog input. You can make one but I don't know modules that do. Maybe others can help.

It you want small, this

I can't switch from Flora anymore.

Anyway, I found a last very convenient alternative for EDA and HRM: a SPO2 sensor.

Now I want a SPO2 sensor very bad!
Any suggestions?
It seems simple, but I don't know anything about it.

Just for the record: Flora has analog ports (I forgot which Dx ones), someone from Adafruit confirmed.