Arduino overview

Arduino is a prototyping platform (open source) based on easy-to-use hardware and software. It consists of a programmable circuit board (called a microcontroller) and off-the-shelf software called the Arduino IDE (Integrated Development Environment) for writing and uploading computer code to the physical board.

 

The main features are:

Arduino boards are able to read analog or digital input signals from different sensors and convert them into outputs such as activating motors, turning LEDs on/off, connecting to the cloud and many more.

You can control board functions by sending a set of commands to the microcontroller on the board through the Arduino IDE (upload software for short).

Unlike most previous programmable circuit boards, the Arduino does not require additional hardware (called a programmer) to load new code onto the board. You just need to use a USB cable.

Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn programming.

Finally, Arduino provides a standard form factor that breaks the functionality of a microcontroller into an easier-to-use package.

Arduino板卡

Types of Arduino Boards
Various Arduino boards are available depending on the different microcontroller used. However, all Arduino boards have one thing in common: they are programmed through the Arduino IDE.

The difference is based on the number of inputs and outputs (number of sensors, LEDs and buttons that can be used on a single board), speed, operating voltage, form factor, etc. Some boards are designed to be embedded and have no programming interface (hardware), so you need to buy them separately. Some can run directly from a 3.7V battery, others require at least 5V.

Below is a list of the different Arduino boards available.

Arduino board based on ATMEGA328 microcontroller

板名称 工作电压 时钟速度 数字i/o 模拟输入 PWM UART 编程接口
Arduino Uno R3 5V 16MHz 14 6 6 1 USB通过ATMega16U2
Arduino Uno R3 SMD 5V 16MHz 14 6 6 1 USB通过ATMega16U2
Red Board 5V 16MHz 14 6 6 1 USB通过FTDI
Arduino Pro 3.3v/8 MHz 3.3V 8MHz 14 6 6 1 FTDI兼容头
Arduino Pro 5V/16MHz 5V 16MHz 14 6 6 1 FTDI兼容头
Arduino mini 05 5V 16MHz 14 8 6 1 FTDI兼容头
Arduino Pro mini 3.3v/8mhz 3.3V 8MHz 14 8 6 1 FTDI兼容头
Arduino Pro mini 5v/16mhz 5V 16MHz 14 8 6 1 FTDI兼容头
Arduino Ethernet 5V 16MHz 14 6 6 1 FTDI兼容头
Arduino Fio 3.3V 8MHz 14 8 6 1 FTDI兼容头
LilyPad Arduino 328 main board 3.3V 8MHz 14 6 6 1 FTDI兼容头
LilyPad Arduino simply board 3.3V 8MHz 9 4 5 0 FTDI兼容头

 

Arduino board based on ATMEGA32u4 microcontroller

板名称 工作电压 时钟速度 数字i/o 模拟输入 PWM UART 编程接口
Arduino Leonardo 5V 16MHz 20 12 7 1 本机USB
Pro micro 5V/16MHz 5V 16MHz 14 6 6 1 本机USB
Pro micro 3.3V/8MHz 5V 16MHz 14 6 6 1 本机USB
LilyPad Arduino USB 3.3V 8MHz 14 6 6 1 本机USB

 

Arduino board based on ATMEGA2560 microcontroller

板名称 工作电压 时钟速度 数字i/o 模拟输入 PWM UART 编程接口
Arduino Mega 2560 R3 5V 16MHz 54 16 14 4 USB通过ATMega16U2B
Mega Pro 3.3V 3.3V 8MHz 54 16 14 4 FTDI兼容头
Mega Pro 5V 5V 16MHz 54 16 14 4 FTDI兼容头
Mega Pro Mini 3.3V 3.3V 8MHz 54 16 14 4 FTDI兼容头

Arduino board based on AT91SAM3X8E microcontroller

板名称工作电压时钟速度数字i/o模拟输入PWMUART编程接口Arduino Mega 2560 R33.3V84MHz5412124本机USB

Posted in Uncategorized | Leave a comment

Arduino Tutorial Series: Getting Started with ESP32

The ESP8266EX has the following five advantages: 1. It has a wide operating temperature range and is able to maintain stable performance and adapt to various operating environments; 2. Designed for mobile devices, wearable electronics and IoT applications, the ESP8266EX features several proprietary technologies to achieve ultra-low power consumption. Real Time Operating System (RTOS) and Wi-Fi protocol stack, leaving up to 80% of the processing power for application programming and development. What, are you itching to see it? The device comes with a flash memory, and we can even store some of our own stuff in it. However, this feature is not open to users, we need to implement our own API to use it.

