Help Needed On Creating an Spark App for Artificial Pancreas


#1

I developed a model of an artificial pancreas and would like to know how to see the pumping of insulin data, on a web and/or iOS application.
Here’s a link to the science fair pancreas model:

As you probably saw in the link, it is connected to a breadboard. I was thinking of connecting the Spark Core to the breadboard and would need help figuring out how to connect the Spark Core to the pH sensor. Also, what type of pH sensor should I get? I also wanted to ask if you know of a substitute for the pH sensor, somehow, as the cost a lot. Anyway, I would like the Spark Core to record data of the usage of the pump and the increase and decrease of the acidity levels.

Thanks!!


#2

Hopefully these tutorial helps:


#3

Combining the above, do you need someone to build it for you, or are you willing to do things yourself (with help when possible)?

That’s rather vague, care to elaborate? What kind of ‘app’ where you thinking about? Does it have to be a native app, and if so, what operation system? Could it also be a web app, and if so, what are the possibilities there (LAMP stack, node.js)? Does the data need to be stored somewhere, as to make a hystorical overview, or do you just want the current readings, starting from when you started the app.

Is this just a boolean ON/OFF state, or are you expecting something else? What are you planning on measuring with the Core?

There are also some very nice only services out there which you can use to store/visualize data. There’s a topic for using google here:


Ubidots is also said to be rather nice. Atomiot is created by one of the community members, and also includes data logging/visualisation.


#4

I am in 7th grade and do not know how to code, sorry. I would want to know how to do this. I would be willing to do things myself but it would be great if someone gave me an outline of the code . I am wanting a web app or a ios, node.js. I want the data to be stored on the app, a line graph that outline how the acid slowly neutralizes. For example, if I used Orange Juice, the Spark Core should record the time taken to neutralize and as the pump is pumping insulin( baking soda) into the orange juice, I would like to see the decrease in acidity levels. I have a conductivity sensor made of bare copper wire, this is in the acid, and the end of the copper wire is alligator test clip leads, which is ultimately connected to the breadboard. If I am correct boolean means true or false, so I am saying that this is not a boolean off and on state, rather this is measuring data, in line graph, of the decrease in acidity levels.

I was thinking of using a pH sensor but they are expensive. Do you have any ideas of how I can let the spark core know of the acidity.

I am also sorry if I am not elaborate enough, I do not know much about Spark Core, but I saw this and I thought I could incorporate this into my artificial pancreas model


#5

Since you got it working with Arduino, treat the Spark core like a normal arduino and make the setup work before we talk further :wink:


#6

Few things up front regarding the whole ‘app’ idea; Making an iOS app is no trivial task, moreover, it’ll cost you at least $99/year for a developers licence, not to mention the fact that you need an Apple computer for Xcode. And that doesn’t even include the fact that you need to know how to actually use said software, and the fact that you’ll have to learn how to program that in less than a week or so. You’ll also need some kind of server to log your data when you’re not using the app.
The webapp is less difficult in the way that it doesn’t have any software requirements or mandatory fees. It will also run on all platforms. The problem here however lies in the fact that you’ll need a place to host that page on, and some kind of server which continuously logs your data.
The server side could be done with node.js, but you’ll need a place to host that on as well. If you’ve got a raspberry pi, or some other device that’s permanently connected, you could use that, otherwise you’ll have to find an external host for that as well. Also, you’ll need to code the necessary node.js code (javascript, which could fortunately be the same as the webapp).

Considering all of the above, the time constraints, and your (lack of) programming skills, I would highly recommend checking out one of the online options I mentioned in my previous post. They are capable of running on all platforms (it’s webbased), they have datastorage included, they have hosting included, they have data visualisation included. That pretty much sums up all of your requirements. There’s some sort of proverb about wheels, and the fact that you may not want to reinvent them. I’ve got a hunch that might be applicable here ;).

