change Arduino I2C bus address continuously - arduino

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.

Related

Arduino multiple serial/hid output

Hello has anyone found a way to use an Arduino as a serial device and hid device at the same time?
I thought of a few solutions but didn't know the best way to go about it.
my goal is I need a serial device so the computer can send info to the Arduino but I also need an hid device.
can I use them both though 1 USB port? probably not
or
can I rig up another usb or serial port on the Arduino and use that as hid?
or
should I connect the Arduino to a teensy and use that for hid?
Thank you just trying to find the safest solution I'm making a custom fixture for my little laser engraver.
I recommend getting an Arduino Leonardo, Arduino Micro, an A-Star 32U4, or any other Arduino-compatible ATmega32U4 board. These devices act as a USB serial port but they can also be an HID at the same time if you use the Keyboard or Mouse libraries that comes with the Arduino IDE.

Communication between 2 arduinos

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.

Best way to transfer data from Arduino to Server

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.

Is it possible to use both external power jack and USB port with Arduino?

I have the Arduino UNO board and I want to know if it is possible to use both the USB connection (for exchanging data) and the external jack to power supply it.
I will use the following cable: http://ecx.images-amazon.com/images/I/41OMXaj5cPL.SY355.jpg with a AC-DC 5V adaptor in order to power supply the Arduino. However, I want to use also the USB connection in order to send some data from the computer.
Both will be connected at the same time.
In short, I want the Arduino to be able to run even if the computer is OFF and whenever I open the computer to send data to Arduino from USB connection.
Is this possible? Will the Arduino Uno board support it?
Yes. From the official Arduino website:
Power
The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.
External DC power will override USB power if the Arduino detects it. [Source]
as other said, it is absolutely possible to have both usb and power jack plugged in.
but be aware that if you shut down your computer and turn it on after, when reading the usb port you'll restart the Arduino and might loose important data.
yeah both of them can be used. If you want to upload the code in arduino then simply use the usb cable otherwise keep it on adapter. it wont harm the device.
What I personally do is, I keep on plugging the adapter and remove the usb once I am done with uploading and then test it as normally the usb cable is quite small and I normally work on robots so I need long wires.
if you want just plugs it in, it's ok but Arduino board will chose one and usb has priority to other power source.
********* Very important :*****
if you are controlling other circuits, that are connected to an external power supply, with your Arduino and connecting it to your PC's usb, Arduino will have potential difference and it will cause current flow that will damage your PC and Arduino board. if you want to do such thing, you have to shield your Arduino board from your other circuits that you want to control and they have external power source. this could happen with optocouplers for digital ports, non signal analog ports with shield relays, and complex analog circuits for analog signals

WinUSB driver for Arduino

I'm using an Arduino to read data from the web and display it. I can easily pass the data as serial using the supplied drivers, because they identify the COM port so I can send serial to the COM port.
However, I want to use 'real' USB techniques so the device can be plugged in and out like a normal USB device. I'm looking at using WinUSB as the driver. However, USB is all new to me. Is there an .inf file that uses WinUSB and an Arduino (I have an Uno)?
The lack of information on this is making me think I am going about this incorrectly.
Turns out that an Arduino Uno is not a genuine USB device.
It acts as a Serial to USB adapter. Consequently USB drivers don't talk to it.
I got round this by writing a sketch which reported back what device it was when it got the correct query from the PC.
On the PC I just iterated the Serial ports and sent the query to each port. The one that replied was the Arduino.
After that I record the port number and send serial data to the Arduino.
To learn the USB portion, maybe you could combine V-USB and the UNO?
Check out V-USB.
V-USB is a software-only implementation of a low-speed USB device for Atmel’s AVR® microcontrollers, making it possible to build USB hardware with almost any AVR® microcontroller, not requiring any additional chip.
While not necessarily Arduino, it may provide you the learning exprience you want, and let you use incorporate your UNO device.

Resources