There are not many tutorials for ESP, I got started from a tutorial on Zhihu, but it was not very logical for beginners, so I was confused and didn’t quite understand it. Now, after mastering the basic usage of ESP, I would like to provide a simple tutorial for hardware enthusiasts to get started with ESP. This tutorial assumes that the reader has knowledge of serial communication. For more information about serial communication, please refer to my next article “Arduino Tutorial Series: Serial Communication Guide”. The two are consumed together for more flavor.

This is an 8266 underneath, there are eight interfaces on it, two for power supply and two for serial communication. An enable end, there are three remaining. For getting started, it is enough to understand these five, and the rest can refer to the information I recommend below.

In use, the ESP uses a serial port to communicate with the chip in it. This module, like the Arduino, can be seen as a separate board, only without the extra communication pins on it. Among the advantages I introduced in the first paragraph, it can even support RTOS, so we have to treat it like an Arduino. Usually, after we buy the ESP, it already has the function code burned in it, which is responsible for Wifi communication (it supports linking to other Wifi and can also be used as Wifi, both functions can be turned on at the same time, what do we call it? Yes, routing. (We can even use it as a router.) The data from the Wifi communication will be passed to other chips through the serial port. That is, we use the two wires of the serial communication to extend the Wifi function.

One thing I want to point out in advance: I don’t know if it is because of my device or other unknown reasons, there is always a certain probability of garbled code when using serial communication to get information. Given that my other devices use serial communication without obstacles, I guess that this ESP chip in my hands is inferior.

For the ESP to give instructions on the same as Linux, send instructions to it, it will display back or return the corresponding information.

Use the following process.

1. boot

After power on, the system is initialized. Make sure it functions properly.

2. Network

Send command to link wifi or set link password for other devices to link.

“AT+CWMODE=3\r\n”. Set wifi mode. 3 means SoftAP+Station mode, i.e. Hotspot+Terminal. That is, it can accept external wifi signal and provide wifi signal for other devices.

“AT+CIPMUX=1\r\n”. Set multi-link. It can be used for multiple devices to link.

“AT+CIPSERVER=1,5000\r\n”. Set up TCP server with port set to 5000.

3. Loop

Wait for the acceptance message and process it.

The code to accept the message is as follows.

🙒 🙒

String _comdata_wifi = “”; //for incoming wifi serial data

void getWifiSerialData(){//get raw communication information

while (wifi.available() > 0){

_comdata_wifi += char(wifi.read()); //get wifi data

delay(4);

}

}

“`

Just process the accepted message in the loop.

The baud rate of the ESP is 115200. the initial IP is 192.168.4.1. make sure to send commands to the ESP at least 500ms apart, otherwise it will error out.

Complete code.

#include <SoftwareSerial.h>

#define WIFI_TX 9

#define WIFI_RX 8

#define LED 13

SoftwareSerial wifi(WIFI_RX, WIFI_TX); //RX, TX

String _comdata_wifi = “”; //for incoming wifi serial data

String _prodata = “”;

void setup() {

pinMode(LED,OUTPUT);

digitalWrite(LED,LOW);

Serial.begin(9600);

wifi.begin(115200);

Serial.println(“system is ready!”);

wifi.println(“AT+CWMODE=3\r\n”);

delay(500);

wifi.println(“AT+CIPMUX=1\r\n”);

delay(500);

wifi.println(“AT+CIPSERVER=1,5000\r\n”);

delay(500);

}

void loop() {

getWifiSerialData();

if(Serial.available()){

String order = “”;

while (Serial.available()){

char cc = (char)Serial.read();

order += cc;

delay(2);

}

order.trim();

wifi.println(order);

}

if(_comdata_wifi!=””){

if((_comdata_wifi[2]==’+’)&&(_comdata_wifi[3]==’I’)&&(_comdata_wifi[4]==’P’))//MCU receives the data as +IPD when it enters the judgment control 0\1 to make the small light on and off

{

if((_comdata_wifi[5]==’D’)&&(_comdata_wifi[8]==’,’))

{

if(_comdata_wifi[11]==’0′)

{

digitalWrite(LED,LOW);//0 light is off }

else if (_comdata_wifi[11]==’1′)

{

digitalWrite(LED,HIGH); //1 light on

}

}

}

else{

if(_comdata_wifi[0] == ‘1’){

digitalWrite(LED,HIGH);

}

else if(_comdata_wifi[0] == ‘0’){

digitalWrite(LED,LOW);

}

}

_comdata_wifi = String(“”);

}

}

void getWifiSerialData(){//Get the raw communication information

while (wifi.available() > 0){

_comdata_wifi += char(wifi.read()); //get wifi data

delay(4);

}

}

This is a code to control a light switch.

Posted in Arduino | Leave a comment

Arduino and STM32 performance comparison, who is more powerful

Arduino and STM32 performance comparison in the end who is more powerful? Arduino has been in a hot state, but STM32 has more interfaces and is faster.

Features of Arduino and STM32

Arduino:


Arduino is more creative, it weakens the operation of specific hardware, its functions and syntax are very simple, and very “foolproof”.
Most of the

Arduino has the advantage of high code encapsulation and fewer statements, which reduces the difficulty of software development.
Arduino is relatively easy to get started, as long as you know a little hardware and C++ you can develop.
Most of the functions of Arduino have a good library, so it is very easy to use, but for slightly more complex functions are less controllable.
STM32.


For computing or control requirements, STM32 is a better choice. STM32 if you buy a development board you have to learn from the bottom of the hardware and master its various details.
STM32 is more focused on the actual engineering, in fact, many simple instruments in the factory what temperature controller, what ordinary motor controller, what low-grade PLC, and some toys in the civilian, game controller, wired keyboard and mouse and other peripherals, the college cafeteria card pos machine and so on actually used a lot.
STM32 is mainly for professional developers to do products with a certain degree of expertise, but at the same time write code to achieve the function is also relatively complex. For example, a simple string output from the serial port can be achieved by Arduino with 10 lines of code starting from a new project, but if you use STM32 development tools like Keil, you may need even more lines of code.


Arduino vs STM32

There are many versions of Arduino, and the features are not consistent. If we take Arduino UNO R3, the most common one, its controller is AVR 138 microcontroller, and the performance is not on the same level as STM32. MCU version of the Arduino in the boss, rich interface, and STM32F1 series should not be comparable, but power consumption is quite large, the chip heat obvious, while the same package STM32F1ZET6 is only a slight heat, the ambient temperature is low when you can not even feel the temperature.
According to the different characteristics of the two we can compare according to different applications.
In terms of ease of learning: Arduino is much easier compared to STM32.
The basic programming ideas required: Arduino: object-oriented class C++, class Java-based, its language based on C but some four. STM32, on the other hand, has orthodox C as the main development language.
The knowledge gained after learning: Arduino is weaker than STM32.
Because Arduino encapsulates a lot of underlying operations. Unless you try to write your own libraries for Arduino and the accompanying circuit modules, you are still only stuck with basic programming.

The degree of open source: open source if you want to open source things made with STM32, do not want to open source can not publish anything.
Peripheral circuit building difficulty: Arduino is far greater than STM32.
Extensibility: Arduino is comparable to STM32, and Arduino basically prints out most of the pins of the controller.

Cost, assuming making something with the same functionality: Arduino costs more than STM32.

To summarize

If you still don’t know how to choose, here are suggestions for options.

If you are an average student below the university level who does not know much about programming languages, it is recommended to start with Arduino.

If you have a weak C background, you will soon have the idea of giving up on STM32.

If you just want to study for employment, you should definitely study STM32 class microcontroller.

If you just want to learn for fun, non-electronics professional, no confidence, we recommend Arduino

If you have good programming skills, STM32 is recommended, and after you see what the Arduino open source community does, you can easily get it done with STM32.

Of course, if you have the ability, both contact contact, generally less than a week Arduino’s basic features you will have mastered, later if necessary, you can be very comfortable to port Arduino code to STM32 and other MCU platform.

In fact, the two are actually aimed at slightly different directions, Arduino general electronics enthusiasts and DIY choice, while STM32 is often used for the actual product development and manufacturing. But now the Arduino series can also support STM32 chips, by first downloading the Arduino firmware, and then you can use the Arduino development environment for programming. It is important to choose the right one for your project type and needs.

Posted in Arduino | Leave a comment