Control Arduino Pins via ESP8266 Webserver - arduino

I want to program a simple Webserver with an ESP8266 but I want to connect the ESP8266 to an Arduino Mega. I want to connect a LED and a Sensor to the Arduino and control the LED and read the sensor data via the ESP8266 Webserver.
I am a beginner and dont want too complex solutions. It's just a simple school project.
For the Webpage I am sending just some HTML Code, I do not use Blynk or anything like that.
My question is how can I connect the ESP8266 to the Arduino and control it's pins?

There is a million ways to connect an ESP to an Arduino.
Without any shields or perihperals you can basically use any wired bus that does not require transceivers.
For example I2C or SPI.
With shields or peripherals you can use CAN, LIN, RS232, Ethernet, WIFI, Bluetooth, radio, optical and audio transmission... The list is endless.
You can of course read a sensor with the ESP so an Arduino Mega is not really necessary.

Related

Sending Data from Arduino to Android using Bluetooth

I am trying to do a project based on arduino and Android in which I want to use ultrasonic sensors and Bluetooth module hc-05 . I want to detect any obstacle using ultrasonic and send it's distance to Android app using Bluetooth. I am completely new to arduino and have never used it before . How could I connect both the Bluetooth and ultrasonic sensor to arduino uno board without using breadboard? Is it possible to connect both of them without using breadboard and just the jumper wires?
You can connect the Bluetooth Module and Ultrasonic Sensor with jumper wires directly to the Arduino.
Depending upon the Ultrasonic Sensor you are interfacing, there must be a library or a sample code. You can tweak the code to get the distance in your desired format or variable.
As far as the Bluetooth is concerned, you can operate it at 3.3v or 5v depending upon the module you use. Most of the Bluetooth module support both 3.3v and 5v - as they have voltage regulators on their break out. I have used these and they work on 3.3v as well as 5v
For instance, check the Bluetooth HC - 05 Module in the below link :
http://www.amazon.in/Verve-VTA009-Bluetooth-Module-HC-05/dp/B00S15XTG8?tag=googinhydr18418-21&tag=googinkenshoo-21&ascsubtag=7a58e842-4c10-40bf-a48f-339edef372a7
For implementing the Bluetooth communication, prefer using the Software Serial. If you connect the Bluetooth HC 05's Rx and Tx to the Arduino's Hardware UART Pins, there can be unpredictable results. I have experienced that using HC05 with Software Serial is reliable. Additionally, you can use the Serial Monitor to debug your code at the same time. I mean, you can send the same data on Software Serial and the Serial port and check if things are as desired.
You can implement, the HC-05 Software Serial at 9600 baudrate. 9600 is the default baudrate on most HC 05 Modules.
For developing the Arduino code and testing it, you can use a terminal client like PuTTY on you computer. You need to establish a bluetooth connection between your computer and HC 05.
HC-05 runs at 3.3V, make sure you do level conversion from 5V to 3.3V using a zener diode. Or buy a level converter if you are new to electronics. If you don't, there is a good chance you will blow up the HC-05. If you could add a photo we can see if its already done on the Bluetooth module, then you need not worry about level conversion
HC-05 is basically a wireless serial port over bluetooh. On arduino create a software serial post using the library SoftwareSerial and send the sensor data to that serial port
There are libraries available for popular HC-SR04 ultrasonic sensor, if that is the sensor you are using.
For testing on android many app are availables like Bluetooh Terminal, you can receive the data sent from arduino.
Yes the whole project can be done without breadboard using connecting wires.

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

Combine RPI and Arduino

I have a few questions about rpi and arduino.
1. Is it possible to provide arduino and rpi two-way communication? (Sending data from the sensors to the Arduino and from arduino to RPI and processing information on RPI).
2. Can i use sensors from Arduino on RPI?
3. Can I programming RPI using C++ (such an as Arduino)?
Yes, checkout the ArduPi project. Serial communication (a USB cable) between the two is a fairly simple way to get started. It provides bi-directional communication between Raspberry and Arduino. And yes, you can compile C/C++ on the Raspberry Pi (but in most cases, you cannot directly reuse C/C++ for Arduino directly on the Pi, as it might use some special .h files not available on the Pi).
Yes it can. Just use I2C Bus (or Two-Wire). By TWI You can easily communicate Rpi and Arduino.
You can directly read the Arduino through the USB serial port. There is a Linux board I came across that you plug directly on top of your Arduino like a shield (It's called the Rubix) .
Of course it is, Uart , I2C or SPI.
I highly recommand Uart.
1.The library GPIO has demo of Uart Communication.
2.You can use USB to connect the serial port.
you can follow this tutorial to make it run
https://electrosome.com/uart-raspberry-pi-python/
Yes you can communicate using I2C. There should be a wired connection between RPi and Arduino to communicate using I2C. If you wanna try wireless communication you can use ESP8266 13 arduino wifi shield.
https://www.tindie.com/products/doit/esp8266-esp-13-wifi-web-sever-shield-for-arduino/
Otherwise you can use a ESP8266 module replacing arduino and you can communicate bidirectionally using wifi.
Most sensors that work with the Raspberry Pi, also work with Arduino and other boards like it.

connect arduino to arduino mega adk by USB

I have an arduino mega ADK, with usb port, and an arduino uno.
- On the arduino uno, I put a xBee shield with the wifly module for connect to the internet.
- On the arduino mega ADK, I put the TinkerKit! shield.
I need to use both : xBee shield and TinkerKit!. and the single way i found, is to connect the arduino uno to the arduino mega ADK by USB wire (the wire is the one I use to connect an arduino to my computer).
Do you think it could work ? If yes, How can I get what is writting on the outpu of the arduino uno ? If no, is there an other way to do what I need ?
yes, it can be done, but is is way more easier to use directly the Hardware/Software Serial. Even if you get iw work, it will be a serial simulation over usb..
So using USB is just a layer of complexity that can break, and nothing more.

Arduino Wifi Shield SPI commands

I'm currently using the Arduino Wifi Shield. It works fine with the Arduino Library, but I have a project in which I need to get rid of all the Arduino library, and use only the AVR-libc.
Therefore, in order to use the Wifi shield, I would like to know where there is a documentation about the protocol used on the SPI bus between the arduino and the shield, so that I do not need to use the Wifi Library.
Am I forced to look at the source code, or does any document exist?
Thanks.
The documentation for SPI will be contained in the datasheet for the MCU used in the Arduino. For AVR-based Arduinos, look in the section titled "SPI – Serial Peripheral Interface". For the Arduino Due, see the "Serial Peripheral Interface (SPI) Programmer Datasheet" section.

Resources