Networking and communication

Networking is interesting in its abilty to create a multicore system of cheap AVRs to create something with plenty of peripherals and computing power. Useful even if you're not trying to separate things physically but also to create interesting architectures.

Serial bus protocols

Asynchronous - RS-232, 422 and 485 and multidrop and differential (for overcoming noise in a factory). A simple serial bus connects Rx and Tx with wires (buses). All the boards (nodes) can listen to the Tx line. All the boards write to the Rx line with the Rx pin set as tri-state. They remain tristated, listening to the masters, when they hear themselves being called they send their message back to the master. Described as "tristating on a serial bus".

I2C is a two wire protocol. You use SCA and SCL. Difference from RS232 is that I2C is synchronous. ATTinys have USI which can implement 2 wire (compatible with I2C) and 3 wire (compatible with USI) communication capability.

WiFi frequents the 2.4GHz ISM band becuase this is the frequency that microwave ovens operate, but WiFi just uses a far lower power. Optical transmission is unregulated, just need line of sight.

Pick a medium, what you're sending, modulation technique, sharing rules

So pick a medium and choose what you want to send into it. You then need to modulate the channel that you're sending in (might modulate frequency, amplitude, pulses). Then you need to figure out what sends what when (divided by time slots, frequencies, carrier sense).

A bus is a wire with things hanging off, a network is topological.

Radio's - Need antenna to match the impedance of free space to allow signals to pass from the antenna into freespace without reflecting back (think of wave passing from thin chain to a thick rope). Try using the nRF905 radio chip or boards with the chip and fussy circuit section integrating. You can choose to have an antenna built into the board or use an external antenna depending on the distance required for communication.

ESP8266 - Wifi implementation in very cheap break out board. They use quite a lot of power.

Why are the antenna's all along a line for "Physical Division Multiple Access"


Embedded JS with Espruino and STM32 Nucleo. To run a JS interpreter, type $ node in the terminal. Use ClojureScript to translate/transpile one programming language into JS. Now there are options to run JS embedded on a chip. These instances won't use the same compiler such as JerryScript. Esprino is a JS interpreter that can run on a boards using a STM32 chip such as a Nucleo. The Nucleo has the same break out configuration as the Arduino Duo. You compile for the Nucleo in the MBED IDE running in the browser, use that to download a compiled file that you drag into the Nucelo drive. Esprino comes as a bin file (a bunch of machine code files), so drag the bin folder into the Nucelo drive on your computer. (Short cut to find a usb device by typeing /dev/tty.u....and tab to complete)). You can control it through a terminal emulator$ miniterm.py /dev/tty.u....tab and write directly to GPIO pins in real time. Pretty useful. The event driven model of JS is very fitting for the types of functions you'd have running on these boards. Having the live coding environment of Esprino, code runs up to 3000 times slower than compiling from the online MBED IDE.

WiFi used to be a really expensive thing to do but then ESP8266 came out as a really cheap with WiFi networking capability. When the power spikes during some RF communications it can draw more than 100mA. It can do serial to WiFi, but also people hacked it to be able to run any type of code to run on it's core using Arduino. This can generate issues by having the networking and control stack on the same chip, however this only becomes problematic in time critical issues. ESP32 is coming out soon, which has dual core processor, Bluetooth, WiFi, capacitive touch sensor pins. So you can have networking running on one core and application on the other one. Will come with an Arduino Core which doesn't have as great of a performance hit as it does for the Nucleo and Esprino.

Your device communicates with ESP8266 through a serial port, get the ESP8266 to communicate with a server (Sparkfun Data, AWS IoT, Firebase). Easiest to set up the ESP8266 as a client.

My failed attempts

Failing with the ESP8266

I spent tried to incorporate the ESP8266 based on Neil's design into my double H-bridge DC controller board however after milling it I realised I'd made a couple of mistakes and incorrect assumptions:

Failing with Bluetooth + Attiny

I decided to leave my motor controller board and the ESP8266 and start from scratch with an ATTiny and a Bluetooth module. I started by trying to control the ATTiny through the Chrome serial API. This required setting two of the ATTiny GPIO pins ias Tx and Rx. Found some help here http://www.ernstc.dk/arduino/tinycom.html. I managed to get the serial port working well through Chrome, however after 3 attmpts, I was unable to fabricate an ATTiny board that I could even program to run an LED blink program. As result I wasn't able to get serial running or try and install the Bluetooth module and try and program it.

Trying Bluetooth on its own

So in the end I just tried fabbing the HM-11 board from Neil's design. The HM-11 hasn't arrived yet so well test when it does. I'm still a little confused about the voltage that the Tx and Rx lines should take as Neil's design only regulates power into the chip. But if you're using a 3.3V FTDI cable I'm not sure why this would be necessary.

Notes from class