The Arduino extension fully embraces the Arduino developer community and is almost fully compatible and consistent with the official Arduino IDE. On top of it, we added the most sought-after features, such as IntelliSense, Auto code completion, and on-device debugging for supported boards.
Here is a list of the core functionalities:
IntelliSense and syntax highlighting for Arduino sketches
Verify and upload your sketches in Visual Studio Code
Built-in board and library manager
Built-in example list
Built-in serial monitor
Snippets for sketches
Automatic Arduino project scaffolding
Command Palette (F1) integration of frequently used commands (e.g. Verify, Upload…)
New Integrated Arduino Debugging
For Arduino extension users, you can directly download and install the extension from Visual Studio Code Marketplace at: https://aka.ms/arduino.
Last post show a simple program run on ESP8266/NodeMCU to read Analog Input and send to Serial. And display the data on Raspberry Pi 3 using Arduino IDE Serial Plotted. This post show a Python example run on Raspberry Pi 3/Raspbian Jessie with PIXEL, to plot the serial data graphically using matplotlib library.
pyserialplot.py
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import serial
import platform
print("Python version: " + platform.python_version())
print("matplotlib version: " + mpl.__version__)
fig, ax = plt.subplots()
line, = ax.plot(np.random.rand(10))
ax.set_ylim(0, 1030)
xdata, ydata = [0]*100, [0]*100
SerialIn = serial.Serial("/dev/ttyUSB0",9600)
def update(data):
line.set_ydata(data)
return line,
def run(data):
global xdata, ydata
x,y = data
if (x == 0):
xdata = [0]*100
ydata = [0]*100
del xdata[0]
del ydata[0]
xdata.append(x)
ydata.append(y)
line.set_data(xdata, ydata)
return line,
def data_gen():
x = 9
while True:
if (x >= 9):
x = 0
else:
x += 0.1
try:
inRaw = SerialIn.readline()
inInt = int(inRaw)
except:
inInt = 0
yield x, inInt
ani = animation.FuncAnimation(fig, run, data_gen, interval=0, blit=True)
plt.show()
This python example can be run on both Python 2 and 3. To run this on Raspberry Pi/Raspbian Jessie with PIXEL, matplotlib library is need.
For Python 2: $ sudo apt-get install python-matplotlib
For Python 3: $ sudo apt-get install python3-matplotlib
In the following code, we have to get the port connected. SerialIn = serial.Serial("/dev/ttyUSB0",9600)
In Raspberry Pi/Raspbian Jessie with PIXEL, it is /dev/ttyUSB0 normal. We can check it with: $ ls /dev/ttyUSB0*
Run on Ubuntu:
The Python script work on PC/Ubuntu also. This video show running on Ubuntu 17.04/Payton 3.6 (actually behind Windows 10/VirtualBox).
This example of ESP8266/NodeMCU read input from A0, and output to Serial. The receiving side is a Raspberry Pi 3 running Raspbian Jessie with PIXEL and Arduino IDE installed, the result is display graphically using Arduino IDE's Serial Plotter. All job done on Raspberry Pi 3. ESP8266/NodeMCU connect to the Raspberry Pi 3 with USB.