The other concern is the available data. Unless you’re going to stick in a PH sensor, there’s hardly a way of telling the PH values at any given time. Seeing as PH sensors are rather expensive and cumbersome so set up, I think I may have an alternative. What if, instead if measuring the PH value, you measure the flow rate, and use that to calculate the PH values (approximately). It should be basic chemistry that when you mix X amount of Basic stuff with Y amount of acidic stuff, you get a PH of Z. If you know how much acid you’ve got, and you can measure the amount of basic stuff that’s being pumped into it, you not only have the total amount of combined liquid, but are also able to calculate the PH values. You can use one of these flow meters to measure the amount of liquid that’s being pumped. I can’t guarantee that’s it’s going to be incredibly accurate, but then again, a home-made copper conductivity sensor, orange juice, and baking soda probably isn’t going to be that accurate either :wink:

Maybe there are some alternative ways of measuring the output of your circuit (voltages, current, resistance of conductivity sensor), but I feel more comfortable asking @bko or perhaps @kennethlimcp for some ideas regarding that.


Unrelated side note: in the future, please don’t edit your posts so dramatically. It’s going to be confusing for other readers when the responses don’t match up with the post being responded to. Most of the question in my first post have now been erased from your original post, which is kind of messy. If you feel like adding additional information, just put it at the bottom of the post, preceded by “Edit:”. That’ll make it easier to understand. Thanks in advance!


@kennethlimcp, I’m not sure where you’ve seen that he’s using an Arduino, because it looked all analog to me(?)


#7

@Moors7, I believe the “pH” sensor in the article is actually a conductivity sensor. Generally, pH and conductivity are related under controlled conditions. For this project, that type of sensor vs an expensive pH level sensor is probably fine.

So, the conductivity sensor is used to trigger a MOSFET switch to turn on and off the pump. The same approach may be feasible with the Core but the “sensor” would need to be characterized. That is, what voltage/current range does it produce so it can be correctly read with the Core. This is great for pH thresholds but not for actual values which like I said before is probably fine for this project.

To read actual pH requires a specialized probe and amplifier which I believe may be beyond the range of @benclough’s budget. Instead of biting off more than he can chew, the project would be a great demonstrator if he got the sensor and the Core working together along with sending data to a Google spreadsheet for example or using IFTTT for triggering an alarm. Keep it simple and leverage existing tools so he can build it quickly and make it look great :smile:


#8

Thanks for your input and the advice :smile:


@peekay123, A pH sensor would not be a conductivity sensor. It would be something to measure the acidity of a substance. Sorry for any confusion caused,


But can I use the Spark Core? Sorry I am new to this kind of stuff…


Does flow rate mean the pumping activity over time? Also I am sorry, I can’t understand your alternative…:frowning:


@kennethlimcp

I don’t know what you mean by the use of Arduino… I haven’t used a Arduino yet…


@peekay123 I am confused how the Core and Google Spreadsheet work together.Also, what is IFTTT?

Thanks for your input :smile: :blush:

@peekay123 Unfortunately this is not the case for me. I am still confident that help with such a wonderful community is enough !!

@peekay123 Can you elaborate on each of these please? Mostly the first one


#14

@benclough, the article you pointed to refers to using a conductivity sensors to sense the level of pH in a solution. Conductivity and pH are related under controlled conditions. In the article, the conductivity sensor will trigger the pump when the solution’s conductivity/pH is high enough. For your project, this may be enough to demonstrate the idea. Instead of driving pump, the Core could read the voltage/current through the conductivity sensor (the wires around the blue tube) and act accordingly. For your project, the Spark Core could:

  1. Read the conductivity sensor’s “output” and log it (this may be very basic like high/low since it is not a real pH sensor)
  2. Control the pump based on the sensor’s value
  3. Send data to an internet service like Google Spreadsheet or IFTTT

One of the powerful aspects of the Spark Core is its ability to connect via WiFi and the internet. You can use that to send data to a Google Spreadsheet or use IFTTT (IF That Then This) which is like having a program make decisions on what to do based on defined conditions. The cool thing about IFTTT (which is a free web service), is that you can define “actions” like sending a tweet or a facebook post or send an email or many other things.

