I am working with Arduino yun, and I would like to know how can I access sensor values from one arduino using another arduino. Which ways of comunication they are between arduinos? Can I access data from another arduino through wireless? Do I need additional hardware to accomplish this, or its possible with just two arduinos and one computer?
It is possible. Arduinos, depending on the model, can usually communicate via SPI, I2C, etc. Both Arduinos can send and receive data via SPI, for example, so you can hook them up to each other.
It also depends on the type of sensor data you have as well as how many open pins you have: if you really wanted to, you could set 8 bits of data to 8 different pins, and simply connect those pins to 8 pins on the receiving Arduino. That's a rather barbaric way to do it considering you have SPI at your disposal, though.
There are a couple of ways, without any external hardware you have :
SPI
I2C
Serial communication/UART
Serial is the easiest to use among these 3.
And for any other kind of communication you will require external hardware, so if you want to go wireless, then you have cheap RF modules, XBee, etc..
That said that's more appropriate question for Arduino SE site ;)
Check this page. https://www.arduino.cc/en/Tutorial/MasterWriter
I used the I2C to trigger sound from on one arduino and play it on the other. There was no noticeable delay. If you want to stream a lot of data then SPI should be used.
Related
I have a project in hand where I need to connect 5 or more arduinos as slaves to Raspberry Pi. Load Cells, Reed Switch, Solenoid lock will be connected to each of the arduino. The arduinos need to send the weight readings when a communication is started by the raspberry pi(master). Only a single arduino will be activated at a time. The arduinos will be placed at a maximum of 6ft distance from the raspberry pi. I need advice regarding how to make this connection. I read that I2C cannot be used for long distances so I am unsure if 6 ft is a long distance for I2C. Next, I am trying to see if a USB would work for my case but the issue is the Pi has only 4 USB slots. So can I use a external USB hub with an external power supply and connected each of the arduinos to the USB hub and provide individual power supply to the arduinos? Will this arrangement work or should I be looking at any other protocol apart from I2C and USB?? Any advice on this will be much appreciated. Thanks a lot for your time.
Arduino (Nano, Uno, Mega etc.) can communicate via SPI, I2C or UART.
Long story short, SPI is not suitable for your application. It is used for fast data transfer over short distances (usually milimeters or centimeters), so mainly for communication between chips mounted on the same PCB or PCBs close together (e.g. display shields).
Using I2C is perfectly fine (let's say up to 10 meters) and in your case it is a way to go. The maximum possible length depends on baud rate, for 10 meters a 9600 baud rate would be OK. The big advantage is that you need only 2 wires to connect all Arduinos, the disadvantage is that only one device can transfer data at the time – in your case, that does not matter.
UART is used for communication with many external modules (GSM, GPS, HMI, ...) and also in combination with USB-TTL chip for communication via USB (virtual COM port). In your case, you can use UART e.g. in combination with external UART-RS485 converter module, but there is no need since you can use I2C.
an ADXL345 and IMU9252 are connected to an arduino pro mini through i2c bus. both modules have different addresses.
so i should change i2c address in slave(arduino) continuously to access both modules data.
I need to know how is it possible and if there is any standard solution to manage this situation?
P.S: I'm using RTimulib for mpu9252 and sparkfun for ADXL345.
so i should adopt the solution regarding to these libraries.
Assuming you are using the standard Arduino Wire library, you need to use beginTransmission to begin an I2C transaction:
Wire.beginTransmission(address)
Just put the correct device address as the argument to that function.
I am new to Arduino and I would like to do a project that sends data, remotely. So, the Arduino would not be connected to Wifi/Bluetooth, Ethernet, etc. Would using a GSM shield be the best way to transfer data? I do not need to make phone calls or send SMS (unless sending SMS would be a better, more reliable, option) just data to a server, who's app I would create. If this is the best option, what else would I need to make this happen? For example, on top of the GSM shield (I am looking at something cheap like this: https://www.amazon.com/Geeetech-SIMCOM-Quad-band-Development-Arduino/dp/B00A8DDYB6/ref=sr_1_2?ie=UTF8&qid=1467651878&sr=8-2&keywords=Arduino+GSM+Shield) what other charges would I need to pay? I.E. would I also need to get another phone plan? Would I have to pay for a gateway service that would receive the cell phone data and then send it to my server?
Thanks your any thoughts on this
Wifi, ethernet or GSM, it depends on what you want to use, and what you have.
With all three you can send data to a server.
There is a bench of Arduino shields. All shields from Arduino come with a library to handle communication.
Other shields from other vendors exist and they provide their libraries too.
For Ethernet you can check the arduino shield https://www.arduino.cc/en/Main/ArduinoBoardEthernet.
For Wifi there are plenty. You have first the arduino shield. You can also take a look at the CC3000. Or the famous ESP8266. For all three you can find libraries.
For GSM, Arduino has a shield and a library. Arduino uses the Quectel M10 GSM moduel. You can find lots of examples in the arduino website and all over the net (https://www.arduino.cc/en/Guide/ArduinoGSMShield).
There exist other shields like the one you mentioned. Libraries does exist for those "other" shields however they are not as maintained as the arduino one.
You need to be careful though, you'll find over Amazon (and most likely on Alibaba) some GSM modules like SIM900A that are way cheaper, those are only dual band and will work only on certain contries.
There is another cheap GSM Module called the A6. It was made by espressif the company behid the ESP8266. It's relatively new and no library exist for it at the time. You can write you own functions to use it, but that would be some extra work.
In all cases, to use a GSM module you'll need a sim card with it's phone plan and all.
Another thing to consider is how to power these shields. They use more power than an Arduino can generate (A GSM modules datasheet recommend to use a power supply that can deliver up to 2A). If you power them straight from the Arduino, you may encounter some strange behaviour.
So the ideal way is to have for them an external power supply with the required amps and have a commun ground with the Arduino.
I'm on a project in which I must read the DC (1ms-2ms) of 16 PWM signals with 4 Arduino MEGA 2560, 4 PWM for each one. After have read it, I should send the 16 values to a computer. The initial idea was to use 4 Arduino Ethernet Shield connected to a router and then get on the computer. The other option is to connect the 4 Arduino directly by USB to the computer and perform it with each Serial.print. Which of the two options could give me better results? I have to emphasize that time is important, less than 20ms to receive the 16 PWM values would be optimal.
A greeting and thanks.
20ms is not really an issue here. Assuming you connect the Arduino over USB, using Serial, at 115,000bps, you can send the 4 bytes (Assuming a byte per Duty Cycle reading) to the control computer in .35ms.
Using TCP/IP, and a direct Ethernet connection, it will be orders of magnitude faster than that.
So, I would say, what are you more comfortable with in coding terms? The serial approach will be easy on the Arduino, but you might have to work a bit harder on the control computer. (For instance, will you use C++, and a Serial library like Boost::ASIO ?
Or, are you comfortable with TCP/IP socket programming? And if so, you will have a more robust solution, which will scale better for you.
What I have in mind is having a number of sensors (temperature, accelerometer, sound level meter) that are controlled by a micro controller. What I want to do is take this information and transmit it wireless to a laptop that will take this information and put it on to a web server using Zigbee. I don't know where to start.
Since you don't have any hardware as of yet, you might want to give the Arduino a try. The hardware is affordable, can be connected to your system via USB while being programmable in-system.
The basic board can be extended via so called "shields", which offer additional features. In your case, the XBee shield would be appropriate. Connecting your laptop to a XBee module is as simple as using Sparkfun's breakout board and a mini-USB cable.
The Arduino has a large community, so you will find a lot of resources, like books, online material, example code etc.
We also provide wireless modules that can be used for serial data transmission. They can be found at www.starmanelectric.com Our modules are very similar to the xbee, but more plug and play. They can be a great for going wireless for the first time. Our devices are designed to function like a "wireless cable" so if you're used to using wires then you'll be up and running in no time at all. We also have circuit examples for transmitting to a laptop serial port or USB. Any micro-controller will be fine for this application, as long as it has a serial port and a few ADCs to sample your data. Our modules also provide simple analog in/out which can run in parallel to the serial. If you want to compare to other systems, I would google "wireless serial modules"
Regards,
Michael
Starman Electric