Show Posts
Pages: [1]
1  Using Arduino / Project Guidance / Chat server and client as a "bus" on: July 10, 2014, 01:59:12 pm
Hi everyone, I have been working on a project for a while now and have got it up and running thanks to the wealth of knowledge  here  smiley (thanks everyone for sharing all your experiences) I am at the point where i have made an android app that sends serial messages via Bluetooth to a arduino which takes the messages and controls a sainsmart relay board. Pretty simple serial communication type stuff. Now I am at the point where I want to expand. I am looking to create a network that will read messages much like a CAN bus but  will not have the physical limitation that CAN has. My idea would be to have a arduino chat server (telnet) and arduino chat clients. A android app that will setup telnet automatically and when a button is pressed, send a message to the server. The Arduino's would read the telnet messages as a string and take action as needed. This would make it kind of like a chat bus? Anyway, the Arduino's would all be connected by ethernet so distance would not be an issue. So I guess the questions I have are:
Can you have multiple telnet clients connected at the same and all sharing the same session?  
Would this method be a good way to provide communication between arduinos over ethernet?
Can anyone see a failure with this setup?

Thanks
2  Using Arduino / Project Guidance / Re: Bluetooth and App Inventor on: October 28, 2012, 10:27:30 am
This is nice PaulS, It seems like this could also help keep errors from being injected since it only looks at whats inside the packet ignoring everything else. This also seems like it is more modular and could be used for larger scale projects without having to do as much work. I like it. Thanks for the example, this gives me lots to think about.
3  Using Arduino / Project Guidance / Re: production time on: October 28, 2012, 12:46:42 am
Have you looked at digi-key or mauser? Maybe element 14?
4  Using Arduino / Project Guidance / Re: Bluetooth and App Inventor on: October 27, 2012, 11:58:00 pm
Well if anyone else has the same questions I did I will answer some of them now. The sketch I posted above works!.......kinda. As PaulS has pointed out it is a rough way of doing things. I don't know how to do it better but Im working on it. As far as App inventor goes: If the bluetooth is in slave, The App can be in client. It may work in Server as well or might not but I do know it will work in client mode with the bluetooth as slave. The reason it wouldn't turn the pins off is that I am a poor self checker and I didn't notice that I had off lowercase in my app code and OFF upper case in arduino. Changed arduino code and it works and is quite responsive. I now have a app that has 8 toggle buttons that turn pins 2-9 on and off. I have the bluetooth on the tx,rx pins (0,1). All the app is doing is checking the state of the pins and sending text to the arduino over bluetooth. So if button 2 is pressed it checks to see if pin 2 is on or off. If pin 2 is on it sends text "2off" and if pin 2 is off it sends text "2on". As seen in the code, The arduino reads the text and if the text matches any of the if statements then it will execute a digital write based off of what the text was. (write pin X high or low) Now I get to look into the suggestions that PaulS has made to make the code better and then on to making the app look so fresh and so clean. So may other noobs who are looking at bluetooth learn from my mistakes.
5  Using Arduino / Project Guidance / Re: Bluetooth and App Inventor on: October 27, 2012, 10:59:52 pm
So I probably shouldn't admit to it but I will. I was reading some of Pauls other posts (helping out some other people, Paul seems to be a very helpful person) I read that they had the usb powering the arduino and once they went to battery it fixed some problems. I figured that since I didnt have any data going over usb it wouldn't interfere but it was. I the arduino on external power and was able to get the Pins to turn on when they were supposed to. I would press the button on my app to turn them on and...they did! smiley-yell then I went to turn them off  smiley-cry No dice. So I am doing a little better than I thought but not perfect....ok not even good. hmmm
6  Using Arduino / Project Guidance / Re: Bluetooth and App Inventor on: October 27, 2012, 10:32:09 pm
PaulS thank you for taking time to help explain this. I realize this is some low level bone head stuff that my thick scull is having a hard time grasping. Its nice to have some insight. I have searched examples but it seems like bluetooth is not well documented and when it is its above my understanding. So I need to have a marker of some sort at the end of the command such as "1on" would be "1on#" the # would be the marker telling arduino that at that point it needs to do what ever it has been set to do. Otherwise the commands could string together and the arduino would see "1on2on3off" which would look like nothing instead of 3 separate commands. Here is what sucks, I don't know how to search this because I don't know what it is called that I am searching. Is there a topic that you could suggest I go search so I don't have you going crazy trying to explain everything Arduino? Another question which this forum might know the answer to: In app inventor it has bluetooth client and server. If i have the bluesmirf in slave mode, should the android app be in Server or Client? I would think that this is just another way of saying master and slave and that if the bluesmirf is in slave then the android app should be a server.
7  Using Arduino / Project Guidance / Re: Bluetooth and App Inventor on: October 27, 2012, 09:58:59 pm
Thanks for the reply. I would think that serial would be fast enough, I have seen robots controlled over bluetooth that seem responsive enough. However is there a better way to be doing wireless control? Or is it that I need to have Delays in the code? I guess that would be what you are saying with the end of record in a way. I will research the end of record method and see if I can work something up, thanks again. If anyone else has any tips or better ways of creating bluetooth pin control please let me know as I have picked this route only out of not knowing any other way.
P.S. Any good links of examples of serial code that show serial comms?
8  Using Arduino / Project Guidance / Bluetooth and App Inventor on: October 27, 2012, 03:18:03 pm
I am working on a project that I would like to have buttons on my phone send text over bluetooth which the arduino would read and turn pins on or off. So button one would send "2on" over bluetooth and the bluetooth would send that over serial to the Arduino. The Arduino would see "2on" and know to write pin 2 HIGH. The app that i am working on can connect to the bluetooth but nothing happens after that. I press buttons but the Arduino doesn't write to pins. I don't see rx/tx lights either. I have the bluetooth rx to pin 1 of my UNO and bluetooth tx to pin 0. I am running my app as a bluetooth client and the BlueSMiRF as a slave. Do I need to change my app to Server? Am i missing something about how text gets sent over serial? I am using the bluetoothclient1.sendtext block with a text of "8on" to send text to turn on pin 8 in App inventor. If anyone has any critiques for me I would appreciate it. This is my first real project in app inventor and Arduino and my skills in coding are poor. (Im sure the code will show that I don't know what im doing)  smiley-roll I have seen examples of reading the state of the pin and then writing the inverse using "!" and thought that might be a better way to o it and then just send a number over serial that would represent the pin and would toggle but I just don't know how to implement that so I went this route.


String readString;

void setup () {
Serial.begin (115200);
// Outputs

pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);
pinMode (7, OUTPUT);
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
}

