Arduino uploads data to shell Iot platform and interacts with FPGA. arduinofpga

Source: Internet
Author: User
Tags shell account

Arduino uploads data to shell Iot platform and interacts with FPGA. arduinofpga

This article implements the interaction between Arduino and FPGA. Of course, there is no new protocol, or it is based on serial communication. Now, learning a serial communication can basically drive most modules, moreover, it can seamlessly interact with various single-chip microcomputer data. Because of its powerful Library Function Support, Arduino is much more convenient in implementing many things. For example, for serial communication, Arduino only has two lines of code, there are at least a hundred lines of OpenGL, but from the perspective of learning knowledge, learning Arduino is just a way to control hardware using software, and many things are simplified, similar to programming on a computer, it is better to learn SCM. At least, you can understand the use of various internal registers. I used Arduino to play games. Of course, I still had a lot of different experiences. We all know that Arduino is an open-source project. We can use other people's code for free. Of course, we also need to share our own code, it will be open-source to the end.

The Arduino programming language is nothing to say. It uses a simple version of C language programming. Generally, a friend with C language basics should be able to get started in two days, and then use various functions, during my experiment, I learned a function called map. Let's talk about it now! The following figure is actually very vivid.

Let's look at the official explanation, that is, to change a number from one range to another.

Map (value, fromLow, fromHigh, toLow, toHigh)
Description

Re-maps a number from one range to another. that is, a value of fromLow wocould get mapped to toLow, a value of fromHigh totoHigh, values in-between to values in-between, etc.
I used Arduino to collect data from the soil humidity module, ranging from 1023 to. The maximum analog data read by Arduino is. However, this big data is not what we need, we need a percentage, so we can use the map function to project the 0-1023 range to the 0-100 range, so the obtained data can be considered as the soil humidity percentage.

Arduino has only one serial port, so what if two or more serial ports are required to send and receive data? In this case, use the software to simulate the serial port. The official configuration process calls the SoftwareSerial library function,

Initialize configuration baud rate

Use Serial for output. the write () function. Note the Serial. print lost to the Serial port is the ASCII code value, Serial. write inputs to the serial port are real values. What I need here is the soil humidity collected by arduino. Of course, I want to directly use the hexadecimal code.

To upload data to the shell Iot platform, the ESP8266 Wi-Fi module is required. The module configuration is as follows.

The ESP8266 module supports three working modes: STA, AP, STA, and AP.
* STA mode: The ESP8266 module connects to the Internet through a router, and the mobile phone or computer remotely controls the device through the Internet.
* AP mode: As a hotspot, The ESP8266 module can communicate directly with the module on a mobile phone or computer to implement wireless LAN control.
* STA + AP mode: the coexistence mode of the two modes, that is, the seamless switch can be achieved through internet control, facilitating operations.

We can directly set the status to coexist in two modes for convenience.

Shows the ESP8266 interface:

The required ports are TX, RX, CH_PD, VCC, And GND.

TX and RX are connected to the RX, TX, and,

CH_PD, VCC connected to 3.3 v (it must be 3.3 v)

GND grounding

Connect to IOT

Open the serial port debugging assistant, search for the serial port, set the baud rate to 115200, and unplug the VCC pin of ESP8266. a garbled string and ready are returned, indicating that the connection is normal. If no return value is returned, check whether the PIN is correctly connected.

Send the AT command: ++ and return CLOSED, indicating to disable the previously set mode.

Send AT + CWMODE = 3 + press enter and set the WiFi module to AT/AP mode. (For more information about the Wi-Fi module, see the manual.) If OK is returned, the setting is successful.

Send AT + CWJAP = "WIFI name", "Wi-Fi password" + press enter to connect to WIFI. If OK is returned, the connection is correct.

Then, send AT + CIPSTART = "TCP", "www.bigiot.net", 8181 + press enter, and return, indicating to connect to the shell network.

In this way, the WiFi module is configured, And the WiFi module is connected to the Development Board. After power-on, the module automatically connects to the shell network.

After the Wi-Fi module is configured. We use the first WiFi module to connect to the shell network. The shell network is an Iot platform that can remotely interact with hardware.

Register an Internet Shell account www.bigiot.net

Click to add a device

Add a data interface. Here we can modify the excuse type

Each device has its own ID, APIKEY,

Each device has a corresponding data interface and corresponding ID

You need to add several data interfaces. Here, I have added four. Connect all modules to the device and upload the program according to the code. Note that when uploading the Arduino program, you must unplug the 0 and 1 pins; otherwise, the upload will fail. After the upload is successful, open the data interface and you can see that the data is uploaded in real time. The shell Iot platform also has related apps and public numbers. As long as the device can connect to the network, you can control the device, therefore, remote control is not under pressure.

The FPGA sends data to FPGA through soft serial port. After processing, the FPGA sends the data to the host computer, which enables data interaction between FPGA and Arduino. This enables Iot.

Of course, there are many easy and fun ways to play with Arduino. If you are interested, you can continue to play. If you want the source code of this experiment, please reply "Arduino" in the subscription number background to obtain the source code and library file! If you need to send messages to the background of some FPGA codes in this design, contact the subscriber to obtain the message!

 

For more information, see NingHeChuan)

Individual subscription number: open-source FPGANingHeChuan

If you want to receive a blog post pushed by someone in time, you can scan the QR code on the left (or long-Press the QR code to identify it) to follow the personal subscription number.

Zhihu ID: NingHeChuan

Weibo ID: NingHeChuan

Address: http://www.cnblogs.com/ninghechuan/p/7751382.html

Related Article

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.