Arduino uploads data to shell objects and interacts with the FPGA

Source: Internet
Author: User

The implementation of the Arduino and FPGA interaction, of course, there is no new protocol, or based on serial communication, now learn a serial communication can basically drive most modules, and with a variety of single-chip computer seamless data interaction, Arduino because of its powerful library function support, in the implementation of many things will be convenient many , such as serial communication, Arduino on two lines of code, Verilog at least hundreds of lines, but from the perspective of learning knowledge, learning Arduino is just learning a software control hardware method, and a lot of things are simplified, and computer programming is no different, You might as well learn to learn a single-chip computer. At the very least, you can understand the use of various registers within it. I use Arduino is to play, of course, there are a lot of different experience, all know that Arduino is open source projects, we can use other people's code for free, of course, we have to share their code, open source to the end.

Arduino programming language does not say anything, using a simple version of the C language programming, General C language base of friends should be two days to get started, and then is the use of various functions, I was doing experiments, learned a function, map function. Now, say it! The following picture is actually very image.

Look again at the official explanation, which is to shift a number from one range to another.

Map (value, Fromlow, Fromhigh, Tolow, Tohigh)
Description

Re-maps a number from one range to another. That's, a value of Fromlow would get mapped to Tolow, a value of Fromhigh Totohigh, values in-between to values In-betwee N, etc.
I used the Arduino to collect the soil humidity module data, 200-100, Arduino read the maximum value of analog is 1023, and so big data, is not what we need, we need a percentage, so use the map function, Projecting the 0-1023 interval to 0-100, the data can be approximated as a percentage of soil moisture.

Arduino original serial port only one, then if you have to use two or more serial port to send and receive data to do, this time using the software to simulate the serial port can be. The official configuration process, call the Softwareserial library function,

Initialize configuration baud rate

Use the Serial.write () function when outputting, Here to note is serial.print to the serial port is the ASCII code value, serial.write input to the serial port is the real value, I need here is the Arduino collected by the soil moisture, of course, want to direct hexadecimal code.

To achieve data upload to the shell, the final thing is to need ESP8266 WiFi module, module configuration is as follows.

The ESP8266 module supports STA/AP/STA+AP three modes of operation.
*sta mode: The ESP8266 module connects to the Internet via a router, and the device is remotely controlled by a mobile phone or computer via the Internet.
*ap mode: ESP8266 module as a hotspot, realize the mobile phone or computer directly communicates with the module, realizes the LAN wireless control.
*sta+ap mode: Two modes of coexistence mode, that can be controlled via the Internet can be seamlessly switched, easy to operate.

We are here to facilitate the direct setting of two modes to coexist in a state.

The interface for the ESP8266 is as follows:

The port to use is TX,RX,CH_PD,VCC,GND

Tx,rx the rx,tx of the USB to TTL interface respectively,

CH_PD,VCC 3.3v (remember must be 3.3v)

GND grounding

Connecting the Internet of Things

Open the Serial debugging assistant, search the serial port, set the baud rate to 115200, and then unplug the ESP8266 VCC pin on the plug, will return a string of garbled and ready, indicating that the connection is normal, if there is no return value, check the PIN is connected correctly.

Send at command: + + +, returns closed, indicating the mode that was set before closing.

Send at+cwmode=3+ carriage return, set the WiFi module to AT/AP mode (WiFi module knowledge needs to see the manual), return OK, indicating the success of the setup

Send at+cwjap= "WiFi name", "WiFi password" + ENTER, connect WiFi. Returning OK indicates that the connection is correct.

Then send at+cipstart= "TCP", "www.bigiot.net", 8181+ enter, return, indicating connection to the shell net.

So the WiFi module is configured, and then connect the WiFi module to the development Board, after power, will automatically connect to the shell online.

After the WiFi module is configured. Here we use the first WiFi module configuration connected to the shell network, Shell network is an internet of things, can be implemented with the hardware remote interaction.

Register a shell net account www.bigiot.net

Click Add a Device

Add a data interface where you can modify the excuse type

Once added, each device has its own id,apikey,

Each device has a corresponding data interface and a corresponding ID.

Need several data interfaces you just add a few, I've added four here. Then according to the code to connect all the modules, connect the device, upload the program, note, upload the Arduino program must be 0, 1 pin unplug, otherwise the upload failed. After the successful upload, open the data interface, you can see real-time data upload, shellfish and related apps and the public number, as long as the device can be connected to the network, you can control the equipment, so remote control also without pressure.

Through the soft serial port sends the data to the FPGA,FPGA through the processing, sends the data to the host computer, thus realizes the FPGA and the Arduino data interaction, thus realizes the internet of things.

Of course, Arduino also has a lot of convenient and fun to play, interested friends can continue to play. If you want the source code of this experiment, please reply "Arduino" in the background of the subscription number to get the source and library files! Need this design FPGA part of the code background message, contact the main subscription number, you can get!

Reprint Please specify source: Ninghechuan (Ning River)

Personal Subscription Number: Open Source Fpganinghechuan

If you want to receive a personal blog post in time, you can scan the QR code on the left (or long press the QR code) to follow your personal subscription number

Know Id:ninghechuan

Micro Bo Id:ninghechuan

Original address: http://www.cnblogs.com/ninghechuan/p/7751382.html

Arduino uploads data to shell objects and interacts with the FPGA

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.