I'm working a little project where I make my own version of serial communication between 2 arduino megas using their digital I/O pins.
So there are a couple digital pins on arduino A that are set as output. These are plugged into two digital pins in arduino B which are set as input. Is there a way for arduino B to detect whether the output pins coming from arduino A are high or low?
I know this can be done with transistors, but is there a way to do it without them?
The digital pins from one Arduino can be connected directly to the digital pins on the other - no need for any transistors in between. Make sure there is a common ground between them so both boards are at the same reference level (connect the GND pins, or power both from the same supply).
You can read the digital pins on the receiving end by calling digitalRead(), and write to the digital pins on the sending end by calling digitalWrite(). Whatever protocol you implement will need to detect the high/low transitions and decode them accordingly.
I guess I'm curious why you wouldn't just use the built-in serial ports to communicate, unless this is just a learning exercise? Certainly worthwhile for learning, but unnecessary extra work otherwise...
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.
On Adafruit there was an example on how to connect a ledstrip to an arduino, but it said "For longer strips requiring more than 1A, wire power directly to the strip, then run power and ground wires back to the Arduino." I didn't fully understand it so i made a sketch on circuits.io . Since there isn't a normal ledstrip in there i used a RGB to show my sketch, but i can't test it. So before i fry my arduino or ledstrip can someone explain if this is correct or if it needs to be changed? Also can i connect everything on a breadboard or not, since the higher voltage and amp.
https://i.gyazo.com/27e9a6527805b6e4e898a8f32f66de61.png
That would work.
I believe this is the same as this https://learn.adafruit.com/rgb-led-strips/usage
about the breadboard it really depends on the breadboard they can vary from cheap ones 0.5A to 2A is usually the maximum current rating for a good solderless breadboard
Here are what you need:
Your Arduino.
An external power supply. Get something like this for your external power suply.
You led strip.
Connect:
PWM pulse of Arduino -> Data IN of led strip
All GND togheters
5V output of external power supply-> VCC of led strip
Computer -> USB -> Arduino
External power supplies give you high current levels, perfect for many leds. Dont worry about your breadboard melting, it should be able to handle it.
I am working on a project to read analog sensors. I need to read them and convert them to digital values and transmit them to the server and do the processing there. I need a ADC chip that can give out digital voltage or something that I can read through the GPIO of ESP8266 so that I can reject the MCU part in here. I cannot use the ESP's ADC pins as my input ADC voltage is little higher and also I don't want an extra circuit to be added in this. I just wanted to know if some chip like that is available that I can use it for my project.
Thanks in advance.
I'm in exactly the same position, the ADC of the ESP8266 is not ideal, since it will only allow values between 0v and 1v.
I havent been able to test it yet, but I found this page: https://github.com/rccursach/SAM_i2c_Dust_Sensor
In that tutorial they convert a analog value (in this case from a Sharp GP2Y1010AUF Dust Sensor) to a digital value with a ATTiny85, which can then be read over i2c. i2c is available on the ESP8266, so this seems like a proper solution.
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.
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