void loop () {
while (Serial.available ()) {
delay (10);
if (Serial.available ()> 0) {
char c = Serial.read ();
readString += c;
}
}
// Check serial and write pins high or low.
if (readString.length ()> 0) {


if (readString == "2on") {
digitalWrite (2, HIGH);
}
if (readString == "2OFF") {
digitalWrite (2, LOW);
}
if (readString == "3on") {
digitalWrite (3, HIGH);
}
if (readString == "3OFF") {
digitalWrite (3, LOW);
}
if (readString == "4on") {
digitalWrite (4, HIGH);
}
if (readString == "4OFF") {
digitalWrite (4, LOW);
}
if (readString == "5on") {
digitalWrite (5, HIGH);
}
if (readString == "5OFF") {
digitalWrite (5, LOW);
}
if (readString == "6on") {
digitalWrite (6, HIGH);
}
if (readString == "6OFF") {
digitalWrite (6, LOW);
}
if (readString == "7on") {
digitalWrite (7, HIGH);
}
if (readString == "7OFF") {
digitalWrite (7, LOW);
}
if (readString == "8on") {
digitalWrite (8, HIGH);
}
if (readString == "8OFF") {
digitalWrite (8, LOW);
}
if (readString == "9on") {
digitalWrite (9, HIGH);
}
if (readString == "9OFF") {
digitalWrite (9, LOW);
}

readString = "";
}
}
Pages: [1]