The Spark Core gives you a processor to read, calculate and react by using a C++ program AND provides a connection to the internet to enable you to take advantage of a huge number of “services” there. :smile:


#15

@benclough, if you have never programmed or used an Arduino before, using the Spark Core may present a steep learning curve. This community is extremely helpful but it would be best if you had someone with programming experience in Arduino to help you locally. Then we can guide the two of you. :smile:


#16

You most definitely can, you just need to differentiate between the sender and the receiver. The sender would in this case be the Spark Core, which can broadcast your data to the internet, whereas the receiving end would collect said data and possibly visualise it.

A flow meter measures the amount of liquid passing through it, allowing you to determine how much liquid is being mixed. Using basic-acid chemistry, you should be able to figure out the PH values depending on the amounts used.

Your Core would expose your measures values to the internet, and Google spreadsheet would pick these up. There’s also a built in functionality which you can use to make line graphs. If you check out the topic I linked to above, you can find some nice example where people used Google spreadsheets to store/visualise their data.


#17

Hey,
I was looking at the size of the Spark Core and I am anxious if the Spark Core is too big for my breadboard…

I have a 400 point solderless breadboard, and want to know if the Spark Core can fit on there?


#18

Don’t worry, it’ll fit :wink:


#19

Thanks!!

Also where should I start? I have got so much information, I don’t know where to start? What application will I be using and which coding language is it?

I have a few more questions in mind.
Does the Spark Core have to be connected to the Internet? I am going to present my science fair at a school, and we may not have Wi-Fi there.
Does the model always have to be in the baking soda and orange juice? As the school is far away from my home, I wanted to know if the how the flow meter works and if they always have to be connected to the baking soda. I will disconnect the pump on the car ride to the competition and will connect it together with the flow meter and baking soda at the competition. Is this okay?
Next, How does the flow meter work? Where should I connect this meter to?
Next, so as the judges come by, I will submerge the conductivity sensor into the acid( Orange Juice), and would like to know if as soon as I submerge, will the Spark Core begin sending data to the web application as the pump starts pumping baking soda into the orange juice?
Where do I plug the other end of the Spark Cable? Does the Spark Core need to be charged?


#20

If you’re sure you’re going to use the Spark Core, then get your hands on that as soon as possible. Even if you’re not going to use it for this project, it’s really awesome, and definitely worthwhile!

The application for coding the firmware for the Core will most likely be the online IDE. Like the main page says, It makes use of the Wiring language, which is the same as Arduino uses. This makes it easy to find examples. It can also work with C/C++ if I’m not mistaken.
The Google spreadsheets part will work with their software, which looks a lot like JavaScript (haven’t really looked into it yet). Depending on how difficult you want to make things on yourself, the examples provided in the topic I linked to, will suffice.

The Core itself will be able to work without an internet connection. You will however not be able to use its network functionalities. That means you won’t be able to send information to the internet, nor will you be able to control it over the web. If you can bring a wireless router, that might be best, since then you’ll be able to create your own network. Another possibility is to use a mobile hotspot. Most mobile phones nowadays are capable of sharing their internet connections by creating a hotspot. You can most likely use that to connect your Core to the internet.

I’m not sure what you mean by ‘model’, but the Core goes on the breadboard. Since it’ll get it’s measurements from there as well, it should work as long as the rest works.

Honestly, I would ditch the idea of the flow meter. It was just one of many possibilities, but @peekay123 's suggestion is much neater, and should be preferred.

That’s up to you to code. The Core is as brilliant as it is dumb. It can do a lot of things, but only the things you tell it to do. If you don’t tell it to measure things, it won’t measure things. If you don’t tell it to send data, it won’t. Turning on when you want it to definitely belongs to the possibilities.

