Getting Started

Install visual studio code Download a binary and install it from here: https://code.visualstudio.com/ Install PlatformIO addon for VSCode PlatformIO should be available for you as an extension on your left, you can just go ahead and install it in your system. Create a PlatformIO project Name your project anything you would like Choose the right Arduino board: if you are using a typical Arduino Uno board - most likely just choose “Arduino Uno” if you are using an Arduino Nano - choose Arduino nano with ATMega328p and new bootloader Either choose a folder to store the project, or use default location Choose “finish” and wait a while (especially if this is a first project) Project structure overview See the explorer on the left to see the project structure ....

Working with GPIO - digital output

Connecting LEDs Single LED output Assuming you have the default blink project running on the board, you can go ahead and plug an LED to the pin number 13 of your board to control it. Beware of the LED polarity - cathode (-) has a bigger piece inside the LED, but a shorter leg; anode (+) has a smaller piece inside the LED, but a longer leg. The resistor value you need to select using the Ohms law depending on current required by the LED....

Working with GPIO - digital & analog input

Connecting a button to digital input Let’s start with connecting a tact switch to GPIO number 2. We will configure the input with an internal pull-up resistor, so the tact-switch should be connected between the GPIO and GND. Try tu use following code, that: configures the button pin as a digital input with INPUT_PULLUP, in loop() prints an UP or DOWN message based on the button input logic level every second....

Digital input & output - continuation

Using PWM to control a servo You can use the PWM output, or more technically PPM (Pulse Position Modulation) - to control a servo. Let’s start with connecting a servo: We will use port 11, as typically we would use one of PWM-capable pins for servo control, there are alternatives though. Starting code below: #include <Arduino.h> #include <Servo.h> Servo myservo; void setup(){ myservo.attach(11); } void loop(){ for(uint16_t i = 0; i <= 180 i++){ myservo....

I2C bus - OLED display & OneWire sensor

I2C bus basics As discussed during the lecture, I2C is a digital bus that supports data exchange with multiple slave devices over two signals - clock and data. The typical Arduino pinout is A4 for data (SDA) and A5 for clock (SCL). To have multiple devices in the system, each of them has to have a different address, up to 127 different addresses are possible (7 bits). To avoid conflicts - usually digital devices with I2C bus have some way of switching their address, either over the I2C bus itself, or...

UART Communication & Bluetooth

UART communication - receiving UART data Let’s learn how to parse UART data in different ways. Reading UART in the main program loop You can just add a simplest possible example to your loop. In that case if there is any data available in the UART buffer, it will be read and printed back to UART. void loop() { if (Serial.available() > 0) { char character = Serial.read(); Serial.print("received: "); Serial....

IoT - WiFi on ESP8266

Project setup for WeMos D1 Mini Let’s start off with configuring a PlatformIO project for Wemos D1 mini. then, let’s use a simplest blink example as usual and build the code. #include <Arduino.h> void setup() { pinMode(LED_BUILTIN, OUTPUT); Serial.begin(9600); } void loop() { Serial.println("OK"); digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); } Note: most likely the first compilation will take a while, as you will need to download all the libraries and tools required to work with ESP8266 if you don’t have them yet in your system....

Cloud automation - Node-RED

Installing and starting node-RED Installing Docker We will use NodeRED in docker container. So let’s start with installing Docker for Windows: https://hub.docker.com/editions/community/docker-ce-desktop-windows It might require you to reboot your computer and install Linux Subsystem for Wondows. Running Node-RED in Docker When you have docker installed - launching node-red is as easy as: docker run -it -p 1880:1880 --name mynodered nodered/node-red And afterwards you should have it available via browser at http://localhost:1880...

Project ideas

Digital thermostat The simplest case possible, but surprisingly useful. digital temperature measurement GPIO control of a relay switch (just plain LOW/HIGH control but plug it into a relay) logic on the device to open / close the relay depending on temperature conditions, with some hysteresis Voltage logger for car battery Maybe you have a machine / car / forklift etc that often fails in the winter? You can make the following:...

Basics of GIT version control

Download software for GIT if you are on Linux - install git in accordance to your platform apt-get install git, pacman -S git on MacOS - I recommend git bash for Windows (https://gitforwindows.org/) Create a repository on GitHub Create a repostiory on GitHub, set it as a private empty repository (optional) create SSH keys and add them to your GitHub account Clone the repository Open git bash / commandline window Change directory to something appropriate, like: cd /c/Users/your-user-name/PROJECTS/ArduinoWorkshop Clone the (empty) project repository with: if you are using SSH key: git clone https://github....