Arduino Firmata protocol for pysimCoder

Prerequisites

Install the Arduino IDE and the upload StandardFirmata on your Arduino (Arduino IDE > File > Examples > Firmata > StandardFirmata).

In order to use the encoders, the following Arduino libraries are required:

  • Configurable firmata
  • Encoder
  • FirmataEncoder
  • Servo (?)

Instead of the *StandardFirmata *SW, install firmataMotor SW on Arduino


New Blocks

  • setup - Initializes Firmata on port='/dev/ttyACM0' with baud=57600
  • analogWrite - uses arduino analogWrite function on pin with mode (firmata supported modes: https://github.com/Chiff/FirmataC/blob/master/includes/firmata.h#L7-L13)
  • digitalWrite - uses arduino digitalWrite function on pin
  • pinRead - reads pin value from arduino pin with mode (firmata supported modes: https://github.com/Chiff/FirmataC/blob/master/includes/firmata.h#L7-L13)
  • customRead - array from 0 to 6
    • customRead[0] - VL53L0X distance sensor - distance in mm - SYSEX format = START_SYSEX 0x72 msb lsb END_SYSEX
    • customRead[1] - *unused at the moment
    • customRead[2] - *unused at the moment
    • customRead[3] - *unused at the moment
    • customRead[4] - *unused at the moment
    • customRead[5] - *unused at the moment
    • customRead[6] - *unused at the moment

Helpers:

  • help_HeatShield_temperature - customized block to translate voltage to temperature based on shield
  • help_TCLab_temperature - customized block to translate voltage to temperature based on shield

Tools

SocketServer

(moved to separate repo https://github.com/Chiff/pysimCoder-socketserver)

Express server that can be used to communicate with pysimCoder over TCP

Creates:

  • simple web page to plot data from the Arduino and send commands to the Arduino
  • express API
  • TCP server that listens on port 5000
  • Unix socket client

Prerequisites:

  • Node.js (see package.json for version requirements)
  • npm or yarn (see package.json for version requirements)

Usage:

  • Navigate to pysimCoder/CodeGen/arduinoFirmata/tools/SocketServer
  • If necessary edit the src/config.js file
  • Run npm run start or yarn start

Reference

Headers

https://github.com/firmata/arduino/blob/4bd508aca4f2c73ed3528529eeb5c490815b5f9b/Boards.h https://github.com/gergelytakacs/AutomationShield/blob/master/src/AutomationShield.h https://github.com/gergelytakacs/AutomationShield/blob/master/src/FloatShield.h https://github.com/gergelytakacs/AutomationShield/blob/master/src/HeatShield.h https://github.com/Chiff/FirmataC/include/Firmata.h

Misc

VL53L0X

https://www.instructables.com/Going-Beyond-StandardFirmata-Adding-New-Device-Sup/ https://docs.arduino.cc/hacking/software/FirmataLibrary https://github.com/pololu/vl53l0x-arduino

TC Lab

Node MCU

← →