The Core can be powered over micro USB using pretty much any USB adapter that provides 5V, 300+mA, preferably 500+mA. The Core itself can not be charged, since it’s doesn’t contain a battery. Although it’s possible to use an external battery pack (those cell phone back-up batteries), it might drain those rather fast, depending on the capacity. You can even make it run of normal batteries, but I’d suggest you stick with the USB powered micro USB cable.


@peekay123 mentioned this already, but I’ll repeat it just to be sure. Coding stuff, and making projects like this can be, and often is, a lot of fun. When you’ve never done so before, and you’re under time pressure it can become rather stressful. Is there anybody you could ask to help/assist you, preferably with some experience with things like these? If so, then please do ask for help, since it will save you a tremendous amount of problems.


#22

@benclough, I think you need to find someone who can help you locally and with Arduino experience. Otherwise, we will not be able to help you much more.


#28

@benclough, IF you are using a Spark Core to read the conductivity sensor and control your pump then you could measure:

  1. The conductivity of the solution (from the sensor) as it relates to pH
  2. The amount of time the pump is on or off - knowing what the flowrate of the pump is (milliliters per minute or hour), you could estimate total liquid volume pumped.

@benclough, a lot of your questions suggest that you are biting off much more than you can chew here. You really need a coach/mentor who has experience with micro-controllers before you can go any further. Without wanting to be rude, I cannot not help you any further until that happens. :smile:


#29

I have a group of people who can help me with building the Spark Core with group. What bothers me is the fact that they have the same question:

How does this work: Can you elaborate more?

It would be really helpful if you answer this final question. It would be considered with appreciation :smile:
@Moors7
Final question before I wrap up this forum, How could I connect this idea of @peekay123 with Google Spreadsheets?

Also can @Moors7 look into the Google Spreadsheets and explain the idea in simple terms? I saw the Google spreadsheets Idea and there is code, can I use the excat code?


#30

@benclough, if your support group is asking the same questions then they may not have the knowledge required to use the Core. Do they have Arduino experience?

As for logging to google spreadsheets:


#31

I don’t want to crush your dreams or anything, but I have to agree with @peekay123 on this one. If none of the people in your group can answer even these questions, then it’s highly unlikely that you’re going to get this working. You need someone with experience locally to help you. If that person can’t answer these questions, then they’re not the right person. If you don’t understand the Spark specific stuff, that’s understandable, but you’re asking for basic electronics, and basic programming. Those two things you should know before starting, or have someone there to help you, who does know.

Of course we can keep answering all your questions here, like we’ve been doing so far, but until you get someone with experience, that’s not going to help.

I could go though the Google Spreadsheet topic and tell you how it works. But I’m not going to do that for several reasons:

  • It isn’t my project. Although I’d gladly help you, I’m not going to make it for you, nor is it likely someone else will. This forum is for helping each other out, not for doing each others work. If you’ve got some specific questions like:“I don’t understand this particular piece of code, could you explain it?”, that might be okay. Now it’s more like:“tell me how to do everything”, which is, unfortunately, not okay.
  • The Spark Core is a ‘development kit’, something you use for developing things. It’s not a Lego building kit with a guide that tells you where to put what item. You’re going to have to figure stuff out on your own.
  • I personally feel like you aren’t putting in as much effort as you’re expecting us to put in for you. The Google topic, for example, has been referred to countless times, yet you’re still asking for information that’s given in that topic. That makes me feel like you don’t care enough to even read it. Following that, if you don’t care, then why should I?
  • Most of your questions come down to:“tell me how to build my project”. In your original post you asked for step by step instructions. Again, we’re glad to help, but we’re no building manual. We can give you general pointers on where to look, and provide you with useful informations, but we can’t and won’t build it for you. That’s up to you.

If you still want to pursue this path, then get someone who knows what he’s doing to help you. If you find such a person, then feel free to ask some more questions. Until such time, I’m afraid neither @peekay123 nor I can be of much help any more. There’s only so much we can do over a forum, and teaching electronics and programming is (un)fortunately not one of them.

Regardless of your decisions, I wish you the best of luck!