I am trying to connect two Arduino Yun boards to each other via WIFI (make one board control a pin on the other board an vice versa) and I am having trouble making it work the way I want to.
This is where I've gotten so far:
I have two Arduino Yun boards with a simple sketch installed on each, which works fine as long as I keep the "connecting-each-other"-part out of it. It uses a potentiometer on the analog port, reads its value, maps it to the range of 0-255 an fades a LED up or down on one of the digital pins (brighter / darker) depending on the given value. Now I want to use the potentionmeter of one board to control the LED on the OTHER board.
To do that, I tried to use the REST API. I combined my sketch with the code from the "Bridge" Example Sketch, which sets up a http-client/server on the Arduino Yun (on the Linux part) allowing it to receive requests to control and read patricular pins via http.
When using the specific URL for the REST API in a browser, it works fine. For example: when I type "http://myarduino.local/arduino/digital/3/1" it sets the value of digital pin 3 to 1 (i.e. LED is switched on) --> so that's all fine
I am not sure how to continue at this point, since I dont want to control the board from a browser or app but make one Arduino Yun control another Arduino Yun directly. If I put a http request in my sketch like mentioned above via client.get and client.read (as in the example sketch) it does not work. See example code below. It doesnt have any effect nor does anything appear in the serial monitor (with the original URL "http://arduino.cc/asciilogo.txt" like in the example, the ascii code appears in the serial monitor)
HttpClient webclient;
webclient.get("http://ardu1.local/digital/3/1");
while (webclient.available()) {
char c = webclient.read();
Serial.print(c);
}
Serial.flush();
I am a beginner with Arduino Yun boards and maybe I am missing something?
Thanks for any help or pointing me in the right direction. Or if you need more information to help me with this problem, please let me know.
I found another way to connect two Arduino Yun boards directly, or as close to "directly" as it probably gets. The REST API was not the right way to go. So this is for anyone who might encounter the same "problem":
After some research I came across "Spacebrew". It's based on "websockets" and requires a server to connect the boards to each other, but it is very flexible. It's also fairly easy to setup a spacebrew server locally. It allows every client (like a Arduino Yun board) connected to the server to publish different types of data (boolean, range, value) and/or to subscribe to the published data from other devices using a simple webinterface. The good thing is, that the connection is fast and there's no waiting for the connection to be reestablished when there is data to be sent.
I used the Arduino Example Sketch "spacebrewRange" and it worked fine for me.
It also requires a few other things before it can work, but its explained on the website and in a tutorial:
http://docs.spacebrew.cc/gettingstarted/
http://de.slideshare.net/julioterra/spacebrew-server-workshop-itp
Trying to do the same, it seems, and for me it works (this bit at least :-|
I let one arduino request the URL "http://router.domain:port/arduino/key/value", using a Process which runs cURL. The receiving arduino interprets this request to set the key to the value, using a YunClient.
From the URLs in your question, it seems that you are missing the mandatory "/arduino/" component in the path name. As far as I know, this is needed to direct any requests directed at the OpenWRT stack to the arduino/Leonardo part.
Related
I'm using the SwiftySensors CocoaPod to connect to a Wahoo Smart Trainer. It's advertising CyclingPowerService and DeviceInformationService. I've been able to get speed and power values without issue. Wahoo apparently extended the CyclingPowerService standard to allow setting resistance via that service instead of the Fitness Machine Control service.
https://github.com/codeinversion/sensors-swift links out to another Github page dealing with that extension, but that link is broken.
My question is: how should I go about setting the trainer's resistance? Wahoo's app can do it, so the machine is equipped for it. This is the only time I need to change the trainer's settings. Otherwise, I'm just reading sent information and SwiftySensors works great.
I've referenced the following post: Writing BLE to Cycling Control Point - Adding Resistance. Someone there said using CyclingPowerService to set resistance was possible without offering any guidance. I'm not very experienced with Bluetooth, so any information would be great!
Thank you Jordan. That was the answer. The broken link I referenced must have been pointing to the following repo: https://github.com/WahooFitness/sensors-swift-trainers
The following instructions assume that you're already able to connect to the trainer to receive data from it, like speed and power, using the SwiftySensors CocoaPod and the CyclingPowerService. Using the repo linked above, I was able to set the resistance to the Wahoo Snap trainer. Note that after you install that new repo, before you start scanning for sensors to connect to, you need to call
CyclingPowerService.WahooTrainer.activate()
From there, you set the resistance with
if let wahooTrainer = cyclingSpeedService.wahooTrainer {
wahooTrainer.setResistanceMode(resistance: 0.5)
}
The resistance is set using percentages. The value for resistance will be a Float, somewhere between 0 and 1.
So the title sounds stupid. I'm not really sure how to really word it, but I want someone to help guide me on what to look for. Little back story first so I'm working on a Raspberry Pi project that involves using an LTE service currently I have a dashboard running on a AWS EC2 web server with a simple user working user login.
I have a raspberry pi that is directly pointed to the dashboard/account via an IP address. I want to know how to do something like giving a device an ID and having it connect to an account. So for example with Nest products you have the QR code on the camera you take a photo and that devices get applied to your account.
Is this even possible with Raspberry Pi(I'm sure anything possible, but is it feasible? If so what should I look into or learn how to do such thing. I know its not something that can be answered in a short paragraph just looking for some guidance.
Right, thanks. Well, I think you need to program this into the pi server app. So currently your Pi is reading a sensor and sending this data to the web server, right? I suppose you have a daemon running, taking readings, and doing an API REST call to the server backend, correct? So what you want is to have a unique code for each pi, sent with the API call, and then on your DB server side,you store all readings related to their unique code.
You don't need to pre-validate this code, there are GUID generators that will create a number for you, guaranteed to be unique for all eternity, so on the PI, you set it up once, to create the PI's code, and use it from then on. Now, server side, then associating a device with a user is a matter of choosing the data associated with a given gui. And I think that covers it.
You can improve on this basic idea by giving it more thought, but I think it's a good starting point! Do let me know if I can help you with anything else!
I am new to Raspberry and VOIP. I am interested to make a door intercom system using raspberry, as I read most of the post here and those are really helpful,one of the raspberry is acting as server (Asterisk and PBX). I was able to call using sflphonebut that was only for desktop mode and I am interested to call using CLI and for that I installed "PJSIP" as reffered by most of users, but don't have any idea what to do next (I mean how should i start). As it is written after installation I am supposed to try for "pjsua" and "pjsystest" in pjsip-apps/bin, but it doesn't ring any bell for me.
Sorry for my level as beginner but if you don't begin how are you supposed to masters it.
I shall be very thankful.
so i can't explain all of the stuff you need to know, but with this Site you should be able to register to you PBX. It's an documentation to the high level API of PJSUA. If you go further on that site they will lead you through the things you have to do to establish a call.
Although this can be very frustrating because there are many error that can appear. There are some python test application under pjproject/pjsip-apps/src/python/samples, here you should firstly try to establish a call between two clients to be sure you server is well configured.
Just for info, the dest_uri you have to give in the call.py is like so sip:ip:port and you have to change the values in the register.py to your client infos. Then run the register.py in one shell and the call.py in an other shell.
Hopefully i could help you over some barriers, feel free to ask if something was unclear.
I am wanting to give back to a small gaming community. The idea is to make an app that acts like a chat client to connect to the game servers. I am trying to grasp the concepts on how connections work through examples I've found on the web, since I am self taught by seeing examples.
So far the examples I found are for connections on the same network. What I need is some kind of example that will allow me to connect from different networks or at least an explanation on what I need to do. Also I need to be able to get around a router without with setting port forwarding on the router.
In the end the app will be connecting to the game developer's server but I need a working app before I get his permission to connect to his servers.
Any help will be most appreciated. If any additional information is needed to help just ask and I'll do my best to fill in the gaps.
That is a very broad question, but I try to give you as much information as possible from by point of view. As I'm not yet sure if you want to have a P2P Connection (game-application to game-application) or a standard server model, I will just mentioned different approaches to this problem.
Adobe has support for P2P since a long time. Read some FAQ, esspecially "How does RTMFP differ from RTMP?" (I try to choose Sources with infographics, as that helped me to understand it).
What you really should start playing with and making first steps in, should be NetConnection. This is the very basic Function that will allow you to communicate to a Server running e.g. PHP or connecting to a Flash Media Server (FMS). FMS is inpartcular interresting for you, as it really boosts the ideas what you game could do, but setting up a FMS is not that easy,to host a own instance is even more complex. So if you come to the conclusion that you want to travel the road of using a FMS, I can suggest you Onyx Server. They mainly marketing theirself as a Streaming service, but in reality you will get access to a FMS for a ok'ish price (FMS instances on Amazon were way worst the last time I checked).
The FMS basicly only a Flash AS2 File with some extra Commands. Your FMS can handle real-time (!) persistent connections (!) with any client that connects to it. Everyone is able to connect to the server at first, and you can then choose in your FMS Script what a client have to bring to the table to stay on the server or is rejected. After that, you have a very string tool for a Game. For example, you could have a game instance connect to it, tell the server that an enemy was hit and the server near-instantly (the speed is really amazing, there is no feeled delay, it really is instant. Its called SharedObjects) pass this information down to the enemy game instance. I used FMS only for one project and it was a very long ride to understand it and work with it, but it was a really nice experience, as you code the Server in the "same" language like the game itself (AS2, AS3 = ECMA).
If you dont want to spend money at this stage, you can use the Adobe RTMFP Instance at p2p.rtmfp.net. It is, as far as I know, only for testing and you will be rejected if you misuse the service for a real project, but for starting and testing it will do. If you use the Cirrus Engine, you can even follow this Tutorial. You will find sample code in there:
// Cirrus connect info
private const SERVER:String = "rtmfp://p2p.rtmfp.net/";
private const DEVKEY:String = "{YOUR_DEVELOPER_KEY}";
// Used to connect to the Cirrus service
private var _netConnection:NetConnection;
_netConnection = new NetConnection();
// Listen for status info
_netConnection.addEventListener( NetStatusEvent.NET_STATUS, onNetStatus );
// Connect to Cirrus using our unique URI
_netConnection.connect( SERVER + DEVKEY );
My adive for you would be: Try getting comfortable with NetConnection. It is really straight forward. When I first started using it, I had a couple of days struggeling and reading a lot on the web, but I learned a lot doing so. You should too. Use NetConnection and try to create two simple AS3/FLA instances of your code that both connect to the same domain (use the adobe rtmfp domain for now) and try to exchange some simple String-Data between these instances.
To take some of the pain of your shoulders, add the minimum amount of listeners to your NetConnection like so:
//Main NetConnector
nc = new NetConnection();
//Troubleshooting Listener
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nc.addEventListener(NetStatusEvent.NET_STATUS, status_handler);
//nc.objectEncoding = ObjectEncoding.AMF0; //Default
nc.client = this;
nc.connect("https://some-domain");
////////////////////////////////////////////////////////////////////////////////
/// CALL ERROR LISTENER
////////////////////////////////////////////////////////////////////////////////
private function status_handler(e:NetStatusEvent):void {
//trace("NetStatusEvent");
dispatchEvent(new CallEvent(CallEvent.CALL_NATIVE_NET_STATUS, e, true ));
}
private function securityErrorHandler(e:SecurityErrorEvent):void {
//trace("SecurityErrorEvent");
dispatchEvent(new CallEvent(CallEvent.CALL_NATIVE_SECURITY_ERROR, e, true ));
}
You will get alot of errors and netStatus and NetSecuriy Events. Flash will often run into Sandbox-Violation errors when you now know what you are doing. That can be frustrating but if you keep it up, google every error and compare you implementations with the implementation of others, you will wrap your head around this and can do really neat stuff with it.
I recommend you google sources and tutorials for NetConnection and stick to one that is on your level of knowledge.
Good Luck.
So I have been modifying the chat program found here: http://www.dreamincode.net/forums/topic/259777-a-simple-chat-program-with-clientserver-gui-optional/ and I am at the point where I am ready to use it between twp pc's.
The problem is, I do not know enough about server-client relationships to set it up. Is there anything missing in the code for this to work? I just want to link two laptops to chat with one another. Is there any server softare I need to run or something?
I tried openfire but couldn't figure out how to link it, every port number I tried (listed in the admin page) didn't work. This is my first attempt at anything like this and probably beyond my current level of understanding which is why I would greatly appreciate a straightforward solution.
I chose this becaue I needed to do a lot of customization to the code so please use the ones on the page above as a reference. I would post the code here but there are 5 classes and they are neatly displayed on that page already with a explanation of each.
Thanks in advance!
Before you start trying to incorporate external libraries or functions, understand the code. Play around with it a little. See what does what and if you change this setting or that what will happen. Bare in mind that the code is separated into 2 applications:
Client - [ClientUI + Client + ChatMessage]
Server - [ServerUI + Server + ChatMessage]
Check that the application works on a single machine. So keep the server class the same and simply edit the client class so that it points to the current machine.
Run both the server and the client (from the example) on the same machine and when the client asks for the server location input 127.0.0.1 then put the port number you gave for the ServerSocket in Server. This should point to your machine and if this works but not when using 2 separate machines check your firewall settings.